From 0b60c863eff18705cfd4569f64d91561d2d88592 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Wed, 12 May 2021 15:01:18 +0000 Subject: [PATCH] [IMP] mrp: don't require consumed widget when multi-location Before this commit, it was required to always use the widget to edit the consumed quantity of a component when multi-location or packages setting is active. This was not user friendly so this commit relaxes the requirement to only tracked products and gives users the option to still edit the consumed move lines directly if desired. We also distinguish between when using the widget is required or not with the widget button color. Note that if quantity consumed is greater than amount reserved in different locations, the difference will default to the move's source location (this is consistent with what happens when the `qty_producing` is changed in the MO and the consumed quantities are scaled to match.) Task: 2518523 Upgrade PR: odoo/upgrade#2655 closes odoo/odoo#73939 Related: odoo/enterprise#19732 Signed-off-by: Arnold Moyaux --- addons/mrp/models/stock_move.py | 7 +++++++ addons/mrp/static/src/scss/mrp_fields.scss | 8 ++++++++ addons/mrp/views/mrp_production_views.xml | 19 +++++++++++-------- addons/stock/models/stock_move.py | 22 +++++++++++++--------- addons/stock/views/stock_move_views.xml | 4 ++-- addons/stock/views/stock_picking_views.xml | 8 ++++---- 6 files changed, 45 insertions(+), 23 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index cef9bbb3360..a662a976a68 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -419,3 +419,10 @@ class StockMove(models.Model): candidate_moves_list.append(production.move_raw_ids) for production in self.mapped('production_id'): candidate_moves_list.append(production.move_finished_ids) + + def _multi_line_quantity_done_set(self, quantity_done): + if self.raw_material_production_id: + self.move_line_ids.filtered(lambda ml: ml.state not in ('done', 'cancel')).qty_done = 0 + self.move_line_ids = self._set_quantity_done_prepare_vals(quantity_done) + else: + super()._multi_line_quantity_done_set(quantity_done) diff --git a/addons/mrp/static/src/scss/mrp_fields.scss b/addons/mrp/static/src/scss/mrp_fields.scss index da959565fc8..e442db35271 100644 --- a/addons/mrp/static/src/scss/mrp_fields.scss +++ b/addons/mrp/static/src/scss/mrp_fields.scss @@ -9,3 +9,11 @@ .o_should_consume{ padding-left: 0.3em; } + +.btn-link.o_optional_button{ + color: gray; + + &:hover { + filter: brightness(0.9); + } +} diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index 2903cb060ff..8333091096e 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -94,7 +94,7 @@