Harry (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-clean-yml-product-hmo into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-clean-yml-product-hmo/+merge/87610
cleanup yml of product
=========
[IMP]
product_uom.yml: test conversion of UOM with price
product_pricelist_demo.yml: make records of pricelist with different versions
and items
product_pricelist.yml : check sale price and cost price base on pricelists
[REM]
product_report.yml: remove and put into product_pricelist.yml
Thanks
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-clean-yml-product-hmo/+merge/87610
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-clean-yml-product-hmo.
=== modified file 'product/__openerp__.py'
--- product/__openerp__.py 2012-01-05 08:10:22 +0000
+++ product/__openerp__.py 2012-01-05 12:38:25 +0000
@@ -62,9 +62,9 @@
'process/product_process.xml'
],
'test':[
- 'test/product_test.yml',
- 'test/product_price_list.yml',
- 'test/product_report.yml',
+ "product_pricelist_demo.yml",
+ 'test/product_uom.yml',
+ 'test/product_pricelist.yml',
],
'installable': True,
'active': False,
=== modified file 'product/pricelist.py'
--- product/pricelist.py 2011-12-21 22:15:04 +0000
+++ product/pricelist.py 2012-01-05 12:38:25 +0000
@@ -271,7 +271,7 @@
if price is not False:
price_limit = price
price = price * (1.0+(res['price_discount'] or 0.0))
- price = rounding(price, res['price_round'])
+ price = rounding(price, res['price_round']) #TOFIX: rounding with tools.float_rouding
price += (res['price_surcharge'] or 0.0)
if res['price_min_margin']:
price = max(price, price_limit+res['price_min_margin'])
=== modified file 'product/product.py'
--- product/product.py 2011-12-31 07:14:16 +0000
+++ product/product.py 2012-01-05 12:38:25 +0000
@@ -406,10 +406,11 @@
context = {}
quantity = context.get('quantity') or 1.0
pricelist = context.get('pricelist', False)
+ partner = context.get('partner', False)
if pricelist:
for id in ids:
try:
- price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, context=context)[pricelist]
+ price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, partner=partner, context=context)[pricelist]
except:
price = 0.0
res[id] = price
=== added file 'product/product_pricelist_demo.yml'
--- product/product_pricelist_demo.yml 1970-01-01 00:00:00 +0000
+++ product/product_pricelist_demo.yml 2012-01-05 12:38:25 +0000
@@ -0,0 +1,62 @@
+-
+ !record {model: product.product, id: product_product_pc2}:
+ uom_id: product_uom_unit
+ categ_id: product_category_pc
+-
+ !record {model: product.pricelist, id: customer_pricelist}:
+ name: Customer Pricelist
+ type: sale
+ version_id:
+ - name: v1.0
+ date_start: 2012-01-01
+ items_id:
+ - name: Default pricelist
+ base: -1
+ base_pricelist_id: list0
+ - name: 10% Discount on PC2
+ sequence: 1
+ product_id: product_product_pc2
+ base: !eval (ref('product.list_price'))
+ price_discount: -0.10
+ - name: 1 surchange on PC3
+ sequence: 1
+ product_id: product_product_pc3
+ base: !eval (ref('product.list_price'))
+ price_surcharge: 1
+ - name: 5% Discount on all IT components
+ sequence: 1
+ min_quantity: 2
+ base: !eval (ref('product.list_price'))
+ categ_id: product_category_10
+ price_discount: -0.05
+ - name: v2.0 (Special Discount on all products during last 5 days in current year)
+ date_start: 2011-12-27
+ date_end: 2011-12-31
+ items_id:
+ - name: 30% Discount on all products
+ price_discount: -0.30
+ sequence: 1
+ base: !eval (ref('product.list_price'))
+-
+ !record {model: product.pricelist, id: supplier_pricelist}:
+ name: Supplier Pricelist
+ type: sale
+ version_id:
+ - name: v1.0
+ items_id:
+ - name: 20% Discount given by my supplier
+ sequence: 1
+ price_min_margin: 2
+ price_max_margin: -5
+ product_id: product_product_pc2
+ base: -2
+-
+ !record {model: pricelist.partnerinfo, id: supplier_pricelist0_product_pc2}:
+ suppinfo_id: supplierinfo6
+ min_quantity: 3
+ price: 405
+-
+ !record {model: pricelist.partnerinfo, id: supplier_pricelist1_product_pc2}:
+ suppinfo_id: supplierinfo6
+ min_quantity: 1
+ price: 455
=== renamed file 'product/test/product_price_list.yml' => 'product/test/product_pricelist.yml'
--- product/test/product_price_list.yml 2012-01-05 08:10:22 +0000
+++ product/test/product_pricelist.yml 2012-01-05 12:38:25 +0000
@@ -1,124 +1,74 @@
-
- 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
+ In order to check the calculation of price of the products according to pricelist,
+-
+ I check sale price of PC2.
+-
+ !python {model: product.product}: |
+ context.update({'pricelist': ref("customer_pricelist"), 'quantity':1})
+ product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
+ assert product.price == product.lst_price-product.lst_price*(0.10), "Sell price is not correspond."
+-
+ I check sale price of PC3.
+-
+ !python {model: product.product}: |
+ product = self.browse(cr, uid, ref("product_product_pc3"), context=context)
+ assert product.price == product.lst_price + 1, "Sell price is not correspond."
+-
+ I check sale price of IT componet.
+-
+ !python {model: product.product}: |
+ product = self.browse(cr, uid, ref("product_product_mb1"), context=context)
+ assert product.price == product.lst_price, "Sell price is not correspond."
+
+-
+ I check sale price of IT componet if more than 3 PCE.
+-
+ !python {model: product.product}: |
+ context.update({'quantity':5})
+ product = self.browse(cr, uid, ref("product_product_mb1"), context=context)
+ assert product.price == product.lst_price-product.lst_price*(0.05), "Sell price is not correspond."
+-
+ I check sale price of PC4.
+-
+ !python {model: product.product}: |
+ context.update({'quantity':1})
+ product = self.browse(cr, uid, ref("product_product_pc4"), context=context)
+ assert product.price == product.lst_price, "Sell price is not correspond."
+
+-
+ I check sale price of PC4 on end of year.
+-
+ !python {model: product.product}: |
+ context.update({'quantity':1, 'date': '2011-12-31'})
+ product = self.browse(cr, uid, ref("product_product_pc4"), context=context)
+ assert product.price == product.lst_price-product.lst_price*(0.30), "Sell price is not correspond."
+
+-
+ I check cost price of PC2.
+-
+ !python {model: product.product}: |
+ context.update({'quantity':1, 'date': False, 'partner': ref('base.res_partner_4'), 'pricelist': ref("supplier_pricelist")})
+ product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
+ assert product.price == 450, "cost price is not correspond."
+-
+ I check cost price of PC2 if more than 3 PCE.
+-
+ !python {model: product.product}: |
+ context.update({'quantity':3})
+ product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
+ assert product.price == 400, "cost price is not correspond."
+
+-
+ I print the sale prices report.
+-
+ !python {model: product.product}: |
+ ctx = {}
+ ctx.update({'model': 'product.product','date':'2011-12-30','active_ids': [ref('product.product_product_pc1'), ref('product.product_product_pc2'), ref('product.product_product_pc3'), ref('product.product_product_pc4')]})
+ data_dict = {'qty1': 1,
+ 'qty2': 5,
+ 'qty3': 10,
+ 'qty4': 15,
+ 'qty5': 30,
+ 'price_list':ref('customer_pricelist')}
+ from tools import test_reports
+ test_reports.try_report_action(cr, uid, 'action_product_price_list',wiz_data=data_dict, context=ctx, our_module='product')
=== removed file 'product/test/product_report.yml'
--- product/test/product_report.yml 2011-01-14 00:11:01 +0000
+++ product/test/product_report.yml 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
--
- Print the Products Pricelists Report through the wizard
--
- !python {model: product.product}: |
- ctx={}
- ctx.update({'model': 'product.product','active_ids': [ref('product.product_product_pc1'), ref('product.product_product_pc3')]})
- data_dict = {'qty1': 1,
- 'qty2': 5,
- 'qty3': 10,
- 'qty4': 0,
- 'qty5': 0,
- 'price_list':ref('product.list0')}
- from tools import test_reports
- test_reports.try_report_action(cr, uid, 'action_product_price_list',wiz_data=data_dict, context=ctx, our_module='product')
-
-
=== renamed file 'product/test/product_test.yml' => 'product/test/product_uom.yml'
--- product/test/product_test.yml 2011-11-14 22:19:24 +0000
+++ product/test/product_uom.yml 2012-01-05 12:38:25 +0000
@@ -1,33 +1,15 @@
-
- In order to test product,I start by creating a 20KG UOM for 'Sugar'
--
- !record {model: product.uom, id: product_20k_uom_sugar}:
- name: 20KG
- uom_type: bigger
- category_id: product.product_uom_categ_kgm
- factor_inv: 20
--
- I create a 10KG UOM for 'Sugar'
--
- !record {model: product.uom, id: product_10k_uom_sugar}:
- name: 10KG
- uom_type: bigger
- category_id: product.product_uom_categ_kgm
- factor_inv: 10
--
- I create a new product 'Sugar' in 20KG UOM.
--
- !record {model: product.product, id: product_sugar_id1}:
- categ_id: 'product.product_category_rawmaterial0'
- name: Sugar 20KG
- procure_method: make_to_order
- standard_price: 400.0
- uom_id: product.product_20k_uom_sugar
- uom_po_id: product.product_20k_uom_sugar
--
- I test onchanged on UOM, Create Duplicate Product and Delete original Product.
--
- !python {model: product.product}: |
- self.onchange_uom(cr ,uid, [ref("product_sugar_id1")], ref("product.product_20k_uom_sugar"), ref("product.product_10k_uom_sugar"))
- self.copy(cr, uid, ref("product_sugar_id1"))
- self.unlink(cr, uid, [ref("product_sugar_id1")])
+ In order to test conversation of UOM,
+-
+ I convert Grams into TON with price.
+-
+ !python {model: product.uom}: |
+ from_uom_id = ref("product_uom_gram")
+ to_uom_id = ref("product_uom_ton")
+ price = 2
+ qty = 1020000
+ price = self._compute_price(cr, uid, from_uom_id, price, to_uom_id)
+ qty = self._compute_qty(cr, uid, from_uom_id, qty, to_uom_id)
+ assert qty == 1.02, "Qty is not correspond."
+ assert price == 2000000.0, "Price is not correspond."
+
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp