diff --git a/setup/shopfloor_reception_packaging_dimension/odoo/addons/shopfloor_reception_packaging_dimension b/setup/shopfloor_reception_packaging_dimension/odoo/addons/shopfloor_reception_packaging_dimension new file mode 120000 index 00000000000..9ff2c52e7ae --- /dev/null +++ b/setup/shopfloor_reception_packaging_dimension/odoo/addons/shopfloor_reception_packaging_dimension @@ -0,0 +1 @@ +../../../../shopfloor_reception_packaging_dimension \ No newline at end of file diff --git a/setup/shopfloor_reception_packaging_dimension/setup.py b/setup/shopfloor_reception_packaging_dimension/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_reception_packaging_dimension/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/shopfloor_reception_packaging_dimension_mobile/odoo/addons/shopfloor_reception_packaging_dimension_mobile b/setup/shopfloor_reception_packaging_dimension_mobile/odoo/addons/shopfloor_reception_packaging_dimension_mobile new file mode 120000 index 00000000000..a9ab8c21f8f --- /dev/null +++ b/setup/shopfloor_reception_packaging_dimension_mobile/odoo/addons/shopfloor_reception_packaging_dimension_mobile @@ -0,0 +1 @@ +../../../../shopfloor_reception_packaging_dimension_mobile \ No newline at end of file diff --git a/setup/shopfloor_reception_packaging_dimension_mobile/setup.py b/setup/shopfloor_reception_packaging_dimension_mobile/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_reception_packaging_dimension_mobile/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopfloor/actions/message.py b/shopfloor/actions/message.py index e8962bf19bc..5835e401d86 100644 --- a/shopfloor/actions/message.py +++ b/shopfloor/actions/message.py @@ -526,12 +526,6 @@ def packaging_not_found_in_picking(self): "body": _("Packaging not found in the current transfer."), } - def packaging_dimension_updated(self, packaging): - return { - "message_type": "success", - "body": _("Packaging {} dimension updated.").format(packaging.name), - } - def expiration_date_missing(self): return { "message_type": "error", diff --git a/shopfloor_reception_packaging_dimension/README.rst b/shopfloor_reception_packaging_dimension/README.rst new file mode 100644 index 00000000000..fe2cb72b8c3 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/README.rst @@ -0,0 +1,93 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +======================================= +Shopfloor Reception Packaging Dimension +======================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9eeb40e76db899eedaf247b7f44f8ccb3222db15482d93d6f80b64e27fdfd2a6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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_packaging_dimension + :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_packaging_dimension + :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 +packaging related to the product received with missing information, the +user will be presented with a screen (for each packaging) proposing to +update the missing information. + +**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 +- Denis Roussel + +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-TDu| image:: https://github.com/TDu.png?size=40px + :target: https://github.com/TDu + :alt: TDu + +Current `maintainer `__: + +|maintainer-TDu| + +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_packaging_dimension/__init__.py b/shopfloor_reception_packaging_dimension/__init__.py new file mode 100644 index 00000000000..d354f467795 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/__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_packaging_dimension/__manifest__.py b/shopfloor_reception_packaging_dimension/__manifest__.py new file mode 100644 index 00000000000..ea28dc77e86 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +{ + "name": "Shopfloor Reception Packaging Dimension", + "summary": "Collect Packaging Dimension from the 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": ["TDu"], + "license": "AGPL-3", + "installable": True, + "depends": ["shopfloor_reception", "product_packaging_level"], + "data": [ + "views/product_packaging_level.xml", + "views/shopfloor_menu.xml", + ], + "post_init_hook": "post_init_hook", + "uninstall_hook": "uninstall_hook", +} diff --git a/shopfloor_reception_packaging_dimension/actions/__init__.py b/shopfloor_reception_packaging_dimension/actions/__init__.py new file mode 100644 index 00000000000..7bb61dcadf7 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/actions/__init__.py @@ -0,0 +1,3 @@ +from . import data +from . import schema +from . import message diff --git a/shopfloor_reception_packaging_dimension/actions/data.py b/shopfloor_reception_packaging_dimension/actions/data.py new file mode 100644 index 00000000000..d79286dae93 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/actions/data.py @@ -0,0 +1,25 @@ +from odoo.addons.component.core import Component +from odoo.addons.shopfloor_base.utils import ensure_model + + +class DataAction(Component): + _inherit = "shopfloor.data.action" + + @property + def _packaging_dimension_detail_parser(self): + return [ + "id", + "name", + "qty", + "packaging_length", + "width", + "height", + "weight", + "length_uom_name", + "weight_uom_name", + "barcode", + ] + + @ensure_model("product.packaging") + def packaging_dimensions(self, record, **kw): + return self._jsonify(record, self._packaging_dimension_detail_parser, **kw) diff --git a/shopfloor_reception_packaging_dimension/actions/message.py b/shopfloor_reception_packaging_dimension/actions/message.py new file mode 100644 index 00000000000..c15e458fda6 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/actions/message.py @@ -0,0 +1,17 @@ +import logging + +from odoo import _ + +from odoo.addons.component.core import Component + +_logger = logging.getLogger(__name__) + + +class MessageAction(Component): + _inherit = "shopfloor.message.action" + + def packaging_updated(self, packaging): + return { + "message_type": "success", + "body": _("Packaging '{}' updated.").format(packaging.name), + } diff --git a/shopfloor_reception_packaging_dimension/actions/schema.py b/shopfloor_reception_packaging_dimension/actions/schema.py new file mode 100644 index 00000000000..e982635203e --- /dev/null +++ b/shopfloor_reception_packaging_dimension/actions/schema.py @@ -0,0 +1,27 @@ +from odoo.addons.component.core import Component + + +class ShopfloorSchemaAction(Component): + _inherit = "shopfloor.schema.action" + + def packaging_dimensions(self): + return { + "id": {"required": True, "type": "integer"}, + "name": {"type": "string", "nullable": False, "required": True}, + "qty": {"type": "float", "required": True}, + "packaging_length": {"type": "float", "nullable": True, "required": False}, + "width": {"type": "float", "nullable": True, "required": False}, + "height": {"type": "float", "nullable": True, "required": False}, + "weight": {"type": "float", "nullable": True, "required": False}, + "length_uom_name": { + "type": "string", + "nullable": True, + "required": False, + }, + "weight_uom_name": { + "type": "string", + "nullable": True, + "required": False, + }, + "barcode": {"type": "string", "nullable": True, "required": False}, + } diff --git a/shopfloor_reception_packaging_dimension/hooks.py b/shopfloor_reception_packaging_dimension/hooks.py new file mode 100644 index 00000000000..763dee221f3 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/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): + env = api.Environment(cr, SUPERUSER_ID, {}) + _logger.info("Add set packaging dimension option on reception scenario") + scenario = env.ref("shopfloor_reception.scenario_reception") + options = scenario.options + options.update({"set_packaging_dimension": 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): + env = api.Environment(cr, SUPERUSER_ID, {}) + _logger.info("Remove set packaging dimension option on reception scenario") + scenario = env.ref("shopfloor_reception.scenario_reception") + options = scenario.options + if "set_packaging_dimension" in options.keys(): + options.pop("set_packaging_dimension") + scenario.options_edit = json.dumps(options) + Service._usage = "reception" + purge_endpoints(env, Service._usage, endpoint="set_packaging_dimension") diff --git a/shopfloor_reception_packaging_dimension/i18n/it.po b/shopfloor_reception_packaging_dimension/i18n/it.po new file mode 100644 index 00000000000..2ba3659a928 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/i18n/it.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * shopfloor_reception_packaging_dimension +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-09-01 09:42+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_height +msgid "Collect height" +msgstr "Raccogli altezza" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_length +msgid "Collect length" +msgstr "Raccogli lunghezza" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_weight +msgid "Collect weight" +msgstr "Raccogli peso" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_width +msgid "Collect width" +msgstr "Raccogli larghezza" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_shopfloor_menu__set_packaging_dimension +msgid "" +"If for the product being processed, its related packaging dimension are not " +"set, ask to fill them up." +msgstr "" +"Se per il prodotto che deve essere lavorato, non è impostata la dimensione " +"dell'imballo, chiede di compilarla." + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model,name:shopfloor_reception_packaging_dimension.model_product_packaging_level +msgid "Level management for product.packaging" +msgstr "Gestione livello per product.packaging" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model,name:shopfloor_reception_packaging_dimension.model_shopfloor_menu +msgid "Menu displayed in the scanner application" +msgstr "Menu visualizzato nell'applicazione di scansione" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_shopfloor_menu__set_packaging_dimension_is_possible +msgid "Set Packaging Dimension Is Possible" +msgstr "È possibile impostare la dimensione dell'imballo" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_shopfloor_menu__set_packaging_dimension +msgid "Set packaging dimension" +msgstr "Imposta dimensione imballo" + +#. module: shopfloor_reception_packaging_dimension +#: model_terms:ir.ui.view,arch_db:shopfloor_reception_packaging_dimension.view_product_packaging_level_form +msgid "Shopfloor" +msgstr "Reparto" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_height +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_length +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_weight +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_width +msgid "" +"When marked, shopfloor will require to set this dimension during reception " +"if undefined on the packaging" +msgstr "" +"Una volta contrassegnata, il reparto dovrà impostare questa dimensione " +"durante la ricezione se non definita sulla confezione" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/shopfloor_reception_packaging_dimension/i18n/shopfloor_reception_packaging_dimension.pot b/shopfloor_reception_packaging_dimension/i18n/shopfloor_reception_packaging_dimension.pot new file mode 100644 index 00000000000..bedc200b543 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/i18n/shopfloor_reception_packaging_dimension.pot @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * shopfloor_reception_packaging_dimension +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \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: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_height +msgid "Collect height" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_length +msgid "Collect length" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_weight +msgid "Collect weight" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_width +msgid "Collect width" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_shopfloor_menu__set_packaging_dimension +msgid "" +"If for the product being processed, its related packaging dimension are not " +"set, ask to fill them up." +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model,name:shopfloor_reception_packaging_dimension.model_product_packaging_level +msgid "Level management for product.packaging" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model,name:shopfloor_reception_packaging_dimension.model_shopfloor_menu +msgid "Menu displayed in the scanner application" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_shopfloor_menu__set_packaging_dimension_is_possible +msgid "Set Packaging Dimension Is Possible" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,field_description:shopfloor_reception_packaging_dimension.field_shopfloor_menu__set_packaging_dimension +msgid "Set packaging dimension" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model_terms:ir.ui.view,arch_db:shopfloor_reception_packaging_dimension.view_product_packaging_level_form +msgid "Shopfloor" +msgstr "" + +#. module: shopfloor_reception_packaging_dimension +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_height +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_length +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_weight +#: model:ir.model.fields,help:shopfloor_reception_packaging_dimension.field_product_packaging_level__shopfloor_collect_width +msgid "" +"When marked, shopfloor will require to set this dimension during reception " +"if undefined on the packaging" +msgstr "" diff --git a/shopfloor_reception_packaging_dimension/models/__init__.py b/shopfloor_reception_packaging_dimension/models/__init__.py new file mode 100644 index 00000000000..0f96d1da6bd --- /dev/null +++ b/shopfloor_reception_packaging_dimension/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_packaging_level +from . import shopfloor_menu diff --git a/shopfloor_reception_packaging_dimension/models/product_packaging_level.py b/shopfloor_reception_packaging_dimension/models/product_packaging_level.py new file mode 100644 index 00000000000..b0070d9262f --- /dev/null +++ b/shopfloor_reception_packaging_dimension/models/product_packaging_level.py @@ -0,0 +1,38 @@ +# Copyright 2025 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import fields, models + +HELP_TEXT = ( + "When marked, shopfloor will require to set dimensions during " + "reception if undefined on the packaging" +) + + +class ProductPackagingLevel(models.Model): + _inherit = "product.packaging.level" + + shopfloor_collect_length = fields.Boolean( + "Collect length", + default=True, + help=HELP_TEXT, + ) + shopfloor_collect_width = fields.Boolean( + "Collect width", + default=True, + help=HELP_TEXT, + ) + shopfloor_collect_height = fields.Boolean( + "Collect height", + default=True, + help=HELP_TEXT, + ) + shopfloor_collect_weight = fields.Boolean( + "Collect weight", + default=True, + help=HELP_TEXT, + ) + shopfloor_collect_barcode = fields.Boolean( + "Collect Barcode", + default=True, + help=HELP_TEXT, + ) diff --git a/shopfloor_reception_packaging_dimension/models/shopfloor_menu.py b/shopfloor_reception_packaging_dimension/models/shopfloor_menu.py new file mode 100644 index 00000000000..6cf71a58de0 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/models/shopfloor_menu.py @@ -0,0 +1,24 @@ +# Copyright 2023 Camptocamp SA (http://www.camptocamp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class ShopfloorMenu(models.Model): + _inherit = "shopfloor.menu" + + set_packaging_dimension_is_possible = fields.Boolean( + compute="_compute_set_packaging_dimension_is_possible" + ) + set_packaging_dimension = fields.Boolean( + string="Set packaging dimension", + default=False, + help="If for the product being processed, its related packaging " + "dimension are not set, ask to fill them up.", + ) + + @api.depends("scenario_id") + def _compute_set_packaging_dimension_is_possible(self): + for menu in self: + menu.set_packaging_dimension_is_possible = menu.scenario_id.has_option( + "set_packaging_dimension" + ) diff --git a/shopfloor_reception_packaging_dimension/pyproject.toml b/shopfloor_reception_packaging_dimension/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/shopfloor_reception_packaging_dimension/readme/CONTRIBUTORS.md b/shopfloor_reception_packaging_dimension/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..e3bb8b0f9b7 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Thierry Ducrest \<\> +- Denis Roussel \<\> \ No newline at end of file diff --git a/shopfloor_reception_packaging_dimension/readme/DESCRIPTION.md b/shopfloor_reception_packaging_dimension/readme/DESCRIPTION.md new file mode 100644 index 00000000000..7486f8c5859 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +This module adds an option to the reception scenario. When activated. +Before setting the quantity for the reception, if there is product +packaging related to the product received with missing information, the +user will be presented with a screen (for each packaging) proposing to +update the missing information. diff --git a/shopfloor_reception_packaging_dimension/services/__init__.py b/shopfloor_reception_packaging_dimension/services/__init__.py new file mode 100644 index 00000000000..aa19bba8ce4 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/services/__init__.py @@ -0,0 +1 @@ +from . import reception diff --git a/shopfloor_reception_packaging_dimension/services/reception.py b/shopfloor_reception_packaging_dimension/services/reception.py new file mode 100644 index 00000000000..f44a671ddce --- /dev/null +++ b/shopfloor_reception_packaging_dimension/services/reception.py @@ -0,0 +1,244 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (http://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.shopfloor.utils import to_float + + +class Reception(Component): + _inherit = "shopfloor.reception" + + def __init__(self, work_context): + super().__init__(work_context) + self.packaging_update_done = False + + def _before_state__set_quantity(self, picking, line, message=None): + """Show the packaging dimension screen before the set quantity screen.""" + if not self.work.menu.set_packaging_dimension or self.packaging_update_done: + return super()._before_state__set_quantity(picking, line, message=message) + + packaging = self._get_next_packaging_to_set_dimension(line.product_id) + if not packaging: + return super()._before_state__set_quantity(picking, line, message=message) + + return self._response_for_set_packaging_dimension( + picking, line, packaging, message=message + ) + + def _get_domain_packaging_needs_dimension(self): + return expression.OR( + [ + [ + ("packaging_level_id.shopfloor_collect_length", "=", True), + "|", + ("packaging_length", "=", 0), + ("packaging_length", "=", False), + ], + [ + ("packaging_level_id.shopfloor_collect_width", "=", True), + "|", + ("width", "=", 0), + ("width", "=", False), + ], + [ + ("packaging_level_id.shopfloor_collect_height", "=", True), + "|", + ("height", "=", 0), + ("height", "=", False), + ], + [ + ("packaging_level_id.shopfloor_collect_weight", "=", True), + "|", + ("weight", "=", 0), + ("weight", "=", False), + ], + [ + ("packaging_level_id.shopfloor_collect_barcode", "=", True), + ("barcode", "=", False), + ], + ] + ) + + def _get_next_packaging_to_set_dimension(self, product, previous_packaging=None): + """Return for a product the next packaging needing dimension to be set.""" + next_packaging_id = previous_packaging.id + 1 if previous_packaging else 0 + domain_dimension = self._get_domain_packaging_needs_dimension() + domain_packaging_id = [ + ("product_id", "=", product.id), + ("id", ">=", next_packaging_id), + ] + domain = expression.AND([domain_packaging_id, domain_dimension]) + return self.env["product.packaging"].search(domain, order="id", limit=1) + + def _response_for_set_packaging_dimension( + self, picking, line, packaging, message=None + ): + return self._response( + next_state="set_packaging_dimension", + data={ + "picking": self.data.picking(picking), + "selected_move_line": self.data.move_line(line), + "packaging": self._set_packaging_dimension_data_for_packaging( + packaging + ), + }, + message=message, + ) + + def _set_packaging_dimension_data_for_packaging(self, packaging): + return self.data.packaging_dimensions(packaging) + + def set_packaging_dimension( + self, picking_id, selected_line_id, packaging_id, skip=False, **kwargs + ): + """Set the dimension on a product packaging. + + If the user skip the dimension update we still propose the next + possible packaging. + + Transitions: + - set_packaging_dimension: if more packaging needs dimension + - set_quantity: otherwise + """ + picking = self.env["stock.picking"].browse(picking_id) + selected_line = self.env["stock.move.line"].browse(selected_line_id) + packaging = self.env["product.packaging"].sudo().browse(packaging_id) + + if not packaging: + return self._before_state__set_quantity( + picking, selected_line, message=self.msg_store.record_not_found() + ) + + message = None + + if not skip and self._check_dimension_to_update(kwargs): + self._update_packaging_dimension(packaging, kwargs) + message = self.msg_store.packaging_updated(packaging) + + next_packaging = self._get_next_packaging_to_set_dimension( + selected_line.product_id, packaging + ) + if next_packaging: + return self._response_for_set_packaging_dimension( + picking, selected_line, next_packaging, message=message + ) + + self.packaging_update_done = True + return self._before_state__set_quantity(picking, selected_line, message=message) + + def _check_dimension_to_update(self, dimensions): + """Check if the Shopfloor payload contains data for a packaging update.""" + return any(value is not None for value in dimensions.values()) + + def _update_packaging_dimension(self, packaging, dimensions_to_update): + """Update dimension on the packaging.""" + values_to_update = {} + packaging_values = packaging.read(dimensions_to_update.keys())[0] + + for key, value in dimensions_to_update.items(): + if value is None: + continue + # Skip updating fields with unchanged values to prevent unnecessary + # triggers of compute methods or other side effects + if packaging_values[key] != value: + values_to_update[key] = value + + if values_to_update: + packaging.write(values_to_update) + + +class ShopfloorReceptionValidator(Component): + _inherit = "shopfloor.reception.validator" + + def set_packaging_dimension(self): + return { + "picking_id": {"coerce": to_int, "required": True, "type": "integer"}, + "selected_line_id": { + "coerce": to_int, + "required": True, + "type": "integer", + }, + "packaging_id": {"coerce": to_int, "required": True, "type": "integer"}, + "height": { + "coerce": to_float, + "required": False, + "type": "float", + "nullable": True, + }, + "packaging_length": { + "coerce": to_float, + "required": False, + "type": "float", + "nullable": True, + }, + "width": { + "coerce": to_float, + "required": False, + "type": "float", + "nullable": True, + }, + "weight": { + "coerce": to_float, + "required": False, + "type": "float", + "nullable": True, + }, + "shipping_weight": { + "coerce": to_float, + "required": False, + "type": "float", + "nullable": True, + }, + "qty": { + "coerce": to_float, + "required": False, + "type": "float", + "nullable": True, + }, + "barcode": {"type": "string", "required": False, "nullable": True}, + "skip": {"type": "boolean"}, + } + + +class ShopfloorReceptionValidatorResponse(Component): + _inherit = "shopfloor.reception.validator.response" + + def _states(self): + res = super()._states() + res.update({"set_packaging_dimension": self._schema_set_packaging_dimension}) + return res + + def _scan_line_next_states(self): + res = super()._scan_line_next_states() + res.update({"set_packaging_dimension"}) + return res + + def _set_lot_confirm_action_next_states(self): + res = super()._set_lot_confirm_action_next_states() + res.update({"set_packaging_dimension"}) + return res + + @property + def _schema_set_packaging_dimension(self): + return { + "picking": {"type": "dict", "schema": self.schemas.picking()}, + "selected_move_line": {"type": "dict", "schema": self.schemas.move_line()}, + "packaging": self._schema_packaging_dimensions(), + } + + def _schema_packaging_dimensions(self): + return { + "type": "dict", + "schema": self.schemas.packaging_dimensions(), + } + + def _set_packaging_dimension_next_states(self): + return {"set_packaging_dimension", "set_quantity"} + + def set_packaging_dimension(self): + return self._response_schema( + next_states=self._set_packaging_dimension_next_states() + ) diff --git a/shopfloor_reception_packaging_dimension/static/description/icon.png b/shopfloor_reception_packaging_dimension/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/shopfloor_reception_packaging_dimension/static/description/icon.png differ diff --git a/shopfloor_reception_packaging_dimension/static/description/index.html b/shopfloor_reception_packaging_dimension/static/description/index.html new file mode 100644 index 00000000000..d28b1eb9da8 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Shopfloor Reception Packaging Dimension

+ +

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 +packaging related to the product received with missing information, the +user will be presented with a screen (for each packaging) proposing to +update the missing information.

+

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

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.

+

Current maintainer:

+

TDu

+

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_packaging_dimension/tests/__init__.py b/shopfloor_reception_packaging_dimension/tests/__init__.py new file mode 100644 index 00000000000..2c166ca4fd7 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/tests/__init__.py @@ -0,0 +1 @@ +from . import test_set_package_dimension diff --git a/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py b/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py new file mode 100644 index 00000000000..41360e23221 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py @@ -0,0 +1,272 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo.addons.shopfloor_reception.tests.common import CommonCase + + +# pylint: disable=W8110 +class TestSetPackDimension(CommonCase): + @classmethod + def setUpClassBaseData(cls): + super().setUpClassBaseData() + # Activate the option to use the module + cls.menu.sudo().set_packaging_dimension = True + cls.picking = cls._create_picking( + lines=[(cls.product_a, 10), (cls.product_b, 10), (cls.product_c, 10)] + ) + cls.default_packaging_level = cls.env[ + "product.packaging" + ].default_packaging_level_id() + cls.default_packaging_level.sudo().write( + { + "shopfloor_collect_length": True, + "shopfloor_collect_width": True, + "shopfloor_collect_height": True, + "shopfloor_collect_weight": True, + "shopfloor_collect_barcode": True, + } + ) + # Picking has 3 products + # Product A with one packaging + # Product B with no packaging + cls.product_b.packaging_ids = [(5, 0, 0)] + # Product C with 2 packaging + cls.product_c_packaging_2 = ( + cls.env["product.packaging"] + .sudo() + .create( + { + "name": "Big Box", + "product_id": cls.product_c.id, + "barcode": "ProductCBigBox", + "qty": 6, + } + ) + ) + + cls.line_with_packaging = cls.picking.move_line_ids[0] + cls.line_without_packaging = cls.picking.move_line_ids[1] + + def _assert_response_set_dimension( + self, response, picking, line, packaging, message=None + ): + data = { + "picking": self.data.picking(picking), + "selected_move_line": self.data.move_line(line), + "packaging": self.data.packaging_dimensions(packaging), + } + self.assert_response( + response, + next_state="set_packaging_dimension", + data=data, + message=message, + ) + + def test_scan_product_ask_for_dimension(self): + 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 li: li.product_id == self.product_a + ) + self._assert_response_set_dimension( + response, self.picking, selected_move_line, self.product_a_packaging + ) + + def test_scan_product_dimension_already_defined(self): + self.product_a.tracking = "none" + self.product_a_packaging.write( + { + "packaging_length": 10.0, + "width": 5.0, + "height": 2.0, + "weight": 1.5, + "barcode": "BARCODE", + } + ) + response = self.service.dispatch( + "scan_line", + params={ + "picking_id": self.picking.id, + "barcode": self.product_a.barcode, + }, + ) + selected_move_line = self.picking.move_line_ids.filtered( + lambda li: li.product_id == self.product_a + ) + self.assert_response( + response, + next_state="set_quantity", + data={ + "confirmation_required": None, + "picking": self.data.picking(self.picking), + "selected_move_line": [self.data.move_line(selected_move_line)], + }, + ) + + def test_show_set_dimension_screen(self): + self.product_a.tracking = "none" + # Configure product so it should hit every condition + self.product_a.packaging_ids.write( + { + "packaging_length": 0, + "width": 0, + "height": 0, + "weight": 0, + "barcode": False, + } + ) + # Set collect values to false + collect_field_names = [ + "shopfloor_collect_length", + "shopfloor_collect_width", + "shopfloor_collect_height", + "shopfloor_collect_weight", + "shopfloor_collect_barcode", + ] + no_collect_dict = {field: False for field in collect_field_names} + selected_move_line = self.picking.move_line_ids.filtered( + lambda li: li.product_id == self.product_a + ) + for field_name in no_collect_dict.keys(): + # For each field, set only this condition to true, and ensure next screen + # is set_dimension + vals = dict(no_collect_dict, **{field_name: True}) + self.default_packaging_level.sudo().write(vals) + response = self.service.dispatch( + "scan_line", + params={ + "picking_id": self.picking.id, + "barcode": self.product_a.barcode, + }, + ) + self._assert_response_set_dimension( + response, self.picking, selected_move_line, self.product_a_packaging + ) + # To avoid the message about recovering a session + selected_move_line.shopfloor_user_id = False + + # when all collect values are False, no dimension is needed, next screen + # is set_dimension + self.default_packaging_level.sudo().write(no_collect_dict) + response = self.service.dispatch( + "scan_line", + params={ + "picking_id": self.picking.id, + "barcode": self.product_a.barcode, + }, + ) + self.assert_response( + response, + next_state="set_quantity", + data={ + "confirmation_required": None, + "picking": self.data.picking(self.picking), + "selected_move_line": [self.data.move_line(selected_move_line)], + }, + ) + + def test_set_packaging_dimension(self): + selected_move_line = self.picking.move_line_ids.filtered( + lambda li: li.product_id == self.product_a + ) + self.service.dispatch( + "set_packaging_dimension", + params={ + "picking_id": self.picking.id, + "selected_line_id": selected_move_line.id, + "packaging_id": self.product_a_packaging.id, + "height": 55, + "qty": 34, + "barcode": "barcode", + }, + ) + self.assertEqual(self.product_a_packaging.height, 55) + self.assertEqual(self.product_a_packaging.barcode, "barcode") + self.assertEqual(self.product_a_packaging.qty, 34) + + def test_set_multiple_packaging_dimension(self): + line = self.picking.move_line_ids.filtered( + lambda li: li.product_id == self.product_c + ) + # Set the weight but other dimension are required + self.product_c_packaging_2.weight = 200 + response = self.service.dispatch( + "set_packaging_dimension", + params={ + "picking_id": self.picking.id, + "selected_line_id": line.id, + "packaging_id": self.product_c_packaging.id, + "height": 55, + "packaging_length": 233, + }, + ) + self.assertEqual(self.product_c_packaging.height, 55) + self.assertEqual(self.product_c_packaging.packaging_length, 233) + self._assert_response_set_dimension( + response, + self.picking, + line, + self.product_c_packaging_2, + message=self.msg_store.packaging_updated(self.product_c_packaging), + ) + response = self.service.dispatch( + "set_packaging_dimension", + params={ + "picking_id": self.picking.id, + "selected_line_id": line.id, + "packaging_id": self.product_c_packaging_2.id, + "height": 200, + "weight": 1000, + }, + ) + self.assertEqual(self.product_c_packaging_2.height, 200) + self.assertEqual(self.product_c_packaging_2.weight, 1000) + self.assert_response( + response, + next_state="set_quantity", + data={ + "picking": self.data.picking(self.picking), + "selected_move_line": self.data.move_lines(line), + "confirmation_required": None, + }, + message=self.msg_store.packaging_updated(self.product_c_packaging_2), + ) + + def test_skip_packaging_dimension_skips_to_next(self): + line = self.picking.move_line_ids.filtered( + lambda li: li.product_id == self.product_c + ) + original_height = self.product_c_packaging.height + + response = self.service.dispatch( + "set_packaging_dimension", + params={ + "picking_id": self.picking.id, + "selected_line_id": line.id, + "packaging_id": self.product_c_packaging.id, + "height": 999.0, # This value should be ignored + "skip": True, + }, + ) + + self.assertEqual( + self.product_c_packaging.height, + original_height, + "Packaging height should not change when skipped", + ) + self._assert_response_set_dimension( + response, + self.picking, + line, + self.product_c_packaging_2, + message=None, # No 'Updated' message should be returned when skipping + ) diff --git a/shopfloor_reception_packaging_dimension/views/product_packaging_level.xml b/shopfloor_reception_packaging_dimension/views/product_packaging_level.xml new file mode 100644 index 00000000000..c8634809a03 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/views/product_packaging_level.xml @@ -0,0 +1,24 @@ + + + + product.packaging.level.form + product.packaging.level + + + + + + + + + + + + + + + + diff --git a/shopfloor_reception_packaging_dimension/views/shopfloor_menu.xml b/shopfloor_reception_packaging_dimension/views/shopfloor_menu.xml new file mode 100644 index 00000000000..42c46d55a28 --- /dev/null +++ b/shopfloor_reception_packaging_dimension/views/shopfloor_menu.xml @@ -0,0 +1,18 @@ + + + + shopfloor.menu + + + + + + + + + + + diff --git a/shopfloor_reception_packaging_dimension_mobile/README.rst b/shopfloor_reception_packaging_dimension_mobile/README.rst new file mode 100644 index 00000000000..0b682c68b53 --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/README.rst @@ -0,0 +1,92 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================================== +Shopfloor Reception Packaging Dimension 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/license-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_packaging_dimension_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_packaging_dimension_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_packaging_dimension` +module. Allowing to set dimension on packaging related to the product being processed, +if they are not set already. +The option needs to be enable on the shopfloor menu. + +**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 +* Denis Roussel + +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-TDu| image:: https://github.com/TDu.png?size=40px + :target: https://github.com/TDu + :alt: TDu + +Current `maintainer `__: + +|maintainer-TDu| + +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_packaging_dimension_mobile/__init__.py b/shopfloor_reception_packaging_dimension_mobile/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/shopfloor_reception_packaging_dimension_mobile/__manifest__.py b/shopfloor_reception_packaging_dimension_mobile/__manifest__.py new file mode 100644 index 00000000000..0fbd8188128 --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Shopfloor Reception Packaging Dimension Mobile", + "summary": "Frontend for the packaging dimension on reception scenario", + "version": "16.0.1.0.0", + "category": "Inventory", + "website": "https://github.com/OCA/wms", + "author": "Camptocamp, Odoo Community Association (OCA)", + "maintainers": ["TDu"], + "license": "AGPL-3", + "depends": [ + "shopfloor_reception_mobile", + "shopfloor_reception_packaging_dimension", + ], + "data": ["templates/assets.xml"], +} diff --git a/shopfloor_reception_packaging_dimension_mobile/i18n/it.po b/shopfloor_reception_packaging_dimension_mobile/i18n/it.po new file mode 100644 index 00000000000..9ce4346f63e --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/i18n/it.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" diff --git a/shopfloor_reception_packaging_dimension_mobile/i18n/shopfloor_reception_packaging_dimension_mobile.pot b/shopfloor_reception_packaging_dimension_mobile/i18n/shopfloor_reception_packaging_dimension_mobile.pot new file mode 100644 index 00000000000..4d8b20f912f --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/i18n/shopfloor_reception_packaging_dimension_mobile.pot @@ -0,0 +1,13 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \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" diff --git a/shopfloor_reception_packaging_dimension_mobile/readme/CONTRIBUTORS.rst b/shopfloor_reception_packaging_dimension_mobile/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..9dda9dc4be2 --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Thierry Ducrest +* Denis Roussel diff --git a/shopfloor_reception_packaging_dimension_mobile/readme/DESCRIPTION.rst b/shopfloor_reception_packaging_dimension_mobile/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..ab7978b5619 --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module adds the front end part for the `shopfloor_reception_packaging_dimension` +module. Allowing to set dimension on packaging related to the product being processed, +if they are not set already. +The option needs to be enable on the shopfloor menu. diff --git a/shopfloor_reception_packaging_dimension_mobile/static/description/icon.png b/shopfloor_reception_packaging_dimension_mobile/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/shopfloor_reception_packaging_dimension_mobile/static/description/icon.png differ diff --git a/shopfloor_reception_packaging_dimension_mobile/static/description/index.html b/shopfloor_reception_packaging_dimension_mobile/static/description/index.html new file mode 100644 index 00000000000..ebeec41788d --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Shopfloor Reception Packaging Dimension 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_packaging_dimension +module. Allowing to set dimension on packaging related to the product being processed, +if they are not set already. +The option needs to be enable on the shopfloor menu.

+

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

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.

+

Current maintainer:

+

TDu

+

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_packaging_dimension_mobile/static/src/scenario/reception_packaging_dimension.js b/shopfloor_reception_packaging_dimension_mobile/static/src/scenario/reception_packaging_dimension.js new file mode 100644 index 00000000000..04edb4bc006 --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/static/src/scenario/reception_packaging_dimension.js @@ -0,0 +1,251 @@ +/** + * Copyright 2023 Camptocamp SA (http://www.camptocamp.com) + * License AGPL-3.0 or later (http://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"); +// 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 _get_states_base = reception_scenario.component.methods._get_states; +const baseWatchers = reception_scenario.component.watch || {}; +const baseMethods = reception_scenario.component.methods || {}; +const ReceptionPackageDimension = process_registry.extend("reception", { + template: new_template, + watch: { + ...baseWatchers, + "state.key": function (newState) { + if (newState === "set_packaging_dimension") { + this.prefill_packaging_form_inputs(); + } + }, + }, + methods: { + ...baseMethods, + prefill_packaging_form_inputs: function () { + if (!this.state_is("set_packaging_dimension")) return; + + const pkg = this.state.data.packaging; + const input_fields = this.get_packaging_measurements_inputs(); + + input_fields.forEach((inputKey) => { + const originalKey = inputKey.replace("_input", ""); + if (pkg[inputKey] === undefined || pkg[inputKey] === null) { + this.$set(pkg, inputKey, pkg[originalKey]); + } + }); + }, + get_packaging_measurements_inputs: function () { + return [ + "packaging_length_input", + "width_input", + "height_input", + "weight_input", + "qty_input", + "barcode_input", + ]; + }, + packaging_detail_options: function () { + const pkg = this.state.data.packaging; + const _is_field_changed = (fieldName) => { + const inputKey = fieldName + "_input"; + return pkg[inputKey] && pkg[inputKey] != pkg[fieldName]; + }; + const options = { + main: true, + key_title: "name", + title_icon: "mdi-package-variant", + fields: [ + { + path: "barcode", + label: "Barcode", + klass: _is_field_changed("barcode") ? "accent" : "", + }, + { + path: "qty", + label: "Quantity", + klass: _is_field_changed("qty") ? "accent" : "", + }, + { + path: "packaging_length", + label: "Length", + klass: _is_field_changed("packaging_length") ? "accent" : "", + renderer: function (rec, field) { + const value = _.result(rec, "packaging_length", ""); + const uom = _.result(rec, "length_uom_name", ""); + return value + " " + uom; + }, + }, + { + path: "width", + label: "Width", + klass: _is_field_changed("width") ? "accent" : "", + renderer: function (rec, field) { + const value = _.result(rec, "width", ""); + const uom = _.result(rec, "length_uom_name", ""); + return value + " " + uom; + }, + }, + { + path: "height", + label: "Height", + klass: _is_field_changed("height") ? "accent" : "", + renderer: function (rec, field) { + const value = _.result(rec, "height", ""); + const uom = _.result(rec, "length_uom_name", ""); + return value + " " + uom; + }, + }, + { + path: "weight", + label: "Weight", + klass: _is_field_changed("weight") ? "accent" : "", + renderer: function (rec, field) { + const value = _.result(rec, "weight", ""); + const uom = _.result(rec, "weight_uom_name", ""); + return value + " " + uom; + }, + }, + ], + }; + return options; + }, + _get_states: function () { + let states = _get_states_base.bind(this)(); + + // Capture 'this' in a variable to be safe across async boundaries + const self = this; + + states["set_packaging_dimension"] = { + display_info: { + title: "Set packaging dimension", + }, + events: { + go_back: "on_back", + }, + get_payload_set_packaging_dimension: () => { + let values = { + picking_id: this.state.data.picking.id, + selected_line_id: this.state.data.selected_move_line.id, + packaging_id: this.state.data.packaging.id, + }; + for (const measurement of this.get_packaging_measurements_inputs()) { + values[measurement.replace("_input", "")] = + this.state.data.packaging[measurement]; + } + return values; + }, + on_skip: async function () { + const payload = self.state.get_payload_set_packaging_dimension(); + payload["skip"] = true; + await self.wait_call( + self.odoo.call("set_packaging_dimension", payload) + ); + self.prefill_packaging_form_inputs(); + }, + on_done: async function () { + const payload = self.state.get_payload_set_packaging_dimension(); + await self.wait_call( + self.odoo.call("set_packaging_dimension", payload) + ); + self.prefill_packaging_form_inputs(); + }, + }; + return states; + }, + }, +}); + +process_registry.replace("reception", ReceptionPackageDimension); diff --git a/shopfloor_reception_packaging_dimension_mobile/templates/assets.xml b/shopfloor_reception_packaging_dimension_mobile/templates/assets.xml new file mode 100644 index 00000000000..000d0fa522b --- /dev/null +++ b/shopfloor_reception_packaging_dimension_mobile/templates/assets.xml @@ -0,0 +1,25 @@ + + + + + + +