[IMP]improved test case in compute_price_margin.
[odoo/odoo.git] / addons / product / test / compute_price_margin.yml
1 -
2   I create a Product Template "Tablate PC" with variant "2GB, Wi-Fi , 6in and set Variant Price Margin(%) = 10 and Variant Price Extra = 30."
3 -
4   !record {model: product.template, id: product_template_test1}:
5     name: Tablate PC
6     type: service
7     categ_id: product_category_8
8     uom_id: product_uom_unit
9     uom_po_id: product_uom_unit
10     product_variant_ids:
11       - variants: 2GB, Wi-Fi , 6in
12         list_price: 20.0
13         price_margin: 10.0
14         price_extra: 30.0
15 -
16   Now I check new sale price after setting price margins and price extra is equal to (20 + ((20 * 10) / 100)) + 30.
17 -
18   !python {model: product.template}: |
19     template = self.browse(cr, uid, ref("product_template_test1"))
20     for variant_id in template.product_variant_ids:
21       product = self.pool.get('product.product').browse(cr,uid,variant_id.id,context=context)
22       assert product.lst_price == (20 + ((20 * 10) / 100)) + 30, "Sell price is not correspond."
23 -
24   In order to check the Price Extra after setting 'public sale price(lst_price)' of a product. price extra is equal to 32 - (20 + ((20 * 10) / 100)).
25 -
26   !python {model: product.template}: |
27     template = self.browse(cr, uid, ref("product_template_test1"))
28     for variant_id in template.product_variant_ids:
29       self.pool.get('product.product').write(cr,uid,variant_id.id,{'lst_price':32},context=context)
30       product = self.pool.get('product.product').browse(cr,uid,variant_id.id,context=context)
31       assert product.lst_price == 32, "Sale Price should be 32."
32       assert product.list_price == 20, "Template Sale Price should not be changed."
33       assert product.price_extra == 10, "Extra Price should be 10."