diff --git a/setup/shopfloor_reception_product_barcode/odoo/addons/shopfloor_reception_product_barcode b/setup/shopfloor_reception_product_barcode/odoo/addons/shopfloor_reception_product_barcode new file mode 120000 index 00000000000..dbfadfa45ee --- /dev/null +++ b/setup/shopfloor_reception_product_barcode/odoo/addons/shopfloor_reception_product_barcode @@ -0,0 +1 @@ +../../../../shopfloor_reception_product_barcode \ No newline at end of file diff --git a/setup/shopfloor_reception_product_barcode/setup.py b/setup/shopfloor_reception_product_barcode/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_reception_product_barcode/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/shopfloor_reception_product_barcode_mobile/odoo/addons/shopfloor_reception_product_barcode_mobile b/setup/shopfloor_reception_product_barcode_mobile/odoo/addons/shopfloor_reception_product_barcode_mobile new file mode 120000 index 00000000000..11754c0103e --- /dev/null +++ b/setup/shopfloor_reception_product_barcode_mobile/odoo/addons/shopfloor_reception_product_barcode_mobile @@ -0,0 +1 @@ +../../../../shopfloor_reception_product_barcode_mobile \ No newline at end of file diff --git a/setup/shopfloor_reception_product_barcode_mobile/setup.py b/setup/shopfloor_reception_product_barcode_mobile/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_reception_product_barcode_mobile/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopfloor_reception_product_barcode/README.rst b/shopfloor_reception_product_barcode/README.rst new file mode 100644 index 00000000000..9a26394eef2 --- /dev/null +++ b/shopfloor_reception_product_barcode/README.rst @@ -0,0 +1,96 @@ +=================================== +Shopfloor Reception Product Barcode +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a9807c9f273dac265c97d18b5e70280442942cb5b6e019e779be93784cd4765e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fwms-lightgray.png?logo=github + :target: https://github.com/OCA/wms/tree/16.0/shopfloor_reception_product_barcode + :alt: OCA/wms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_reception_product_barcode + :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/wms&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds an option to the reception scenario. When activated, +before setting the quantity for the reception, if there is product +received with missing barcode, the user will be presented with a screen +proposing to update the barcode. + +The scanned barcode will be parsed and so, EAN will be extracted from +GS1 if ``shopfloor_gs1`` module is installed. + +|Scan Product Barcode| + +.. |Scan Product Barcode| image:: https://raw.githubusercontent.com/OCA/wms/16.0/shopfloor_reception_product_barcode/static/description/scan_product_barcode.png + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Camptocamp +* ACSONE SA/NV + +Contributors +------------ + +- Thierry Ducrest thierry.ducrest@camptocamp.com +- Denis Roussel denis.roussel@acsone.eu + +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. + +.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis + +Current `maintainer `__: + +|maintainer-rousseldenis| + +This module is part of the `OCA/wms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shopfloor_reception_product_barcode/__init__.py b/shopfloor_reception_product_barcode/__init__.py new file mode 100644 index 00000000000..d354f467795 --- /dev/null +++ b/shopfloor_reception_product_barcode/__init__.py @@ -0,0 +1,4 @@ +from .hooks import post_init_hook, uninstall_hook +from . import models +from . import services +from . import actions diff --git a/shopfloor_reception_product_barcode/__manifest__.py b/shopfloor_reception_product_barcode/__manifest__.py new file mode 100644 index 00000000000..52349cca78c --- /dev/null +++ b/shopfloor_reception_product_barcode/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": "Shopfloor Reception Product Barcode", + "summary": "Collect Product Barcode from the Reception scenario", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Inventory", + "website": "https://github.com/OCA/wms", + "author": "Camptocamp, ACSONE SA/NV, Odoo Community Association (OCA)", + "maintainers": ["rousseldenis"], + "license": "AGPL-3", + "installable": True, + "depends": [ + "shopfloor_reception", + ], + "data": ["views/shopfloor_menu.xml"], + "post_init_hook": "post_init_hook", + "uninstall_hook": "uninstall_hook", +} diff --git a/shopfloor_reception_product_barcode/actions/__init__.py b/shopfloor_reception_product_barcode/actions/__init__.py new file mode 100644 index 00000000000..51a1e70dbdf --- /dev/null +++ b/shopfloor_reception_product_barcode/actions/__init__.py @@ -0,0 +1 @@ +from . import message diff --git a/shopfloor_reception_product_barcode/actions/message.py b/shopfloor_reception_product_barcode/actions/message.py new file mode 100644 index 00000000000..c7549247cc0 --- /dev/null +++ b/shopfloor_reception_product_barcode/actions/message.py @@ -0,0 +1,23 @@ +# Copyright 2020 Camptocamp SA (http://www.camptocamp.com) +# Copyright 2023 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import logging + +from odoo import _ + +from odoo.addons.component.core import Component + +_logger = logging.getLogger(__name__) + + +class MessageAction(Component): + _inherit = "shopfloor.message.action" + + def product_barcode_updated(self, product): + return { + "message_type": "success", + "body": _( + "Product '%(product_name)s' barcode updated.", + product_name=product.name, + ), + } diff --git a/shopfloor_reception_product_barcode/hooks.py b/shopfloor_reception_product_barcode/hooks.py new file mode 100644 index 00000000000..08629163730 --- /dev/null +++ b/shopfloor_reception_product_barcode/hooks.py @@ -0,0 +1,40 @@ +# Copyright 2023 Camptocamp SA (http://www.camptocamp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import json +import logging + +from odoo import SUPERUSER_ID, api + +from odoo.addons.shopfloor_base.utils import purge_endpoints, register_new_services + +from .services.reception import Reception as Service + +_logger = logging.getLogger(__file__) + + +def post_init_hook(cr, registry): + _logger.info("Add set product barcode option on reception scenario") + env = api.Environment(cr, SUPERUSER_ID, {}) + scenario = env.ref("shopfloor_reception.scenario_reception") + options = scenario.options + options.update({"set_product_barcode": True}) + scenario.options_edit = json.dumps(options) + # The service imported is extending an existing component + # As it is a simple python import the odoo inheritance is not working + # So it needs to be fix + Service._usage = "reception" + Service._name = "shopfloor.reception" + register_new_services(env, Service) + + +def uninstall_hook(cr, registry): + _logger.info("Remove set product barcode option on reception scenario") + env = api.Environment(cr, SUPERUSER_ID, {}) + scenario = env.ref("shopfloor_reception.scenario_reception") + options = scenario.options + if "set_product_barcode" in options.keys(): + options.pop("set_product_barcode") + scenario.options_edit = json.dumps(options) + Service._usage = "reception" + purge_endpoints(env, Service._usage, endpoint="set_product_barcode") diff --git a/shopfloor_reception_product_barcode/models/__init__.py b/shopfloor_reception_product_barcode/models/__init__.py new file mode 100644 index 00000000000..8bd3d5195ca --- /dev/null +++ b/shopfloor_reception_product_barcode/models/__init__.py @@ -0,0 +1 @@ +from . import shopfloor_menu diff --git a/shopfloor_reception_product_barcode/models/shopfloor_menu.py b/shopfloor_reception_product_barcode/models/shopfloor_menu.py new file mode 100644 index 00000000000..8c5e93b0cc3 --- /dev/null +++ b/shopfloor_reception_product_barcode/models/shopfloor_menu.py @@ -0,0 +1,25 @@ +# Copyright 2023 Camptocamp SA (http://www.camptocamp.com) +# Copyright 2025 ACSONE SA/NV (https://acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class ShopfloorMenu(models.Model): + _inherit = "shopfloor.menu" + + set_product_barcode_is_possible = fields.Boolean( + compute="_compute_set_product_barcode_is_possible" + ) + set_product_barcode = fields.Boolean( + string="Set product barcode", + default=False, + help="If for the product being processed, its related " + "barcode is not set, ask to fill them up.", + ) + + @api.depends("scenario_id") + def _compute_set_product_barcode_is_possible(self): + for menu in self: + menu.set_product_barcode_is_possible = menu.scenario_id.has_option( + "set_product_barcode" + ) diff --git a/shopfloor_reception_product_barcode/readme/CONTRIBUTORS.md b/shopfloor_reception_product_barcode/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..1dfeb473ae3 --- /dev/null +++ b/shopfloor_reception_product_barcode/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Thierry Ducrest +- Denis Roussel \ No newline at end of file diff --git a/shopfloor_reception_product_barcode/readme/DESCRIPTION.md b/shopfloor_reception_product_barcode/readme/DESCRIPTION.md new file mode 100644 index 00000000000..498fb9ab1a4 --- /dev/null +++ b/shopfloor_reception_product_barcode/readme/DESCRIPTION.md @@ -0,0 +1,8 @@ +This module adds an option to the reception scenario. +When activated, before setting the quantity for the reception, if there is product received with +missing barcode, the user will be presented with a screen proposing to update the barcode. + +The scanned barcode will be parsed and so, EAN will be extracted from GS1 if `shopfloor_gs1` +module is installed. + +![Scan Product Barcode](../static/description/scan_product_barcode.png) \ No newline at end of file diff --git a/shopfloor_reception_product_barcode/services/__init__.py b/shopfloor_reception_product_barcode/services/__init__.py new file mode 100644 index 00000000000..aa19bba8ce4 --- /dev/null +++ b/shopfloor_reception_product_barcode/services/__init__.py @@ -0,0 +1 @@ +from . import reception diff --git a/shopfloor_reception_product_barcode/services/reception.py b/shopfloor_reception_product_barcode/services/reception.py new file mode 100644 index 00000000000..1bb4cdf8e1a --- /dev/null +++ b/shopfloor_reception_product_barcode/services/reception.py @@ -0,0 +1,176 @@ +# Copyright 2023 Camptocamp SA +# Copyright 2025 ACSONE SA/NV (https://acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo.osv import expression + +from odoo.addons.base_rest.components.service import to_int +from odoo.addons.component.core import Component +from odoo.addons.product.models.product_product import ProductProduct + + +class Reception(Component): + _inherit = "shopfloor.reception" + + product_barcode_update_done = False + + def _before_state__set_quantity(self, picking, line, message=None): + """ + Check if product needs its barcode before + """ + if self.work.menu.set_product_barcode and not self.product_barcode_update_done: + product = self._get_product_to_set_barcode(line.product_id) + if product: + return self._response_for_set_product_barcode( + picking, line, message=message + ) + return super()._before_state__set_quantity(picking, line, message=message) + + def _get_domain_product_needs_barcode(self): + """ + Returns the domain to filter product that should be + selected for barcode assignation. + """ + return expression.OR( + [ + [("barcode", "=", "")], + [("barcode", "=", False)], + ] + ) + + def _get_product_to_set_barcode(self, product) -> ProductProduct: + """ + Filter the selected product to check if barcode + should be set. + """ + domain_dimension = self._get_domain_product_needs_barcode() + return product.filtered_domain(domain_dimension) + + def _response_for_set_product_barcode(self, picking, line, message=None) -> dict: + return self._response( + next_state="set_product_barcode", + data={ + "picking": self.data.picking(picking), + "selected_move_line": self.data.move_line(line), + "product": self.data_detail.product_detail(line.product_id), + "product_barcode": line.product_id.barcode or "", + }, + message=message, + ) + + def set_product_barcode_scan(self, picking_id, selected_line_id, barcode) -> dict: + """ + This will parse the scanned barcode and return the result + """ + search = self._actions_for("search") + result = search.parser.parse(barcode, ["product"]) + result_value = result[0].value if result else "" + picking = self.env["stock.picking"].browse(picking_id) + selected_line = self.env["stock.move.line"].browse(selected_line_id) + return self._response( + next_state="set_product_barcode", + data={ + "picking": self.data.picking(picking), + "selected_move_line": self.data.move_line(selected_line), + "product": self.data_detail.product_detail(selected_line.product_id), + "product_barcode": result_value, + }, + ) + + def set_product_barcode( + self, + picking_id, + selected_line_id, + barcode, + cancel=False, + ) -> dict: + """ + Set the barcode on a product if not already set. + """ + picking = self.env["stock.picking"].browse(picking_id) + selected_line = self.env["stock.move.line"].browse(selected_line_id) + product = self._get_product_to_set_barcode(selected_line.product_id) + message = None + if product and not cancel: + self._update_product_barcode(product, barcode) + message = self.msg_store.product_barcode_updated(product) + self.product_barcode_update_done = True + return super()._before_state__set_quantity( + picking, selected_line, message=message + ) + + def _update_product_barcode(self, product, barcode) -> None: + """Update barcode on the product.""" + product_sudo = product.sudo() + product_sudo.barcode = barcode + + +class ShopfloorReceptionValidator(Component): + _inherit = "shopfloor.reception.validator" + + def set_product_barcode(self) -> dict: + return { + "picking_id": {"coerce": to_int, "required": True, "type": "integer"}, + "selected_line_id": { + "coerce": to_int, + "required": True, + "type": "integer", + }, + "barcode": { + "required": True, + "type": "string", + "nullable": True, + }, + "cancel": {"type": "boolean"}, + } + + def set_product_barcode_scan(self) -> dict: + return { + "picking_id": {"coerce": to_int, "required": True, "type": "integer"}, + "selected_line_id": { + "coerce": to_int, + "required": True, + "type": "integer", + }, + "barcode": { + "required": True, + "type": "string", + "nullable": True, + }, + } + + +class ShopfloorReceptionValidatorResponse(Component): + _inherit = "shopfloor.reception.validator.response" + + def _states(self) -> dict: + res = super()._states() + res.update( + { + "set_product_barcode": self._schema_set_product_barcode, + "set_product_barcode_scan": self._schema_set_product_barcode_scan, + } + ) + return res + + def _scan_line_next_states(self) -> dict: + res = super()._scan_line_next_states() + res.update({"set_product_barcode"}) + return res + + def _set_lot_confirm_action_next_states(self) -> dict: + res = super()._set_lot_confirm_action_next_states() + res.update({"set_product_barcode"}) + return res + + @property + def _schema_set_product_barcode(self) -> dict: + return { + "picking": {"type": "dict", "schema": self.schemas.picking()}, + "selected_move_line": {"type": "dict", "schema": self.schemas.move_line()}, + "product": {"type": "dict", "schema": self.schemas_detail.product_detail()}, + "product_barcode": {"type": "string", "required": False, "nullable": True}, + } + + @property + def _schema_set_product_barcode_scan(self) -> dict: + return self._schema_set_product_barcode diff --git a/shopfloor_reception_product_barcode/static/description/icon.png b/shopfloor_reception_product_barcode/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/shopfloor_reception_product_barcode/static/description/icon.png differ diff --git a/shopfloor_reception_product_barcode/static/description/index.html b/shopfloor_reception_product_barcode/static/description/index.html new file mode 100644 index 00000000000..ff828187475 --- /dev/null +++ b/shopfloor_reception_product_barcode/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +Shopfloor Reception Product Barcode + + + +
+

