From 372b900fe3125c085a7671d3f38fc8c7f6fecfbc Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Fri, 17 Jul 2020 09:08:36 +0000 Subject: [PATCH] [IMP] mrp: forecast widget Add the forecast widget for the manufacture orders' components. task-2058495 --- addons/mrp/models/stock_move.py | 6 ++++++ addons/mrp/tests/test_order.py | 11 ++++++++--- addons/mrp/views/mrp_production_views.xml | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index ea3b578c165..4e21aec49fc 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -317,6 +317,12 @@ class StockMove(models.Model): vals['state'] = 'assigned' return vals + @api.model + def _consuming_picking_types(self): + res = super()._consuming_picking_types() + res.append('mrp_operation') + return res + def _get_source_document(self): res = super()._get_source_document() return res or self.production_id or self.raw_material_production_id diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index 341afe9d379..5906b45bb73 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -869,13 +869,18 @@ class TestMrpOrder(TestMrpCommon): mo_form = Form(mo) mo_form.qty_producing = 3 self.assertEqual(sum([x['quantity_done'] for x in mo_form.move_raw_ids._records]), 15, 'Update the produce quantity should change the components quantity.') - self.assertEqual(sum([x['reserved_availability'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.') + mo = mo_form.save() + self.assertEqual(sum(mo.move_raw_ids.mapped('reserved_availability')), 5, 'Update the produce quantity should not change the components reserved quantity.') + mo_form = Form(mo) mo_form.qty_producing = 4 self.assertEqual(sum([x['quantity_done'] for x in mo_form.move_raw_ids._records]), 20, 'Update the produce quantity should change the components quantity.') - self.assertEqual(sum([x['reserved_availability'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.') + mo = mo_form.save() + self.assertEqual(sum(mo.move_raw_ids.mapped('reserved_availability')), 5, 'Update the produce quantity should not change the components reserved quantity.') + mo_form = Form(mo) mo_form.qty_producing = 1 self.assertEqual(sum([x['quantity_done'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should change the components quantity.') - self.assertEqual(sum([x['reserved_availability'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.') + mo = mo_form.save() + self.assertEqual(sum(mo.move_raw_ids.mapped('reserved_availability')), 5, 'Update the produce quantity should not change the components reserved quantity.') # try adding another product that doesn't belong to the BoM with mo_form.move_raw_ids.new() as move: move.product_id = self.product_4 diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index ece07e2a67d..3e70dbe313b 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -254,7 +254,7 @@ - +