[FIX] stock_landed_costs: correct rounding tests

Previous forward-port (17b6191a02) includes
new tests (added by eb26694e0f) which are
now broken because quants with a cost of zero are forbidden.

Force a standard_price on created product to avoid this situation.
Adapt quants cost values.

Also change references of accounts and journals on records.
This commit is contained in:
Christophe Simonis
2016-04-20 19:17:34 +02:00
parent ab8a93c852
commit 6339bae875
@@ -13,19 +13,21 @@
-
!record {model: product.product, id: product_landed_cost_3}:
name: "LC product 3"
standard_price: 10
cost_method: real
uom_id: product_uom_unit_round_1
valuation: real_time
property_stock_account_input: account.o_expense
property_stock_account_output: account.o_income
property_stock_account_input: o_expense
property_stock_account_output: o_income
-
!record {model: product.product, id: product_landed_cost_4}:
name: "LC product 4"
standard_price: 8
cost_method: real
uom_id: product_uom_unit_round_1
valuation: real_time
property_stock_account_input: account.o_expense
property_stock_account_output: account.o_income
property_stock_account_input: o_expense
property_stock_account_output: o_income
-
I create 2 pickings moving those products
-
@@ -37,8 +39,6 @@
product_id: product_landed_cost_3
product_uom_qty: 13
product_uom: product_uom_unit_round_1
product_uos_qty: 13
product_uos: product_uom_unit_round_1
location_id: stock.stock_location_customers
location_dest_id: stock.stock_location_stock
-
@@ -50,8 +50,6 @@
product_id: product_landed_cost_4
product_uom_qty: 1
product_uom: product.product_uom_dozen
product_uos_qty: 1
product_uos: product.product_uom_dozen
location_id: stock.stock_location_customers
location_dest_id: stock.stock_location_stock
price_unit: !eval 17.00/12.00
@@ -69,13 +67,13 @@
quants = pick.move_lines.quant_ids
assert len(quants) == 1
assert quants.qty == 13
assert quants.cost == 0.0
assert quants.cost == 10.0
-
I create a landed cost for picking 3
-
!record {model: stock.landed.cost, id: stock_landed_cost_2}:
picking_ids: [picking_landed_cost_3]
account_journal_id: account.expenses_journal
account_journal_id: expenses_journal
cost_lines:
- name: 'equal split'
split_method: 'equal'
@@ -113,7 +111,7 @@
for valuation in landed_cost.valuation_adjustment_lines:
quants = valuation.move_id.quant_ids
assert quants.mapped('qty') == [12.0, 1.0]
assert quants.mapped('cost') == [1.15, 1.2]
assert quants.mapped('cost') == [11.15, 11.2]
-
We perform all the tests for LC_pick_4
-
@@ -126,15 +124,15 @@
pick = self.browse(cr, uid, [ref("picking_landed_cost_4")], context=context)
quants = pick.move_lines.quant_ids
assert len(quants) == 2
assert quants.mapped('qty') == [11.0, 1.0]
assert [round(c, 2) for c in quants.mapped('cost')] == [1.42, 1.38]
assert len(quants) == 1
assert quants.mapped('qty') == [12.0]
assert [round(c, 2) for c in quants.mapped('cost')] == [8.0]
-
I create a landed cost for picking 4
-
!record {model: stock.landed.cost, id: stock_landed_cost_3}:
picking_ids: [picking_landed_cost_4]
account_journal_id: account.expenses_journal
account_journal_id: expenses_journal
cost_lines:
- name: 'equal split'
split_method: 'equal'
@@ -172,4 +170,4 @@
for valuation in landed_cost.valuation_adjustment_lines:
quants = valuation.move_id.quant_ids
assert quants.mapped('qty') == [11.0, 1.0]
assert [round(c, 2) for c in quants.mapped('cost')] == [2.34, 2.26]
assert [round(c, 2) for c in quants.mapped('cost')] == [8.92, 8.88]