diff --git a/addons/mrp_account/__manifest__.py b/addons/mrp_account/__manifest__.py index f16c781339f..3203525413e 100644 --- a/addons/mrp_account/__manifest__.py +++ b/addons/mrp_account/__manifest__.py @@ -21,7 +21,10 @@ If the automated inventory valuation is active, the necessary accounting entries 'depends': ['mrp', 'stock_account'], "init_xml" : [], "demo_xml" : [], - "data": ["views/product_views.xml"], + "data": [ + "views/product_views.xml", + "views/mrp_production_views.xml", + ], 'installable': True, 'auto_install': True, } diff --git a/addons/mrp_account/models/mrp_production.py b/addons/mrp_account/models/mrp_production.py index 2b42f62318e..4a2d0f52a29 100644 --- a/addons/mrp_account/models/mrp_production.py +++ b/addons/mrp_account/models/mrp_production.py @@ -32,8 +32,7 @@ class MrpProduction(models.Model): if finished_move.product_id.cost_method in ('fifo', 'average'): qty_done = finished_move.product_uom._compute_quantity(finished_move.quantity_done, finished_move.product_id.uom_id) extra_cost = self.extra_cost * qty_done - finished_move.price_unit = (sum([-m.value for m in consumed_moves]) + work_center_cost + extra_cost) / qty_done - finished_move.value = sum([-m.value for m in consumed_moves]) + work_center_cost + extra_cost + finished_move.price_unit = (sum([-m.stock_valuation_layer_ids.value for m in consumed_moves]) + work_center_cost + extra_cost) / qty_done return True def _prepare_wc_analytic_line(self, wc_line): @@ -69,3 +68,10 @@ class MrpProduction(models.Model): res = super(MrpProduction, self).button_mark_done() self._costs_generate() return res + + def action_view_stock_valuation_layers(self): + self.ensure_one() + domain = [('id', 'in', (self.move_raw_ids + self.move_finished_ids).stock_valuation_layer_ids.ids)] + action = self.env.ref('stock_account.stock_valuation_layer_action').read()[0] + return dict(action, domain=domain) + diff --git a/addons/mrp_account/tests/test_mrp_account.py b/addons/mrp_account/tests/test_mrp_account.py index 19ab942abb7..ed35c0da1ff 100644 --- a/addons/mrp_account/tests/test_mrp_account.py +++ b/addons/mrp_account/tests/test_mrp_account.py @@ -83,7 +83,7 @@ class TestMrpAccount(common.TransactionCase): produce_wizard = produce_form.save() produce_wizard.do_produce() production_table.post_inventory() - move_value = production_table.move_finished_ids.filtered(lambda x: x.state == "done").value + move_value = production_table.move_finished_ids.filtered(lambda x: x.state == "done").stock_valuation_layer_ids.value # 1 table head at 20 + 4 table leg at 15 + 4 bolt at 10 + 10 screw at 10 + 1*20 (extra cost) self.assertEqual(move_value, 141, 'Thing should have the correct price') diff --git a/addons/mrp_account/views/mrp_production_views.xml b/addons/mrp_account/views/mrp_production_views.xml new file mode 100644 index 00000000000..1ac5394ca3e --- /dev/null +++ b/addons/mrp_account/views/mrp_production_views.xml @@ -0,0 +1,15 @@ + + + mrp.production.view.inherited + mrp.production + + + +