From b7cf5514b234c1729db43d12279d1ebc3164d0a8 Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Fri, 9 Feb 2024 07:38:03 +0100 Subject: [PATCH] shopfloor: add option to exclude package types in product info --- shopfloor/README.rst | 2 +- shopfloor/__manifest__.py | 1 + shopfloor/actions/data.py | 12 ++++++-- shopfloor/models/__init__.py | 2 ++ shopfloor/models/res_company.py | 17 ++++++++++ shopfloor/models/res_config_settings.py | 13 ++++++++ shopfloor/static/description/index.html | 2 +- shopfloor/views/res_config_settings.xml | 41 +++++++++++++++++++++++++ 8 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 shopfloor/models/res_company.py create mode 100644 shopfloor/models/res_config_settings.py create mode 100644 shopfloor/views/res_config_settings.xml diff --git a/shopfloor/README.rst b/shopfloor/README.rst index fc45976e59e..29df50a5d06 100644 --- a/shopfloor/README.rst +++ b/shopfloor/README.rst @@ -7,7 +7,7 @@ Shopfloor !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:f1d165021abc730bc8bf96092b9f76139e4b17c777975af4c9e496f86774bab6 + !! source digest: sha256:562ff659a1a8d75715516363b4a01778493ebfbedd5ae2db173e11358eab7039 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/shopfloor/__manifest__.py b/shopfloor/__manifest__.py index 24f053bf1bc..105b10e1cc2 100644 --- a/shopfloor/__manifest__.py +++ b/shopfloor/__manifest__.py @@ -49,6 +49,7 @@ "data": [ "data/shopfloor_scenario_data.xml", "security/groups.xml", + "views/res_config_settings.xml", "views/shopfloor_menu.xml", "views/stock_picking_type.xml", "views/stock_location.xml", diff --git a/shopfloor/actions/data.py b/shopfloor/actions/data.py index aaefbc06dc2..2858ed2a831 100644 --- a/shopfloor/actions/data.py +++ b/shopfloor/actions/data.py @@ -309,9 +309,17 @@ def _product_parser(self): ("seller_ids:supplier_code", self._product_supplier_code), ] - def _product_packaging(self, rec, field): + def _product_packaging(self, rec, field, apply_excluded=True): + packagings = rec.packaging_ids.filtered(lambda x: x.qty) + if apply_excluded: + excluded_packaging_types = ( + self.env.user.company_id.shopfloor_excluded_product_packaging_ids + ) + packagings = packagings.filtered( + lambda x: x.packaging_type_id not in excluded_packaging_types + ) return self._jsonify( - rec.packaging_ids.filtered(lambda x: x.qty), + packagings, self._packaging_parser, multi=True, ) diff --git a/shopfloor/models/__init__.py b/shopfloor/models/__init__.py index 7147bddd21a..e053ca6af8f 100644 --- a/shopfloor/models/__init__.py +++ b/shopfloor/models/__init__.py @@ -1,4 +1,6 @@ from . import priority_postpone_mixin +from . import res_company +from . import res_config_settings from . import shopfloor_menu from . import shopfloor_app from . import stock_picking_type diff --git a/shopfloor/models/res_company.py b/shopfloor/models/res_company.py new file mode 100644 index 00000000000..bba50a69662 --- /dev/null +++ b/shopfloor/models/res_company.py @@ -0,0 +1,17 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + shopfloor_excluded_product_packaging_ids = fields.Many2many( + comodel_name="product.packaging.type", + string="Packagings Excluded from Product Information", + help=( + "Used to prevent certain package types from being returned " + "to the shopfloor app when querying for product information." + ), + ) diff --git a/shopfloor/models/res_config_settings.py b/shopfloor/models/res_config_settings.py new file mode 100644 index 00000000000..670b01078c1 --- /dev/null +++ b/shopfloor/models/res_config_settings.py @@ -0,0 +1,13 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + shopfloor_excluded_product_packaging_ids = fields.Many2many( + related="company_id.shopfloor_excluded_product_packaging_ids", + readonly=False, + ) diff --git a/shopfloor/static/description/index.html b/shopfloor/static/description/index.html index a6c2c6c887d..a89b5a85cbb 100644 --- a/shopfloor/static/description/index.html +++ b/shopfloor/static/description/index.html @@ -367,7 +367,7 @@

Shopfloor

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:f1d165021abc730bc8bf96092b9f76139e4b17c777975af4c9e496f86774bab6 +!! source digest: sha256:562ff659a1a8d75715516363b4a01778493ebfbedd5ae2db173e11358eab7039 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

Shopfloor is a barcode scanner application for internal warehouse operations.

diff --git a/shopfloor/views/res_config_settings.xml b/shopfloor/views/res_config_settings.xml new file mode 100644 index 00000000000..163898a196a --- /dev/null +++ b/shopfloor/views/res_config_settings.xml @@ -0,0 +1,41 @@ + + + + + + res.config.settings.view.form.inherit.shopfloor + res.config.settings + + + +

Shopfloor

+
+
+
+
+
+
+
+
+
+ +