Shopfloor Reception Product Barcode

+ + +

Beta License: AGPL-3 OCA/wms Translate me on Weblate Try me on Runboat

+

This module adds an option to the reception scenario. When activated, +before setting the quantity for the reception, if there is product +received with missing barcode, the user will be presented with a screen +proposing to update the barcode.

+

The scanned barcode will be parsed and so, EAN will be extracted from +GS1 if shopfloor_gs1 module is installed.

+

Scan Product Barcode

+

Table of contents

+ +
+

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

+
    +
  • Camptocamp
  • +
  • ACSONE SA/NV
  • +
+
+ +
+

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.

+

Current maintainer:

+

rousseldenis

+

This module is part of the OCA/wms project on GitHub.

+

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

+
+
+
+ + diff --git a/shopfloor_reception_product_barcode/static/description/scan_product_barcode.png b/shopfloor_reception_product_barcode/static/description/scan_product_barcode.png new file mode 100644 index 00000000000..182819d3637 Binary files /dev/null and b/shopfloor_reception_product_barcode/static/description/scan_product_barcode.png differ diff --git a/shopfloor_reception_product_barcode/tests/__init__.py b/shopfloor_reception_product_barcode/tests/__init__.py new file mode 100644 index 00000000000..6137cb6c941 --- /dev/null +++ b/shopfloor_reception_product_barcode/tests/__init__.py @@ -0,0 +1 @@ +from . import test_set_product_barcode diff --git a/shopfloor_reception_product_barcode/tests/test_set_product_barcode.py b/shopfloor_reception_product_barcode/tests/test_set_product_barcode.py new file mode 100644 index 00000000000..9cbde1ee11b --- /dev/null +++ b/shopfloor_reception_product_barcode/tests/test_set_product_barcode.py @@ -0,0 +1,191 @@ +# Copyright 2023 Camptocamp SA +# Copyright 2025 ACSONE SA/NV (https://acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo.addons.shopfloor_reception.tests.common import CommonCase + +from ..hooks import post_init_hook, uninstall_hook + + +class TestSetProductDimension(CommonCase): + @classmethod + def setUpClassBaseData(cls): + res = super().setUpClassBaseData() + # Activate the option to use the module + cls.menu.sudo().set_product_barcode = True + cls.picking = cls._create_picking( + lines=[(cls.product_a, 10), (cls.product_b, 10), (cls.product_c, 10)] + ) + return res + + def _assert_response_set_barcode( + self, response, picking, line, barcode, message=None + ): + data = { + "picking": self.data.picking(picking), + "selected_move_line": self.data.move_line(line), + "product": self.data_detail.product_detail(line.product_id), + "product_barcode": barcode, + } + self.assert_response( + response, + next_state="set_product_barcode", + data=data, + message=message, + ) + + def _assert_response_updated_set_quantity( + self, response, picking, line, message=None + ): + data = { + "picking": self.data.picking(picking), + "selected_move_line": [self.data.move_line(line)], + "confirmation_required": None, + } + self.assert_response( + response, + next_state="set_quantity", + data=data, + message=message, + ) + + def test_hooks(self): + post_init_hook(self.env.cr, self.env.registry) + scenario = self.env.ref("shopfloor_reception.scenario_reception") + self.assertTrue(scenario.options.get("set_product_barcode")) + + self.assertTrue(self.menu.set_product_barcode_is_possible) + + uninstall_hook(self.env.cr, self.env.registry) + self.assertNotIn( + "set_product_barcode", + scenario.options, + ) + + def test_scan_product_ask_for_barcode(self): + """ + Check we ask for a barcode if product's one is empty + + We check also the barcode scan + """ + self.product_a.barcode = "" + response = self.service.dispatch( + "scan_line", + params={ + "picking_id": self.picking.id, + "barcode": self.product_a.default_code, + }, + ) + self.data.picking(self.picking) + selected_move_line = self.picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + self._assert_response_set_barcode( + response, self.picking, selected_move_line, "" + ) + + # Check the response for barcode scan + response = self.service.dispatch( + "set_product_barcode_scan", + params={ + "picking_id": self.picking.id, + "selected_line_id": selected_move_line.id, + "barcode": "0799439112766", + }, + ) + self._assert_response_set_barcode( + response, self.picking, selected_move_line, "0799439112766" + ) + + def test_scan_product_dont_ask_for_barcode(self): + """ + Product has already a barcode, don't ask + """ + self.product_a.tracking = "none" + # self._add_package(self.picking) + self.assertTrue(self.product_a.packaging_ids) + response = self.service.dispatch( + "scan_line", + params={ + "picking_id": self.picking.id, + "barcode": self.product_a.barcode, + }, + ) + self.data.picking(self.picking) + selected_move_line = self.picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + self._assert_response_updated_set_quantity( + response, self.picking, selected_move_line + ) + + def test_scan_lot_ask_for_barcode(self): + self.product_a.tracking = "none" + self.product_a.barcode = "" + selected_move_line = self.picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + response = self.service.dispatch( + "set_lot_confirm_action", + params={ + "picking_id": self.picking.id, + "selected_line_id": selected_move_line.id, + }, + ) + self.data.picking(self.picking) + selected_move_line = self.picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + self._assert_response_set_barcode( + response, self.picking, selected_move_line, "" + ) + + def test_set_product_barcode(self): + self.product_a.barcode = "" + selected_move_line = self.picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + self.service.dispatch( + "set_product_barcode", + params={ + "picking_id": self.picking.id, + "selected_line_id": selected_move_line.id, + "barcode": "0799439112766", + }, + ) + self.assertEqual(self.product_a.barcode, "0799439112766") + + def test_set_multiple_product_barcode(self): + line = self.picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_c + ) + self.product_c.barcode = "" + response = self.service.dispatch( + "set_product_barcode", + params={ + "picking_id": self.picking.id, + "selected_line_id": line.id, + "barcode": "0000000000", + }, + ) + self.assertEqual(self.product_c.barcode, "0000000000") + self._assert_response_updated_set_quantity( + response, + self.picking, + line, + message=self.msg_store.product_barcode_updated(self.product_c), + ) + + response = self.service.dispatch( + "set_product_barcode", + params={ + "picking_id": self.picking.id, + "selected_line_id": line.id, + "barcode": "00000000112", + }, + ) + self.assertEqual(self.product_c.barcode, "0000000000") + self._assert_response_updated_set_quantity( + response, + self.picking, + line, + ) diff --git a/shopfloor_reception_product_barcode/views/shopfloor_menu.xml b/shopfloor_reception_product_barcode/views/shopfloor_menu.xml new file mode 100644 index 00000000000..ebf9043022d --- /dev/null +++ b/shopfloor_reception_product_barcode/views/shopfloor_menu.xml @@ -0,0 +1,22 @@ + + + + + shopfloor.menu + + + + + + + + + + + + + diff --git a/shopfloor_reception_product_barcode_mobile/README.rst b/shopfloor_reception_product_barcode_mobile/README.rst new file mode 100644 index 00000000000..a8d827ad807 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/README.rst @@ -0,0 +1,92 @@ +========================================== +Shopfloor Reception Product Barcode Mobile +========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0a022165b9c574559c392b7d2b419b9c0373bc82fc777cc497f937a75738af1a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fwms-lightgray.png?logo=github + :target: https://github.com/OCA/wms/tree/16.0/shopfloor_reception_product_barcode_mobile + :alt: OCA/wms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_reception_product_barcode_mobile + :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/wms&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the front end part for the +``shopfloor_reception_product_barcode`` module. Allowing to set barcode +on the product being processed, if they are not set already. The option +needs to be enable on the shopfloor menu. + +|Scan Product Barcode| + +.. |Scan Product Barcode| image:: https://raw.githubusercontent.com/OCA/wms/16.0/shopfloor_reception_product_barcode_mobile/static/description/scan_product_barcode.png + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Camptocamp + +Contributors +------------ + +- Thierry Ducrest thierry.ducrest@camptocamp.com +- Denis Roussel denis.roussel@acsone.eu + +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. + +.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis + +Current `maintainer `__: + +|maintainer-rousseldenis| + +This module is part of the `OCA/wms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shopfloor_reception_product_barcode_mobile/__init__.py b/shopfloor_reception_product_barcode_mobile/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/shopfloor_reception_product_barcode_mobile/__manifest__.py b/shopfloor_reception_product_barcode_mobile/__manifest__.py new file mode 100644 index 00000000000..6076a927c63 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2023 Camptocamp SA +# Copyright 2025 ACSONE SA/NV (https://acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +{ + "name": "Shopfloor Reception Product Barcode Mobile", + "summary": "Frontend for the product barcode on reception scenario", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Inventory", + "website": "https://github.com/OCA/wms", + "author": "Camptocamp, Odoo Community Association (OCA)", + "maintainers": ["rousseldenis"], + "license": "AGPL-3", + "depends": [ + "shopfloor_reception_mobile", + "shopfloor_reception_product_barcode", + ], + "data": ["templates/assets.xml"], +} diff --git a/shopfloor_reception_product_barcode_mobile/readme/CONTRIBUTORS.md b/shopfloor_reception_product_barcode_mobile/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..1dfeb473ae3 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Thierry Ducrest +- Denis Roussel \ No newline at end of file diff --git a/shopfloor_reception_product_barcode_mobile/readme/DESCRIPTION.md b/shopfloor_reception_product_barcode_mobile/readme/DESCRIPTION.md new file mode 100644 index 00000000000..67b74c1cf84 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +This module adds the front end part for the `shopfloor_reception_product_barcode` +module. Allowing to set barcode on the product being processed, +if they are not set already. +The option needs to be enable on the shopfloor menu. + +![Scan Product Barcode](../static/description/scan_product_barcode.png) diff --git a/shopfloor_reception_product_barcode_mobile/static/description/icon.png b/shopfloor_reception_product_barcode_mobile/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/shopfloor_reception_product_barcode_mobile/static/description/icon.png differ diff --git a/shopfloor_reception_product_barcode_mobile/static/description/index.html b/shopfloor_reception_product_barcode_mobile/static/description/index.html new file mode 100644 index 00000000000..6dbf1aaf000 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +Shopfloor Reception Product Barcode Mobile + + + +
+

