From 6339bae8759526bef94fd024a6bbf645406a2c6d Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 20 Apr 2016 18:54:49 +0200 Subject: [PATCH] [FIX] stock_landed_costs: correct rounding tests Previous forward-port (17b6191a027b84d9e7d879053a4880e6fff62ba6) includes new tests (added by eb26694e0f30445419e58e88eabae3db1aa18865) 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. --- .../test/stock_landed_costs_rounding.yml | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml b/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml index d0dd1ca9eb3..fd2ff25e297 100644 --- a/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml +++ b/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml @@ -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]