From 38288280b173ffc2487758a85edad3bb74959442 Mon Sep 17 00:00:00 2001 From: Francois Poizat Date: Fri, 26 Apr 2024 17:41:56 +0200 Subject: [PATCH] [MIG] stock_barcodes: more migrating --- stock_barcodes/README.rst | 2 +- stock_barcodes/__manifest__.py | 9 +- stock_barcodes/data/stock_barcodes_option.xml | 2 +- .../models/stock_barcodes_option.py | 18 +- stock_barcodes/models/stock_move_line.py | 2 +- stock_barcodes/models/stock_picking_type.py | 2 +- stock_barcodes/static/description/index.html | 13 +- .../static/src/model/basic_model.esm.js | 16 ++ .../views/stock_barcodes_option_view.xml | 4 + stock_barcodes/views/stock_picking_views.xml | 2 + stock_barcodes/wizard/stock_barcodes_read.py | 14 +- .../wizard/stock_barcodes_read_picking.py | 21 +- .../stock_barcodes_read_picking_views.xml | 228 ++++++++++-------- .../wizard/stock_barcodes_read_todo.py | 6 +- 14 files changed, 207 insertions(+), 132 deletions(-) create mode 100644 stock_barcodes/static/src/model/basic_model.esm.js diff --git a/stock_barcodes/README.rst b/stock_barcodes/README.rst index dd43f46374ca..d2a5b012ffda 100644 --- a/stock_barcodes/README.rst +++ b/stock_barcodes/README.rst @@ -7,7 +7,7 @@ Stock Barcodes !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:9d6c1f593b8fd9742b10d5eb279604dc97496ef1505c5673b29182fba1846342 + !! source digest: sha256:a37c70e8ee5fdc272f67d2b22656d3ba8338a556c2997169a90f3c6fd0afde36 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/stock_barcodes/__manifest__.py b/stock_barcodes/__manifest__.py index 72f813effd2a..4657751c747e 100644 --- a/stock_barcodes/__manifest__.py +++ b/stock_barcodes/__manifest__.py @@ -27,14 +27,7 @@ ], "assets": { "web.assets_backend": [ - "/stock_barcodes/static/src/utils/barcodes_models_utils.esm.js", - "/stock_barcodes/static/src/views/kanban_renderer.esm.js", - "/stock_barcodes/static/src/views/views.esm.js", - "/stock_barcodes/static/src/views/form_view.esm.js", - "/stock_barcodes/static/src/views/view_compiler.esm.js", - "/stock_barcodes/static/src/widgets/boolean_toggle.esm.js", - "/stock_barcodes/static/src/widgets/numeric_step.esm.js", - "/stock_barcodes/static/src/widgets/view_button.esm.js", + "stock_barcodes/static/src/**/*.js", "/stock_barcodes/static/src/widgets/view_button.xml", "/stock_barcodes/static/src/css/stock.scss", ], diff --git a/stock_barcodes/data/stock_barcodes_option.xml b/stock_barcodes/data/stock_barcodes_option.xml index 47e3144711be..bb9245ea55ee 100644 --- a/stock_barcodes/data/stock_barcodes_option.xml +++ b/stock_barcodes/data/stock_barcodes_option.xml @@ -11,7 +11,7 @@ guided True True - move_lines + move_ids True Stock Barcodes !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:9d6c1f593b8fd9742b10d5eb279604dc97496ef1505c5673b29182fba1846342 +!! source digest: sha256:a37c70e8ee5fdc272f67d2b22656d3ba8338a556c2997169a90f3c6fd0afde36 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/stock-logistics-barcode Translate me on Weblate Try me on Runboat

This module provides a barcode reader interface for stock module.

@@ -557,7 +558,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/stock_barcodes/static/src/model/basic_model.esm.js b/stock_barcodes/static/src/model/basic_model.esm.js new file mode 100644 index 000000000000..d23ce6dff787 --- /dev/null +++ b/stock_barcodes/static/src/model/basic_model.esm.js @@ -0,0 +1,16 @@ +odoo.define("stock_barcodes.BasicModel", function (require) { + var BasicModel = require("web.BasicModel"); + + BasicModel.include({ + _readMissingFields: function (list, resIDs, fieldNames) { + // This allows for "static list" (x2many fields) to always update there + // fields + if (list.getContext().always_reload) { + for (const key in list._cache) { + delete list._cache[key]; + } + } + return this._super.apply(this, [list, resIDs, fieldNames]); + }, + }); +}); diff --git a/stock_barcodes/views/stock_barcodes_option_view.xml b/stock_barcodes/views/stock_barcodes_option_view.xml index ff26fe0bf402..55167de463d2 100644 --- a/stock_barcodes/views/stock_barcodes_option_view.xml +++ b/stock_barcodes/views/stock_barcodes_option_view.xml @@ -34,6 +34,8 @@ + + @@ -47,6 +49,8 @@ + + diff --git a/stock_barcodes/views/stock_picking_views.xml b/stock_barcodes/views/stock_picking_views.xml index ef54efbf3bc0..a31d4793d110 100644 --- a/stock_barcodes/views/stock_picking_views.xml +++ b/stock_barcodes/views/stock_picking_views.xml @@ -46,9 +46,11 @@ +
-
-
-
- Lot: +
+
+
- +
- Package: + Lot:
- + +
+ Package: +
+
+
- -
- - - - + + + + + + @@ -396,6 +398,18 @@ current
+ + wiz.stock.barcodes.read.picking + Barcodes Read + form + {"control_panel_hidden": True, "scanning_picking_type": True, + "form_view_initial_mode": "edit"} + + + current + wiz.stock.barcodes.read.picking Barcodes menu diff --git a/stock_barcodes/wizard/stock_barcodes_read_todo.py b/stock_barcodes/wizard/stock_barcodes_read_todo.py index 7a6d87e7e41f..a81553824238 100644 --- a/stock_barcodes/wizard/stock_barcodes_read_todo.py +++ b/stock_barcodes/wizard/stock_barcodes_read_todo.py @@ -83,7 +83,6 @@ def _get_all_products_quantities_in_package(self, package): def _prepare_fill_record_values(self, wiz_barcode, line, position): vals = { "product_id": line.product_id.id, - "product_uom_qty": line.product_uom_qty, "name": "To do action", "position_index": position, "picking_code": line.picking_code, @@ -94,6 +93,7 @@ def _prepare_fill_record_values(self, wiz_barcode, line, position): ) vals.update( { + "product_uom_qty": line.move_id.product_uom_qty, "location_id": line.location_id.id, "location_dest_id": line.location_dest_id.id, "lot_id": line.lot_id.id, @@ -111,6 +111,7 @@ def _prepare_fill_record_values(self, wiz_barcode, line, position): else: vals.update( { + "product_uom_qty": line.move_id.product_uom_qty, "location_id": (line.move_line_ids[:1] or line).location_id.id, "location_dest_id": ( line.move_line_ids[:1] or line @@ -126,12 +127,13 @@ def _prepare_fill_record_values(self, wiz_barcode, line, position): return vals def _update_fill_record_values(self, wiz_barcode, line, vals): - vals["product_uom_qty"] += line.product_uom_qty if wiz_barcode.option_group_id.source_pending_moves == "move_line_ids": + vals["product_uom_qty"] += line.reserved_qty vals["product_qty_reserved"] += line.reserved_qty vals["line_ids"][0][2].append(line.id) vals["stock_move_ids"][0][2].append(line.move_id.id) else: + vals["product_uom_qty"] += line.product_uom_qty vals["product_qty_reserved"] += ( line.move_line_ids and sum(line.move_line_ids.mapped("product_qty"))