[MERGE] product: cleanup yml

bzr revid: hmo@tinyerp.com-20120105122219-r7m9pbeyihr2qz0i
This commit is contained in:
Harry (OpenERP) 2012-01-05 17:52:19 +05:30
commit 5e62369fd0
8 changed files with 162 additions and 52 deletions

View File

@ -61,7 +61,13 @@ Print product labels with barcode.
'partner_view.xml',
'process/product_process.xml'
],
'test':['test/product_report.yml','test/product_test.yml'],
'test':[
"product_pricelist_demo.yml",
'test/product_uom.yml',
'test/product_pricelist.yml',
],
'installable': True,
'active': False,
'certificate': '0068861431437',

View File

@ -271,7 +271,7 @@ class product_pricelist(osv.osv):
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'])

View File

@ -406,10 +406,11 @@ class product_product(osv.osv):
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

View File

@ -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

View File

@ -0,0 +1,75 @@
-
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')

View File

@ -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')

View File

@ -1,33 +0,0 @@
-
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")])

View File

@ -0,0 +1,15 @@
-
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."