[MERGE] product: add tests on pricelists
bzr revid: rco@openerp.com-20120105081022-faf3i79oslv3i77s
This commit is contained in:
commit
016d0b705a
|
@ -61,7 +61,11 @@ Print product labels with barcode.
|
|||
'partner_view.xml',
|
||||
'process/product_process.xml'
|
||||
],
|
||||
'test':['test/product_report.yml','test/product_test.yml'],
|
||||
'test':[
|
||||
'test/product_test.yml',
|
||||
'test/product_price_list.yml',
|
||||
'test/product_report.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '0068861431437',
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
-
|
||||
In order to check the calculation of price of the products according to selected pricelist,
|
||||
I create a pricelist rule for giving discount on some quantities of product.
|
||||
-
|
||||
!record {model: product.pricelist.item, id: item0}:
|
||||
name: Default Public Pricelist for More Qty
|
||||
min_quantity: 15
|
||||
price_discount: -0.10
|
||||
-
|
||||
I check whether the product consumes the price, based on the given quantities, correctly or not.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
product_obj = self.pool.get("product.product")
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc1"),15,False)])
|
||||
new_price = result[ref("product_product_pc1")].values()
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 15})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc1"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of the product."
|
||||
-
|
||||
I create a pricelist rule to give discount for a specific product.
|
||||
-
|
||||
!record {model: product.pricelist.item, id: pricelist_rules_for_pc2}:
|
||||
name: Default Public Pricelist for PC2
|
||||
min_quantity: 1
|
||||
product_id: product.product_product_pc2
|
||||
sequence: 4
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_version_id: product.ver0
|
||||
price_discount: -0.20
|
||||
-
|
||||
I check whether the selected product is having the price correctly or not.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc2"),1,False)])
|
||||
product_obj = self.pool.get("product.product")
|
||||
new_price = result[ref("product_product_pc2")].values()
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc2"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of the special product."
|
||||
-
|
||||
I create a pricelist rule to give discount for a specific category of products.
|
||||
-
|
||||
!record {model: product.pricelist.item, id: pricelist_rules_category_1}:
|
||||
name: Default Public Pricelist for Category
|
||||
min_quantity: 1
|
||||
categ_id: product.cat1
|
||||
sequence: 3
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_version_id: product.ver0
|
||||
price_discount: -0.25
|
||||
-
|
||||
I check whether the price of products of selected product category is correctly set or not.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_fan2"),1,False)])
|
||||
product_obj = self.pool.get("product.product")
|
||||
new_price = result[ref("product_product_fan2")].values()
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_fan2"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of the special category of products."
|
||||
-
|
||||
I create a pricelist to give the discount at the end of year.
|
||||
-
|
||||
!record {model: product.pricelist, id: product_price_list_end_year}:
|
||||
name: End of Year Price List
|
||||
type: sale
|
||||
version_id:
|
||||
- name: End of Year Price List Version
|
||||
items_id:
|
||||
- name: End of Year Price List Version Rule
|
||||
min_quantity: 1
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_discount: -0.30
|
||||
-
|
||||
!record {model: product.pricelist.item, id: pricelist_rules_for_end_year1}:
|
||||
name: End of Year Price List Version Rule - Public Pricelist
|
||||
min_quantity: 1
|
||||
sequence: 2
|
||||
base: -1
|
||||
price_version_id: product.ver0
|
||||
base_pricelist_id: product_price_list_end_year
|
||||
-
|
||||
Now, I check that the end of the year pricelist rule is applied on products.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc1"),1,False)])
|
||||
new_price = result[ref("product_product_pc1")].values()
|
||||
product_obj = self.pool.get("product.product")
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc1"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of product at the end of the year."
|
||||
-
|
||||
I create a pricelist for special customers by which they can get discount on products.
|
||||
-
|
||||
!record {model: product.pricelist, id: special_customer_price_list1}:
|
||||
name: Price List For Special Customer
|
||||
type: sale
|
||||
version_id:
|
||||
- name: Special Customer Price List Version
|
||||
items_id:
|
||||
- name: Special Customer Price List Version Rule
|
||||
min_quantity: 1
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_discount: -0.40
|
||||
-
|
||||
!record {model: res.partner, id: base.res_partner_agrolait}:
|
||||
property_product_pricelist: special_customer_price_list1
|
||||
-
|
||||
I check that the customer is getting the discount according to the pricelist.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.special_customer_price_list1")], [(ref("product_product_pc4"),1,ref("base.res_partner_agrolait"))])
|
||||
product_obj = self.pool.get("product.product")
|
||||
new_price = result[ref("product_product_pc4")].values()
|
||||
context.update({'pricelist': ref("product.special_customer_price_list1"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc4"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given to special customer."
|
||||
-
|
||||
I set the supplier pricelist for a product to get the discount at the time of purchase.
|
||||
-
|
||||
!record {model: product.supplierinfo, id: supplierinfo5}:
|
||||
pricelist_ids:
|
||||
- min_quantity: 10
|
||||
price: 200
|
Loading…
Reference in New Issue