Shopfloor Reception Product Barcode Mobile

+ + +

Beta License: AGPL-3 OCA/wms Translate me on Weblate Try me on Runboat

+

This module adds the front end part for the +shopfloor_reception_product_barcode module. Allowing to set barcode +on the product being processed, if they are not set already. The option +needs to be enable on the shopfloor menu.

+

Scan Product Barcode

+

Table of contents

+ +
+

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

+
    +
  • Camptocamp
  • +
+
+ +
+

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.

+

Current maintainer:

+

rousseldenis

+

This module is part of the OCA/wms project on GitHub.

+

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

+
+
+
+ + diff --git a/shopfloor_reception_product_barcode_mobile/static/description/scan_product_barcode.png b/shopfloor_reception_product_barcode_mobile/static/description/scan_product_barcode.png new file mode 100644 index 00000000000..182819d3637 Binary files /dev/null and b/shopfloor_reception_product_barcode_mobile/static/description/scan_product_barcode.png differ diff --git a/shopfloor_reception_product_barcode_mobile/static/src/scenario/reception_product_barcode.js b/shopfloor_reception_product_barcode_mobile/static/src/scenario/reception_product_barcode.js new file mode 100644 index 00000000000..18764875a54 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/static/src/scenario/reception_product_barcode.js @@ -0,0 +1,116 @@ +/** + * Copyright 2023 Camptocamp SA (http://www.camptocamp.com) + * Copyright 2025 ACSONE SA/NV (https://acsone.eu) + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + */ + +import {process_registry} from "/shopfloor_mobile_base/static/wms/src/services/process_registry.js"; + +const reception_scenario = process_registry.get("reception"); +const _get_states = reception_scenario.component.methods._get_states; +// Get the original template of the reception scenario +const template = reception_scenario.component.template; +// And inject the new state template (for this module) into it +const pos = template.indexOf(""); +const new_template = + template.substring(0, pos) + + ` +
+ + + + + + + + + + + + + +
+ + + Done + + + + + Skip + + +
+
+ +` + + template.substring(pos); + +// Extend the reception scenario with : +// - the new patched template +// - the js code for the new state +const ReceptionProductBarcode = process_registry.extend("reception", { + template: new_template, + "methods._get_states": function () { + let states = _get_states.bind(this)(); + states["set_product_barcode"] = { + display_info: { + title: "Set product barcode", + scan_placeholder: "Scan product barcode", + }, + events: { + go_back: "on_back", + }, + on_scan: (barcode) => { + this.wait_call( + this.odoo + .call("set_product_barcode_scan", { + barcode: barcode.text, + picking_id: this.state.data.picking.id, + selected_line_id: this.state.data.selected_move_line.id, + }) + .then((res) => { + this.state_set_data({ + product_barcode: + res.data.set_product_barcode.product_barcode, + }); + return res; + }) + ); + }, + get_payload_set_product_barcode: () => { + let values = { + picking_id: this.state.data.picking.id, + selected_line_id: this.state.data.selected_move_line.id, + product: this.state.data.product.id, + }; + values["barcode"] = this.state.data.product_barcode; + return values; + }, + on_skip: () => { + const payload = this.state.get_payload_set_product_barcode(); + payload["cancel"] = true; + this.wait_call(this.odoo.call("set_product_barcode", payload)); + }, + on_done: () => { + const payload = this.state.get_payload_set_product_barcode(); + this.wait_call(this.odoo.call("set_product_barcode", payload)); + }, + }; + return states; + }, +}); + +process_registry.replace("reception", ReceptionProductBarcode); diff --git a/shopfloor_reception_product_barcode_mobile/templates/assets.xml b/shopfloor_reception_product_barcode_mobile/templates/assets.xml new file mode 100644 index 00000000000..6f95c989f34 --- /dev/null +++ b/shopfloor_reception_product_barcode_mobile/templates/assets.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt index 689482e20df..68826ea51d4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,5 @@ vcrpy-unittest odoo_test_helper + +odoo-addon-shopfloor @ git+https://github.com/OCA/wms@refs/pull/1001/head#subdirectory=setup/shopfloor +odoo-addon-shopfloor-reception @ git+https://github.com/OCA/wms@refs/pull/1002/head#subdirectory=setup/shopfloor_reception