diff --git a/setup/stock_barcodes_gs1_secondary_unit/odoo/addons/stock_barcodes_gs1_secondary_unit b/setup/stock_barcodes_gs1_secondary_unit/odoo/addons/stock_barcodes_gs1_secondary_unit new file mode 120000 index 000000000000..c4a2bbb0f901 --- /dev/null +++ b/setup/stock_barcodes_gs1_secondary_unit/odoo/addons/stock_barcodes_gs1_secondary_unit @@ -0,0 +1 @@ +../../../../stock_barcodes_gs1_secondary_unit \ No newline at end of file diff --git a/setup/stock_barcodes_gs1_secondary_unit/setup.py b/setup/stock_barcodes_gs1_secondary_unit/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_barcodes_gs1_secondary_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_barcodes_gs1_secondary_unit/README.rst b/stock_barcodes_gs1_secondary_unit/README.rst new file mode 100644 index 000000000000..e1916648fbcb --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/README.rst @@ -0,0 +1,85 @@ +================================= +Stock Barcodes GS1 Secondary Unit +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:870410a97d88dbf44555fddda5bfa1a03103a1edb31a832e5ad500e00296a90c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--barcode-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-barcode/tree/15.0/stock_barcodes_gs1_secondary_unit + :alt: OCA/stock-logistics-barcode +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-barcode-15-0/stock-logistics-barcode-15-0-stock_barcodes_gs1_secondary_unit + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-barcode&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends barcode reader GS1 interface module to allow to read +package barcodes from secondary units model. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Read usage section from stock_barcodes module. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + + +* `Tecnativa `_: + + * Sergio Teruel + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/stock-logistics-barcode `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_barcodes_gs1_secondary_unit/__init__.py b/stock_barcodes_gs1_secondary_unit/__init__.py new file mode 100644 index 000000000000..2b59e6cce21c --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models +from . import wizard diff --git a/stock_barcodes_gs1_secondary_unit/__manifest__.py b/stock_barcodes_gs1_secondary_unit/__manifest__.py new file mode 100644 index 000000000000..18d24accdceb --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Barcodes GS1 Secondary Unit", + "summary": "It provides read package from GS1 barcode stored " + "into secondary unit data.", + "version": "15.0.1.0.0", + "author": "Tecnativa, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-barcode", + "license": "AGPL-3", + "category": "Extra Tools", + "depends": ["stock_barcodes_gs1", "stock_secondary_unit"], + "data": [ + "views/product_views.xml", + "wizard/stock_barcodes_read_picking_views.xml", + "wizard/stock_barcodes_read_todo_view.xml", + ], + "installable": True, + "auto_install": True, +} diff --git a/stock_barcodes_gs1_secondary_unit/i18n/es.po b/stock_barcodes_gs1_secondary_unit/i18n/es.po new file mode 100644 index 000000000000..4a7729e1171a --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/i18n/es.po @@ -0,0 +1,102 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_barcodes_gs1_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-04-27 17:43+0000\n" +"PO-Revision-Date: 2023-04-27 19:44+0200\n" +"Last-Translator: Sergio Teruel \n" +"Language-Team: \n" +"Language: es_ES\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.0.1\n" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_product_secondary_unit__barcode +msgid "Barcode" +msgstr "Código de barras" + +#. module: stock_barcodes_gs1_secondary_unit +#: code:addons/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py:0 +#, python-format +msgid "Barcode for product secondary uom not found" +msgstr "No se han encontrado unidades secundarias para este código de barras" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,help:stock_barcodes_gs1_secondary_unit.field_product_secondary_unit__barcode +msgid "International Article Number used for product identification." +msgstr "Número de artículo internacional usado para la identificación de producto." + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_stock_barcodes_read_log +msgid "Log barcode scanner" +msgstr "Registro de lecturas" + +#. module: stock_barcodes_gs1_secondary_unit +#: code:addons/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py:0 +#, python-format +msgid "More than one secondary uom found" +msgstr "Se ha encontrado más de una unidad secundaria para este código de barras" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_product_secondary_unit +msgid "Product Secondary Unit" +msgstr "Unidad Secundaria" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__product_tmpl_id +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__product_tmpl_id +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_todo__secondary_uom_id +msgid "Second unit" +msgstr "Unidad secundaria" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_todo__secondary_uom_qty +msgid "Secondary Qty" +msgstr "Cdad. secundaria" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_stock_barcodes_read_log__secondary_uom_qty +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__secondary_uom_qty +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__secondary_uom_qty +msgid "Secondary UOM Qty" +msgstr "Cta. Ud. secundaria" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__secondary_single_qty +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__secondary_single_qty +msgid "Secondary single Qty" +msgstr "Cta. Ud. secundaria" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_stock_barcodes_read_log__secondary_uom_id +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__secondary_uom_id +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__secondary_uom_id +#: model_terms:ir.ui.view,arch_db:stock_barcodes_gs1_secondary_unit.view_stock_barcodes_read_form +msgid "Secondary uom" +msgstr "Unidad Secundaria" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_wiz_stock_barcodes_read +msgid "Wizard to read barcode" +msgstr "Asistente para leer códigos de barras" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_wiz_stock_barcodes_read_picking +msgid "Wizard to read barcode on picking" +msgstr "Asistente para leer códigos de barras desde los albaranes" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_wiz_stock_barcodes_read_todo +msgid "Wizard to read barcode todo" +msgstr "Asistente para leer códigos de barras" diff --git a/stock_barcodes_gs1_secondary_unit/i18n/stock_barcodes_gs1_secondary_unit.pot b/stock_barcodes_gs1_secondary_unit/i18n/stock_barcodes_gs1_secondary_unit.pot new file mode 100644 index 000000000000..fbb73dd9cfca --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/i18n/stock_barcodes_gs1_secondary_unit.pot @@ -0,0 +1,100 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_barcodes_gs1_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-04-27 17:43+0000\n" +"PO-Revision-Date: 2023-04-27 17:43+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_product_secondary_unit__barcode +msgid "Barcode" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: code:addons/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py:0 +#, python-format +msgid "Barcode for product secondary uom not found" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,help:stock_barcodes_gs1_secondary_unit.field_product_secondary_unit__barcode +msgid "International Article Number used for product identification." +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_stock_barcodes_read_log +msgid "Log barcode scanner" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: code:addons/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py:0 +#, python-format +msgid "More than one secondary uom found" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_product_secondary_unit +msgid "Product Secondary Unit" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__product_tmpl_id +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__product_tmpl_id +msgid "Product Template" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_todo__secondary_uom_id +msgid "Second unit" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_todo__secondary_uom_qty +msgid "Secondary Qty" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_stock_barcodes_read_log__secondary_uom_qty +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__secondary_uom_qty +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__secondary_uom_qty +msgid "Secondary UOM Qty" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__secondary_single_qty +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__secondary_single_qty +msgid "Secondary single Qty" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_stock_barcodes_read_log__secondary_uom_id +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read__secondary_uom_id +#: model:ir.model.fields,field_description:stock_barcodes_gs1_secondary_unit.field_wiz_stock_barcodes_read_picking__secondary_uom_id +#: model_terms:ir.ui.view,arch_db:stock_barcodes_gs1_secondary_unit.view_stock_barcodes_read_form +msgid "Secondary uom" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_wiz_stock_barcodes_read +msgid "Wizard to read barcode" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_wiz_stock_barcodes_read_picking +msgid "Wizard to read barcode on picking" +msgstr "" + +#. module: stock_barcodes_gs1_secondary_unit +#: model:ir.model,name:stock_barcodes_gs1_secondary_unit.model_wiz_stock_barcodes_read_todo +msgid "Wizard to read barcode todo" +msgstr "" diff --git a/stock_barcodes_gs1_secondary_unit/models/__init__.py b/stock_barcodes_gs1_secondary_unit/models/__init__.py new file mode 100644 index 000000000000..85022e3674b8 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import product_second_unit +from . import stock_barcodes_read_log +from . import stock_move_line diff --git a/stock_barcodes_gs1_secondary_unit/models/product_second_unit.py b/stock_barcodes_gs1_secondary_unit/models/product_second_unit.py new file mode 100644 index 000000000000..2d425a363762 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/models/product_second_unit.py @@ -0,0 +1,13 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductSecondaryUnit(models.Model): + _inherit = "product.secondary.unit" + + barcode = fields.Char( + copy=False, + index=True, + help="International Article Number used for product identification.", + ) diff --git a/stock_barcodes_gs1_secondary_unit/models/stock_barcodes_read_log.py b/stock_barcodes_gs1_secondary_unit/models/stock_barcodes_read_log.py new file mode 100644 index 000000000000..b5d195679a08 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/models/stock_barcodes_read_log.py @@ -0,0 +1,15 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class StockBarcodesReadLog(models.Model): + _inherit = "stock.barcodes.read.log" + + secondary_uom_id = fields.Many2one( + comodel_name="product.secondary.unit", + string="Secondary uom", + ) + secondary_uom_qty = fields.Float( + string="Secondary UOM Qty", digits="Product Unit of Measure" + ) diff --git a/stock_barcodes_gs1_secondary_unit/models/stock_move_line.py b/stock_barcodes_gs1_secondary_unit/models/stock_move_line.py new file mode 100644 index 000000000000..1ddaed079285 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/models/stock_move_line.py @@ -0,0 +1,12 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + def _barcodes_process_line_to_unlink(self): + res = super()._barcodes_process_line_to_unlink() + self.secondary_uom_qty = 0.0 + return res diff --git a/stock_barcodes_gs1_secondary_unit/readme/CONTRIBUTORS.rst b/stock_barcodes_gs1_secondary_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..ea44bd934b36 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ + +* `Tecnativa `_: + + * Sergio Teruel diff --git a/stock_barcodes_gs1_secondary_unit/readme/DESCRIPTION.rst b/stock_barcodes_gs1_secondary_unit/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..cc12b48c3a48 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends barcode reader GS1 interface module to allow to read +package barcodes from secondary units model. diff --git a/stock_barcodes_gs1_secondary_unit/readme/USAGE.rst b/stock_barcodes_gs1_secondary_unit/readme/USAGE.rst new file mode 100644 index 000000000000..b0b4bac558c0 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/readme/USAGE.rst @@ -0,0 +1 @@ +Read usage section from stock_barcodes module. diff --git a/stock_barcodes_gs1_secondary_unit/static/description/icon.png b/stock_barcodes_gs1_secondary_unit/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_barcodes_gs1_secondary_unit/static/description/icon.png differ diff --git a/stock_barcodes_gs1_secondary_unit/static/description/index.html b/stock_barcodes_gs1_secondary_unit/static/description/index.html new file mode 100644 index 000000000000..591eedf16343 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +Stock Barcodes GS1 Secondary Unit + + + +
+

Stock Barcodes GS1 Secondary Unit

+ + +

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

+

This module extends barcode reader GS1 interface module to allow to read +package barcodes from secondary units model.

+

Table of contents

+ +
+

Usage

+

Read usage section from stock_barcodes module.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+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.

+

This module is part of the OCA/stock-logistics-barcode project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_barcodes_gs1_secondary_unit/tests/__init__.py b/stock_barcodes_gs1_secondary_unit/tests/__init__.py new file mode 100644 index 000000000000..506ce0b6f62b --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import test_stock_barcodes_gs1_secondary_unit diff --git a/stock_barcodes_gs1_secondary_unit/tests/test_stock_barcodes_gs1_secondary_unit.py b/stock_barcodes_gs1_secondary_unit/tests/test_stock_barcodes_gs1_secondary_unit.py new file mode 100644 index 000000000000..9041d15a6049 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/tests/test_stock_barcodes_gs1_secondary_unit.py @@ -0,0 +1,32 @@ +# Copyright 2108-2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import tagged + +from odoo.addons.stock_barcodes_gs1.tests.test_stock_barcodes_gs1 import ( + TestStockBarcodesGS1, +) + + +@tagged("post_install", "-at_install") +class TestStockBarcodesGS1SecondaryUnit(TestStockBarcodesGS1): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.secondary_unit = cls.env["product.secondary.unit"].create( + { + "product_tmpl_id": cls.product_tracking.product_tmpl_id.id, + "name": "box 8", + "uom_id": cls.product_tracking.uom_id.id, + "factor": 8.0, + "barcode": "08412598033094", + } + ) + + def test_wizard_scan_gs1_secondary_unit(self): + # Scanning barcode with package data + self.action_barcode_scanned(self.wiz_scan, "0108412598033094") + self.assertEqual(self.wiz_scan.secondary_uom_id, self.secondary_unit) + self.wiz_scan.secondary_uom_qty = 5.0 + self.wiz_scan.onchange_secondary_uom_qty() + self.assertEqual(self.wiz_scan.product_qty, 40.0) diff --git a/stock_barcodes_gs1_secondary_unit/views/product_views.xml b/stock_barcodes_gs1_secondary_unit/views/product_views.xml new file mode 100644 index 000000000000..c2a2d47e4b70 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/views/product_views.xml @@ -0,0 +1,18 @@ + + + + + product.template + + + + + + + + + diff --git a/stock_barcodes_gs1_secondary_unit/wizard/__init__.py b/stock_barcodes_gs1_secondary_unit/wizard/__init__.py new file mode 100644 index 000000000000..902ea02764fb --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/wizard/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import stock_barcodes_read +from . import stock_barcodes_read_picking +from . import stock_barcodes_read_todo diff --git a/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py new file mode 100644 index 000000000000..65041b2d3f00 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read.py @@ -0,0 +1,95 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import _, api, fields, models + + +class WizStockBarcodesRead(models.AbstractModel): + _inherit = "wiz.stock.barcodes.read" + + product_tmpl_id = fields.Many2one( + comodel_name="product.template", + related="product_id.product_tmpl_id", + ) + secondary_uom_id = fields.Many2one( + comodel_name="product.secondary.unit", + string="Secondary uom", + ) + secondary_uom_qty = fields.Float( + string="Secondary UOM Qty", digits="Product Unit of Measure" + ) + secondary_single_qty = fields.Float( + string="Secondary single Qty", digits="Product Unit of Measure" + ) + total_secondary_uom_qty = fields.Float( + string="Second. Demand", digits="Product Unit of Measure", store=False + ) + total_secondary_uom_qty_done = fields.Float( + string="Second. Done", digits="Product Unit of Measure", store=False + ) + + @api.onchange("secondary_uom_id", "secondary_uom_qty", "secondary_single_qty") + def onchange_secondary_uom_qty(self): + self.product_qty = ( + self.secondary_uom_qty * self.secondary_uom_id.factor + ) + self.secondary_single_qty + + def action_secondary_uom_scaned_post(self, secondary_uom): + self.secondary_uom_id = secondary_uom + if self.product_id != secondary_uom.product_tmpl_id.product_variant_id: + self.lot_id = False + self.product_id = secondary_uom.product_tmpl_id.product_variant_id + if self.manual_entry or self.is_manual_qty: + return + elif self.secondary_uom_id: + self.secondary_uom_qty = 1.0 + self.product_qty = self.secondary_uom_id.factor * self.secondary_uom_qty + else: + self.secondary_uom_qty = 0.0 + self.product_qty = 1.0 + + def _prepare_scan_log_values(self, log_detail=False): + vals = super()._prepare_scan_log_values(log_detail=log_detail) + vals.update( + { + "secondary_uom_id": self.secondary_uom_id.id, + "secondary_uom_qty": self.secondary_uom_qty, + } + ) + return vals + + def reset_qty(self): + res = super().reset_qty() + self.secondary_uom_qty = 0 + return res + + def _process_ai_01(self, gs1_list): + secondary_uom = self.env["product.secondary.unit"].search( + self._barcode_domain(self.barcode) + ) + if not secondary_uom: + return super()._process_ai_01(gs1_list) + else: + if len(secondary_uom) > 1: + self._set_messagge_info( + "more_match", _("More than one secondary uom found") + ) + return False + self.action_secondary_uom_scaned_post(secondary_uom) + return True + + @api.onchange("product_id") + def onchange_product_id(self): + res = super().onchange_product_id() + self.secondary_uom_id = self.product_id.stock_secondary_uom_id + return res + + def _set_focus_on_qty_input(self, field_name=None): + if field_name is None and self.secondary_uom_id: + field_name = "secondary_uom_qty" + return super()._set_focus_on_qty_input(field_name=field_name) + + def action_clean_values(self): + res = super().action_clean_values() + self.secondary_uom_qty = 0.0 + self.secondary_single_qty = 0.0 + return res diff --git a/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_picking.py b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_picking.py new file mode 100644 index 000000000000..80b55f59f41b --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_picking.py @@ -0,0 +1,53 @@ +# Copyright 2019 Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class WizStockBarcodesReadPicking(models.TransientModel): + _inherit = "wiz.stock.barcodes.read.picking" + + # Extended from stock_barcodes_read base model + total_secondary_uom_qty = fields.Float(compute="_compute_total_secondary_uom") + total_secondary_uom_qty_done = fields.Float(compute="_compute_total_secondary_uom") + + @api.depends("picking_id.move_line_ids.secondary_uom_qty") + def _compute_total_secondary_uom(self): + self.total_secondary_uom_qty = 0.0 + self.total_secondary_uom_qty_done = 0.0 + for rec in self: + product_moves = rec.picking_id.move_lines.filtered( + lambda ln: ln.product_id.ids == self.product_id.ids + and ln.state != "cancel" + ) + for sm in product_moves: + rec.total_secondary_uom_qty += sm.secondary_uom_qty + rec.total_secondary_uom_qty_done += sum( + sm.move_line_ids.mapped("secondary_uom_qty") + ) + + def _prepare_move_line_values(self, candidate_move, available_qty): + vals = super()._prepare_move_line_values(candidate_move, available_qty) + vals.update( + { + "secondary_uom_id": self.secondary_uom_id.id, + "secondary_uom_qty": self.secondary_uom_qty, + } + ) + return vals + + def _get_candidate_line_domain(self): + domain = super(WizStockBarcodesReadPicking, self)._get_candidate_line_domain() + if self.secondary_uom_id: + domain.extend( + [ + ("secondary_uom_id", "=", self.secondary_uom_id.id), + ] + ) + return domain + + def _update_stock_move_line(self, line, sml_vals): + if self.secondary_uom_id: + sml_vals["secondary_uom_qty"] = ( + line.secondary_uom_qty + self.secondary_uom_qty + ) + return super()._update_stock_move_line(line, sml_vals) diff --git a/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_picking_views.xml b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_picking_views.xml new file mode 100644 index 000000000000..2f2ba3c9a7b9 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_picking_views.xml @@ -0,0 +1,156 @@ + + + wiz.stock.barcodes.read + + + +
+
+ + +
+
+
+ +
+
+
+ +
+ + / + +
+
+
+
+ +
+
+ +
+
+
+
+ + + wiz.stock.barcodes.read.picking + + + + + + + + + + + + + +
+
+ +
+
+
+
+ + + + + + + + + + + +
+
+ +
+
+
+
+
+
+ +
diff --git a/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_todo.py b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_todo.py new file mode 100644 index 000000000000..0c9f31ec5b87 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_todo.py @@ -0,0 +1,29 @@ +# Copyright 2023 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class WizStockBarcodesReadTodo(models.TransientModel): + _inherit = ["wiz.stock.barcodes.read.todo", "product.secondary.unit.mixin"] + _name = "wiz.stock.barcodes.read.todo" + _secondary_unit_fields = { + "qty_field": "product_uom_qty", + "uom_field": "uom_id", + } + + def _prepare_fill_record_values(self, wiz_barcode, line, position): + vals = super()._prepare_fill_record_values(wiz_barcode, line, position) + vals.update({"secondary_uom_id": line.secondary_uom_id.id}) + return vals + + @api.model + def fields_to_fill_from_pending_line(self): + res = super().fields_to_fill_from_pending_line() + res.append("secondary_uom_id") + return res + + def _group_key(self, wiz, line): + key = super()._group_key(wiz, line) + key += (line.secondary_uom_id,) + return key diff --git a/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_todo_view.xml b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_todo_view.xml new file mode 100644 index 000000000000..499065053fd3 --- /dev/null +++ b/stock_barcodes_gs1_secondary_unit/wizard/stock_barcodes_read_todo_view.xml @@ -0,0 +1,22 @@ + + + + wiz.stock.barcodes.read.todo + + + + + + + + + + ( ) + + + + + +