From 4da8c6ebca024b31278a946aef55cc37f0210b33 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Fri, 16 Jun 2023 08:47:59 +0200 Subject: [PATCH] [IMP] stock,mrp: detailed operation without RPCs This commit replaces the opening of the stock moves detailed operation wizard by the one2Many record preview. This means creating a move in a picking is still done via a new line but the edition is done via the `fa-list` button that open the record in the web client. The goal is to reduce the RPCs call as much as possible. The stock move lines data are stored in the stock move record until the picking save. Additionally, this commit change a bit the immediate transfers flows. The stock move show only initial demand (`product_uom_qty`) but the column wording is still "Done". In the detailed operation view, the stock move line `qty_done` is displayed as "Reserved". At picking validation, the user is expected to enter the same quantity in `product_uom_qty` and `quantity_done`. If `product_uom_qty` is equals to 0, the done quantity is used as actual transfer quantity. If `product_uom_qty` is different than 0 but small than the done quantity, an error is raised. Task: 3256447 Part-of: odoo/odoo#124409 --- addons/mrp/models/stock_move.py | 2 +- addons/mrp/tests/test_stock.py | 2 +- addons/mrp/views/mrp_production_views.xml | 4 - .../tests/test_subcontracting.py | 33 ++++-- .../views/stock_picking_views.xml | 2 +- .../tests/test_subcontracting_account.py | 2 +- .../product_expiry/views/stock_move_views.xml | 11 ++ .../tests/test_reordering_rule.py | 6 +- addons/stock/__manifest__.py | 2 +- addons/stock/models/stock_move.py | 69 +++++------ addons/stock/models/stock_move_line.py | 16 ++- addons/stock/models/stock_picking.py | 22 +++- addons/stock/models/stock_quant.py | 6 +- .../fields/stock_move_line_x2_many_field.js | 13 ++- .../views/picking_form/stock_move_one2many.js | 29 ++--- .../picking_form/stock_move_one2many.xml | 15 +++ .../static/tests/tours/stock_picking_tour.js | 28 +++++ addons/stock/tests/__init__.py | 1 + addons/stock/tests/test_immediate.py | 6 +- addons/stock/tests/test_move2.py | 6 +- addons/stock/tests/test_packing.py | 9 +- addons/stock/tests/test_picking_tours.py | 38 ++++++ addons/stock/tests/test_report.py | 92 +++++++++------ addons/stock/tests/test_stock_flow.py | 13 ++- addons/stock/views/stock_move_views.xml | 109 +++++++++++++----- addons/stock/views/stock_picking_views.xml | 46 +++----- .../tests/test_wave_picking.py | 4 +- 27 files changed, 376 insertions(+), 210 deletions(-) create mode 100644 addons/stock/static/src/views/picking_form/stock_move_one2many.xml create mode 100644 addons/stock/static/tests/tours/stock_picking_tour.js create mode 100644 addons/stock/tests/test_picking_tours.py diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 058765a1ae1..9ce77a986dc 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -361,7 +361,7 @@ class StockMove(models.Model): if not bom: moves_ids_to_return.add(move.id) continue - if move.picking_id.immediate_transfer or float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding): + if float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding): factor = move.product_uom._compute_quantity(move.quantity_done, bom.product_uom_id) / bom.product_qty else: factor = move.product_uom._compute_quantity(move.product_uom_qty, bom.product_uom_id) / bom.product_qty diff --git a/addons/mrp/tests/test_stock.py b/addons/mrp/tests/test_stock.py index 27f6a4c0c32..5416cbf3d3e 100644 --- a/addons/mrp/tests/test_stock.py +++ b/addons/mrp/tests/test_stock.py @@ -308,7 +308,7 @@ class TestKitPicking(common.TestMrpCommon): move_receipt_1 = self.env['stock.move'].create({ 'name': self.kit_parent.name, 'product_id': self.kit_parent.id, - 'quantity_done': 3, + 'product_uom_qty': 3, 'product_uom': self.kit_parent.uom_id.id, 'picking_id': picking.id, 'picking_type_id': self.env.ref('stock.picking_type_in').id, diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index d9d73321a27..07742956a15 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -393,8 +393,6 @@ context="{'default_company_id': company_id, 'default_product_id': product_id}" domain="[('product_id','=',product_id)]"/> -