From 705b256b8c8644e0e04af6e9b3e649d450a79481 Mon Sep 17 00:00:00 2001 From: Djamel Touati Date: Thu, 28 Dec 2023 15:44:15 +0100 Subject: [PATCH] [REV] mrp: revert commit fe508c6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts the following commits : https://github.com/odoo/odoo/commit/fe508c6b2cb1b92d7b063cc194a3dad37f4eb255 The behavior for tracked products is different; the quantity is modified in a wizard by adding other `stock.move.line`, which does not trigger the change of the 'picked' field to true and makes the behavior different from non-tracked products. We prefer to remove this fix and keep the same behavior for all types of products. The user can manually select the checkbox for the 'picked' field. Update the optional show for the field “picked” in the MO form closes odoo/odoo#147695 Signed-off-by: Arnold Moyaux (arm) --- addons/mrp/models/stock_move.py | 2 -- addons/mrp/static/src/widgets/mrp_consumed.js | 2 +- addons/mrp/static/tests/tours/mrp_manual_consumption.js | 4 ++++ addons/mrp/tests/test_manual_consumption.py | 5 +++-- addons/mrp/views/mrp_production_views.xml | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 5f7c50a9b94..5677ce9ba7b 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -292,8 +292,6 @@ class StockMove(models.Model): def write(self, vals): if self.env.context.get('force_manual_consumption'): vals['manual_consumption'] = True - if vals.get('manual_consumption'): - vals['picked'] = True if 'product_uom_qty' in vals and 'move_line_ids' in vals: # first update lines then product_uom_qty as the later will unreserve # so possibly unlink lines diff --git a/addons/mrp/static/src/widgets/mrp_consumed.js b/addons/mrp/static/src/widgets/mrp_consumed.js index 854ca5d0647..2419c84f401 100644 --- a/addons/mrp/static/src/widgets/mrp_consumed.js +++ b/addons/mrp/static/src/widgets/mrp_consumed.js @@ -23,7 +23,7 @@ export class MrpConsumed extends FloatField { } onInput(ev) { - return this.props.record.update({ manual_consumption: true, picked: true }); + return this.props.record.update({ manual_consumption: true }); } } diff --git a/addons/mrp/static/tests/tours/mrp_manual_consumption.js b/addons/mrp/static/tests/tours/mrp_manual_consumption.js index 02b58eda0e2..714a3ffd575 100644 --- a/addons/mrp/static/tests/tours/mrp_manual_consumption.js +++ b/addons/mrp/static/tests/tours/mrp_manual_consumption.js @@ -86,6 +86,10 @@ registry.category("web_tour.tours").add('test_mrp_manual_consumption_02', { trigger: 'div[name="quantity"] input', run: 'text 16.0' }, + { + trigger: 'div[name="picked"] input', + run: 'click', + }, { content: "Click Pager", trigger: ".o_pager_value:first()", diff --git a/addons/mrp/tests/test_manual_consumption.py b/addons/mrp/tests/test_manual_consumption.py index d449a09e831..f91cf38fa95 100644 --- a/addons/mrp/tests/test_manual_consumption.py +++ b/addons/mrp/tests/test_manual_consumption.py @@ -89,6 +89,7 @@ class TestTourManualConsumption(HttpCase): def test_mrp_manual_consumption_02(self): """ test that when a new quantity is manually set for a component, + and the field picked is set to True, and the MO is marked as done, the component quantity is not overwritten. """ Product = self.env['product.product'] @@ -106,7 +107,7 @@ class TestTourManualConsumption(HttpCase): 'product_qty': 1, 'type': 'normal', 'bom_line_ids': [ - (0, 0, {'product_id': product_nt.id, 'product_qty': 1}), + (0, 0, {'product_id': product_nt.id, 'product_qty': 1, 'manual_consumption': True}), ], }) @@ -119,7 +120,7 @@ class TestTourManualConsumption(HttpCase): self.assertEqual(mo.state, 'confirmed') move_nt = mo.move_raw_ids - self.assertEqual(move_nt.manual_consumption, False) + self.assertEqual(move_nt.manual_consumption, True) self.assertEqual(move_nt.quantity, 0) self.assertFalse(move_nt.picked) diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index d759e05d840..6b1cf8b26bc 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -408,7 +408,7 @@ force_save="1" widget="mrp_consumed"/> - +