[IMP] product: Some more improvements.

bzr revid: uco@tinyerp.com-20111228084912-bn67ngyu6950u108
This commit is contained in:
Ujjvala Collins (OpenERP) 2011-12-28 14:19:12 +05:30
parent 63e7a6465e
commit 9f25131870
1 changed files with 17 additions and 25 deletions

View File

@ -3,23 +3,19 @@
-
I create a pricelist rule for giving discount on some quantities of product.
-
!record {model: product.pricelist.item, id: pricelist_rules_for_more_qty1}:
!record {model: product.pricelist.item, id: item0}:
name: Default Public Pricelist for More Qty
min_quantity: 5
sequence: 5
base: 1
price_version_id: product.ver0
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") ,5,False)])
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc1"),15,False)])
new_price = result[ref("product_product_pc1")].values()
ctx = context.copy()
ctx.update({'pricelist': ref("product.list0"), 'quantity': 5})
product_price = product_obj.browse(cr, uid, ref("product_product_pc1"), context=ctx).price
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.
@ -29,7 +25,7 @@
min_quantity: 1
product_id: product.product_product_pc2
sequence: 4
base: 1
base: !eval (ref('product.list_price'))
price_version_id: product.ver0
price_discount: -0.20
-
@ -39,9 +35,8 @@
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()
ctx = context.copy()
ctx.update({'pricelist': ref("product.list0"), 'quantity': 1})
product_price = product_obj.browse(cr, uid, ref("product_product_pc2"), context=ctx).price
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.
@ -51,7 +46,7 @@
min_quantity: 1
categ_id: product.cat1
sequence: 3
base: 1
base: !eval (ref('product.list_price'))
price_version_id: product.ver0
price_discount: -0.25
-
@ -61,9 +56,8 @@
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()
ctx = context.copy()
ctx.update({'pricelist': ref("product.list0"), 'quantity': 1})
product_price = product_obj.browse(cr, uid, ref("product_product_fan2"), context=ctx).price
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.
@ -76,7 +70,7 @@
items_id:
- name: End of Years Price List Version Rule
min_quantity: 1
base: 1
base: !eval (ref('product.list_price'))
price_discount: -0.30
-
!record {model: product.pricelist.item, id: pricelist_rules_for_end_year1}:
@ -93,9 +87,8 @@
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")
ctx = context.copy()
ctx.update({'pricelist': ref("product.list0"), 'quantity': 1})
product_price = product_obj.browse(cr, uid, ref("product_product_pc1"), context=ctx).price
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.
@ -108,7 +101,7 @@
items_id:
- name: Special Customer Price List Version Rule
min_quantity: 1
base: 1
base: !eval (ref('product.list_price'))
price_discount: -0.40
-
!record {model: res.partner, id: base.res_partner_agrolait}:
@ -120,9 +113,8 @@
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()
ctx = context.copy()
ctx.update({'pricelist': ref("product.special_customer_price_list1"), 'quantity': 1})
product_price = product_obj.browse(cr, uid, ref("product_product_pc4"), context=ctx).price
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.