From 30885acf0e45a54bfe6e4b18fc53cb4b07de85f0 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 28 May 2021 09:41:04 +0200 Subject: [PATCH 1/4] Add stock_packaging_calculator_packaging_type --- .../stock_packaging_calculator_packaging_type | 1 + .../setup.py | 6 +++ .../README.rst | 1 + .../__init__.py | 1 + .../__manifest__.py | 16 ++++++ .../models/__init__.py | 2 + .../models/product.py | 25 +++++++++ .../models/product_qty_by_packaging_mixin.py | 23 +++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 3 ++ .../tests/__init__.py | 1 + .../tests/test_packaging_by_qty.py | 51 +++++++++++++++++++ 12 files changed, 131 insertions(+) create mode 120000 setup/stock_packaging_calculator_packaging_type/odoo/addons/stock_packaging_calculator_packaging_type create mode 100644 setup/stock_packaging_calculator_packaging_type/setup.py create mode 100644 stock_packaging_calculator_packaging_type/README.rst create mode 100644 stock_packaging_calculator_packaging_type/__init__.py create mode 100644 stock_packaging_calculator_packaging_type/__manifest__.py create mode 100644 stock_packaging_calculator_packaging_type/models/__init__.py create mode 100644 stock_packaging_calculator_packaging_type/models/product.py create mode 100644 stock_packaging_calculator_packaging_type/models/product_qty_by_packaging_mixin.py create mode 100644 stock_packaging_calculator_packaging_type/readme/CONTRIBUTORS.rst create mode 100644 stock_packaging_calculator_packaging_type/readme/DESCRIPTION.rst create mode 100644 stock_packaging_calculator_packaging_type/tests/__init__.py create mode 100644 stock_packaging_calculator_packaging_type/tests/test_packaging_by_qty.py diff --git a/setup/stock_packaging_calculator_packaging_type/odoo/addons/stock_packaging_calculator_packaging_type b/setup/stock_packaging_calculator_packaging_type/odoo/addons/stock_packaging_calculator_packaging_type new file mode 120000 index 000000000..f1de9f895 --- /dev/null +++ b/setup/stock_packaging_calculator_packaging_type/odoo/addons/stock_packaging_calculator_packaging_type @@ -0,0 +1 @@ +../../../../stock_packaging_calculator_packaging_type \ No newline at end of file diff --git a/setup/stock_packaging_calculator_packaging_type/setup.py b/setup/stock_packaging_calculator_packaging_type/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_packaging_calculator_packaging_type/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_packaging_calculator_packaging_type/README.rst b/stock_packaging_calculator_packaging_type/README.rst new file mode 100644 index 000000000..89bcd6c21 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/README.rst @@ -0,0 +1 @@ +wait for the bot ;) diff --git a/stock_packaging_calculator_packaging_type/__init__.py b/stock_packaging_calculator_packaging_type/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_packaging_calculator_packaging_type/__manifest__.py b/stock_packaging_calculator_packaging_type/__manifest__.py new file mode 100644 index 000000000..464850ea1 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2021 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) +{ + "name": "Stock packaging calculator packaging type", + "summary": "Glue module for packaging type", + "version": "13.0.1.0.0", + "development_status": "Alpha", + "category": "Warehouse Management", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "auto_install": True, + "depends": ["stock_packaging_calculator", "product_packaging_type"], +} diff --git a/stock_packaging_calculator_packaging_type/models/__init__.py b/stock_packaging_calculator_packaging_type/models/__init__.py new file mode 100644 index 000000000..fb73bb4d1 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/models/__init__.py @@ -0,0 +1,2 @@ +from . import product +from . import product_qty_by_packaging_mixin diff --git a/stock_packaging_calculator_packaging_type/models/product.py b/stock_packaging_calculator_packaging_type/models/product.py new file mode 100644 index 000000000..d69288cb9 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/models/product.py @@ -0,0 +1,25 @@ +# Copyright 2021 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) + +from odoo import models + + +class Product(models.Model): + _inherit = "product.product" + + def _packaging_name_getter(self, packaging): + return packaging.packaging_type_id.name + + def _qty_by_packaging_as_str(self, packaging, qty): + # By default use packaging type code + qty_by_packaging_type_fname = self.env.context.get( + "qty_by_packaging_type_fname", "code" + ) + compact_mode = self.env.context.get("qty_by_packaging_type_compact", True) + sep = "" if compact_mode else " " + # Override to use packaging type code + if packaging and packaging.packaging_type_id: + name = packaging.packaging_type_id[qty_by_packaging_type_fname] + return f"{qty}{sep}{name}" + else: + return super()._qty_by_packaging_as_str(packaging, qty) diff --git a/stock_packaging_calculator_packaging_type/models/product_qty_by_packaging_mixin.py b/stock_packaging_calculator_packaging_type/models/product_qty_by_packaging_mixin.py new file mode 100644 index 000000000..262426ed9 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/models/product_qty_by_packaging_mixin.py @@ -0,0 +1,23 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# @author: Sébastien Alix +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) +from odoo import api, models + + +class ProductQtyByPackagingMixin(models.AbstractModel): + """Allow displaying product qty by packaging. + """ + + _inherit = "product.qty_by_packaging.mixin" + + # Amazing.. unlike `api.depends`, `depends_context` cannot use a lambda + # to delegate lookup. Hence we are forced to override and call super. + @api.depends_context( + "lang", + "qty_by_pkg_total_units", + "qty_by_packaging_type_fname", + "qty_by_packaging_type_compact", + ) + def _compute_product_qty_by_packaging_display(self): + super()._compute_product_qty_by_packaging_display() diff --git a/stock_packaging_calculator_packaging_type/readme/CONTRIBUTORS.rst b/stock_packaging_calculator_packaging_type/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f1c71bce1 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Simone Orsi diff --git a/stock_packaging_calculator_packaging_type/readme/DESCRIPTION.rst b/stock_packaging_calculator_packaging_type/readme/DESCRIPTION.rst new file mode 100644 index 000000000..c4e69a515 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Glue module for `stock_packaging_calculator` and `product_packaging_type`. + +Mainly to use packaging type's code instead of packaging's name. diff --git a/stock_packaging_calculator_packaging_type/tests/__init__.py b/stock_packaging_calculator_packaging_type/tests/__init__.py new file mode 100644 index 000000000..c6b11a17e --- /dev/null +++ b/stock_packaging_calculator_packaging_type/tests/__init__.py @@ -0,0 +1 @@ +from . import test_packaging_by_qty diff --git a/stock_packaging_calculator_packaging_type/tests/test_packaging_by_qty.py b/stock_packaging_calculator_packaging_type/tests/test_packaging_by_qty.py new file mode 100644 index 000000000..e3fc5eba7 --- /dev/null +++ b/stock_packaging_calculator_packaging_type/tests/test_packaging_by_qty.py @@ -0,0 +1,51 @@ +# Copyright 2021 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) +from odoo.addons.stock_packaging_calculator.tests.common import TestCommon +from odoo.addons.stock_packaging_calculator.tests.utils import make_pkg_values + + +class TestCalc(TestCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.type_retail_box = cls.env["product.packaging.type"].create( + {"name": "Retail Box", "code": "PACK", "sequence": 3} + ) + cls.type_transport_box = cls.env["product.packaging.type"].create( + {"name": "Transport Box", "code": "CASE", "sequence": 4} + ) + cls.type_pallet = cls.env["product.packaging.type"].create( + {"name": "Pallet", "code": "PALLET", "sequence": 5} + ) + cls.pkg_box.packaging_type_id = cls.type_retail_box + cls.pkg_big_box.packaging_type_id = cls.type_transport_box + cls.pkg_pallet.packaging_type_id = cls.type_pallet + + def test_calc_1(self): + expected = [ + make_pkg_values(self.pkg_pallet, qty=1, name=self.type_pallet.name), + make_pkg_values(self.pkg_big_box, qty=3, name=self.type_transport_box.name), + make_pkg_values(self.pkg_box, qty=1, name=self.type_retail_box.name), + make_pkg_values(self.uom_unit, qty=5), + ] + self.assertEqual(self.product_a.product_qty_by_packaging(2655), expected) + + def test_calc_2(self): + expected = [ + make_pkg_values(self.pkg_big_box, qty=1, name=self.type_transport_box.name), + make_pkg_values(self.pkg_box, qty=3, name=self.type_retail_box.name), + ] + self.assertEqual(self.product_a.product_qty_by_packaging(350), expected) + + def test_as_str(self): + self.assertEqual(self.product_a.product_qty_by_packaging_as_str(10), "") + self.assertEqual(self.product_a.product_qty_by_packaging_as_str(100), "2PACK") + self.assertEqual( + self.product_a.product_qty_by_packaging_as_str(250), "1CASE,\xa01PACK" + ) + self.assertEqual( + self.product_a.with_context( + qty_by_packaging_type_fname="name", qty_by_packaging_type_compact=False, + ).product_qty_by_packaging_as_str(250), + "1 Transport Box,\xa01 Retail Box", + ) From 64a8c5cfaa87aa776cc53914378d898aa79a2f73 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 28 May 2021 09:49:22 +0200 Subject: [PATCH 2/4] Add stock_product_qty_by_packaging --- .../addons/stock_product_qty_by_packaging | 1 + setup/stock_product_qty_by_packaging/setup.py | 6 ++ stock_product_qty_by_packaging/README.rst | 1 + stock_product_qty_by_packaging/__init__.py | 1 + .../__manifest__.py | 16 +++++ .../models/__init__.py | 3 + .../models/stock_move.py | 13 ++++ .../models/stock_move_line.py | 13 ++++ .../models/stock_quant.py | 13 ++++ .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 1 + .../tests/__init__.py | 1 + .../tests/test_stock.py | 63 +++++++++++++++++++ .../views/stock_picking.xml | 16 +++++ 14 files changed, 150 insertions(+) create mode 120000 setup/stock_product_qty_by_packaging/odoo/addons/stock_product_qty_by_packaging create mode 100644 setup/stock_product_qty_by_packaging/setup.py create mode 100644 stock_product_qty_by_packaging/README.rst create mode 100644 stock_product_qty_by_packaging/__init__.py create mode 100644 stock_product_qty_by_packaging/__manifest__.py create mode 100644 stock_product_qty_by_packaging/models/__init__.py create mode 100644 stock_product_qty_by_packaging/models/stock_move.py create mode 100644 stock_product_qty_by_packaging/models/stock_move_line.py create mode 100644 stock_product_qty_by_packaging/models/stock_quant.py create mode 100644 stock_product_qty_by_packaging/readme/CONTRIBUTORS.rst create mode 100644 stock_product_qty_by_packaging/readme/DESCRIPTION.rst create mode 100644 stock_product_qty_by_packaging/tests/__init__.py create mode 100644 stock_product_qty_by_packaging/tests/test_stock.py create mode 100644 stock_product_qty_by_packaging/views/stock_picking.xml diff --git a/setup/stock_product_qty_by_packaging/odoo/addons/stock_product_qty_by_packaging b/setup/stock_product_qty_by_packaging/odoo/addons/stock_product_qty_by_packaging new file mode 120000 index 000000000..702cf61a4 --- /dev/null +++ b/setup/stock_product_qty_by_packaging/odoo/addons/stock_product_qty_by_packaging @@ -0,0 +1 @@ +../../../../stock_product_qty_by_packaging \ No newline at end of file diff --git a/setup/stock_product_qty_by_packaging/setup.py b/setup/stock_product_qty_by_packaging/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_product_qty_by_packaging/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_product_qty_by_packaging/README.rst b/stock_product_qty_by_packaging/README.rst new file mode 100644 index 000000000..89bcd6c21 --- /dev/null +++ b/stock_product_qty_by_packaging/README.rst @@ -0,0 +1 @@ +wait for the bot ;) diff --git a/stock_product_qty_by_packaging/__init__.py b/stock_product_qty_by_packaging/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_product_qty_by_packaging/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_product_qty_by_packaging/__manifest__.py b/stock_product_qty_by_packaging/__manifest__.py new file mode 100644 index 000000000..330bdf003 --- /dev/null +++ b/stock_product_qty_by_packaging/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) +{ + "name": "Stock packaging calculator", + "summary": "Compute product quantity to pick by packaging", + "version": "13.0.1.0.0", + "development_status": "Alpha", + "category": "Warehouse Management", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["stock_packaging_calculator", "stock"], + "data": ["views/stock_picking.xml"], +} diff --git a/stock_product_qty_by_packaging/models/__init__.py b/stock_product_qty_by_packaging/models/__init__.py new file mode 100644 index 000000000..5676a7278 --- /dev/null +++ b/stock_product_qty_by_packaging/models/__init__.py @@ -0,0 +1,3 @@ +from . import stock_move +from . import stock_move_line +from . import stock_quant diff --git a/stock_product_qty_by_packaging/models/stock_move.py b/stock_product_qty_by_packaging/models/stock_move.py new file mode 100644 index 000000000..2bffff42c --- /dev/null +++ b/stock_product_qty_by_packaging/models/stock_move.py @@ -0,0 +1,13 @@ +# Copyright 2020 Camptocamp SA +# @author: Simone Orsi +# @author: Sébastien Alix +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class StockMove(models.Model): + _name = "stock.move" + _inherit = ["stock.move", "product.qty_by_packaging.mixin"] + + _qty_by_pkg__qty_field_name = "product_uom_qty" diff --git a/stock_product_qty_by_packaging/models/stock_move_line.py b/stock_product_qty_by_packaging/models/stock_move_line.py new file mode 100644 index 000000000..cfea5c7d8 --- /dev/null +++ b/stock_product_qty_by_packaging/models/stock_move_line.py @@ -0,0 +1,13 @@ +# Copyright 2020 Camptocamp SA +# @author: Simone Orsi +# @author: Sébastien Alix +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class StockMoveLine(models.Model): + _name = "stock.move.line" + _inherit = ["stock.move.line", "product.qty_by_packaging.mixin"] + + _qty_by_pkg__qty_field_name = "product_qty" diff --git a/stock_product_qty_by_packaging/models/stock_quant.py b/stock_product_qty_by_packaging/models/stock_quant.py new file mode 100644 index 000000000..04e0888bb --- /dev/null +++ b/stock_product_qty_by_packaging/models/stock_quant.py @@ -0,0 +1,13 @@ +# Copyright 2020 Camptocamp SA +# @author: Simone Orsi +# @author: Sébastien Alix +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class StockQuant(models.Model): + _name = "stock.quant" + _inherit = ["stock.quant", "product.qty_by_packaging.mixin"] + + _qty_by_pkg__qty_field_name = "quantity" diff --git a/stock_product_qty_by_packaging/readme/CONTRIBUTORS.rst b/stock_product_qty_by_packaging/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..e99779dc9 --- /dev/null +++ b/stock_product_qty_by_packaging/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +Simone Orsi +Sébastien Alix diff --git a/stock_product_qty_by_packaging/readme/DESCRIPTION.rst b/stock_product_qty_by_packaging/readme/DESCRIPTION.rst new file mode 100644 index 000000000..4a4438a48 --- /dev/null +++ b/stock_product_qty_by_packaging/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Glue module for `stock_packaging_calculator` and `stock`. diff --git a/stock_product_qty_by_packaging/tests/__init__.py b/stock_product_qty_by_packaging/tests/__init__.py new file mode 100644 index 000000000..e96f48eb2 --- /dev/null +++ b/stock_product_qty_by_packaging/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock diff --git a/stock_product_qty_by_packaging/tests/test_stock.py b/stock_product_qty_by_packaging/tests/test_stock.py new file mode 100644 index 000000000..dd0a629e5 --- /dev/null +++ b/stock_product_qty_by_packaging/tests/test_stock.py @@ -0,0 +1,63 @@ +# Copyright 2021 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) +from odoo.addons.stock_packaging_calculator.tests.common import TestCommon + +# from odoo.addons.stock_packaging_calculator.tests.utils import make_pkg_values + + +class TestStock(TestCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + ref = cls.env.ref + cls.stock_location = ref("stock.stock_location_stock") + cls.sub_location = cls.env["stock.location"].create( + {"name": "Sub", "location_id": cls.stock_location.id} + ) + cls.wh = cls.env.ref("stock.warehouse0") + cls.picking_type = cls.wh.out_type_id + cls.product_a.type = "product" + cls.env["stock.quant"]._update_available_quantity( + cls.product_a, cls.stock_location, 2825 + ) + cls.move = cls.env["stock.move"].create( + { + "name": "test", + "product_id": cls.product_a.id, + "location_id": cls.stock_location.id, + "location_dest_id": cls.sub_location.id, + "product_uom": cls.product_a.uom_id.id, + "product_uom_qty": 2825, + "state": "waiting", + "picking_type_id": cls.picking_type.id, + } + ) + cls.move._assign_picking() + cls.move._action_assign() + cls.move_line = cls.move.move_line_ids[0] + cls.move_line.product_uom_qty = 1470 + cls.quant = cls.env["stock.quant"].create( + { + "location_id": cls.stock_location.id, + "product_id": cls.product_a.id, + "quantity": 3190.0, + } + ) + + def test_move(self): + self.assertEqual( + self.move.product_qty_by_packaging_display, + "1 Pallet,\xa04 Big Box,\xa025 Units", + ) + + def test_move_line(self): + self.assertEqual( + self.move_line.product_qty_by_packaging_display, + "7 Big Box,\xa01 Box,\xa020 Units", + ) + + def test_quant(self): + self.assertEqual( + self.quant.product_qty_by_packaging_display, + "1 Pallet,\xa05 Big Box,\xa03 Box,\xa040 Units", + ) diff --git a/stock_product_qty_by_packaging/views/stock_picking.xml b/stock_product_qty_by_packaging/views/stock_picking.xml new file mode 100644 index 000000000..a77560262 --- /dev/null +++ b/stock_product_qty_by_packaging/views/stock_picking.xml @@ -0,0 +1,16 @@ + + + + stock.view.picking.form + stock.picking + + + + + + + + From 4f1cb11572fd9ecb48989dd5b6f5b7997fef6627 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 28 May 2021 10:35:43 +0200 Subject: [PATCH 3/4] Add stock_vertical_lift_qty_by_packaging --- .../stock_vertical_lift_qty_by_packaging | 1 + .../setup.py | 6 +++++ .../README.rst | 1 + .../__init__.py | 1 + .../__manifest__.py | 19 ++++++++++++++ .../models/__init__.py | 1 + .../models/vertical_lift_operation_base.py | 22 ++++++++++++++++ .../readme/CONTRIBUTORS.rst | 2 ++ .../readme/DESCRIPTION.rst | 1 + .../vertical_lift_operation_base_views.xml | 26 +++++++++++++++++++ 10 files changed, 80 insertions(+) create mode 120000 setup/stock_vertical_lift_qty_by_packaging/odoo/addons/stock_vertical_lift_qty_by_packaging create mode 100644 setup/stock_vertical_lift_qty_by_packaging/setup.py create mode 100644 stock_vertical_lift_qty_by_packaging/README.rst create mode 100644 stock_vertical_lift_qty_by_packaging/__init__.py create mode 100644 stock_vertical_lift_qty_by_packaging/__manifest__.py create mode 100644 stock_vertical_lift_qty_by_packaging/models/__init__.py create mode 100644 stock_vertical_lift_qty_by_packaging/models/vertical_lift_operation_base.py create mode 100644 stock_vertical_lift_qty_by_packaging/readme/CONTRIBUTORS.rst create mode 100644 stock_vertical_lift_qty_by_packaging/readme/DESCRIPTION.rst create mode 100644 stock_vertical_lift_qty_by_packaging/views/vertical_lift_operation_base_views.xml diff --git a/setup/stock_vertical_lift_qty_by_packaging/odoo/addons/stock_vertical_lift_qty_by_packaging b/setup/stock_vertical_lift_qty_by_packaging/odoo/addons/stock_vertical_lift_qty_by_packaging new file mode 120000 index 000000000..9493f2eac --- /dev/null +++ b/setup/stock_vertical_lift_qty_by_packaging/odoo/addons/stock_vertical_lift_qty_by_packaging @@ -0,0 +1 @@ +../../../../stock_vertical_lift_qty_by_packaging \ No newline at end of file diff --git a/setup/stock_vertical_lift_qty_by_packaging/setup.py b/setup/stock_vertical_lift_qty_by_packaging/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_vertical_lift_qty_by_packaging/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_vertical_lift_qty_by_packaging/README.rst b/stock_vertical_lift_qty_by_packaging/README.rst new file mode 100644 index 000000000..0f04118bb --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/README.rst @@ -0,0 +1 @@ +wait fot the bot ;) diff --git a/stock_vertical_lift_qty_by_packaging/__init__.py b/stock_vertical_lift_qty_by_packaging/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_vertical_lift_qty_by_packaging/__manifest__.py b/stock_vertical_lift_qty_by_packaging/__manifest__.py new file mode 100644 index 000000000..d89602b62 --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) +{ + "name": "Stock vertical lift qty by packaging", + "summary": """ + Glue module for `stock_product_qty_by_packaging` and `stock_vertical_lift`. + """, + "version": "13.0.1.0.0", + "development_status": "Alpha", + "category": "Warehouse Management", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "auto_install": True, + "depends": ["stock_product_qty_by_packaging", "stock_vertical_lift"], + "data": ["views/vertical_lift_operation_base_views.xml"], +} diff --git a/stock_vertical_lift_qty_by_packaging/models/__init__.py b/stock_vertical_lift_qty_by_packaging/models/__init__.py new file mode 100644 index 000000000..aa18eecec --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/models/__init__.py @@ -0,0 +1 @@ +from . import vertical_lift_operation_base diff --git a/stock_vertical_lift_qty_by_packaging/models/vertical_lift_operation_base.py b/stock_vertical_lift_qty_by_packaging/models/vertical_lift_operation_base.py new file mode 100644 index 000000000..2fc36e228 --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/models/vertical_lift_operation_base.py @@ -0,0 +1,22 @@ +# Copyright 2020 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import api, fields, models + + +class VerticalLiftOperationTransfer(models.AbstractModel): + _inherit = "vertical.lift.operation.transfer" + + product_qty_by_packaging_display = fields.Char( + compute="_compute_product_qty_by_packaging_display" + ) + + @api.depends("current_move_line_id.product_qty") + def _compute_product_qty_by_packaging_display(self): + # Seems the ctx key is not propagated on a related field + # nor from the field definition, nor from the field declaration in the view. + # Hence, we are forced to use a computed field. + for rec in self.with_context(qty_by_pkg_total_units=True): + rec.product_qty_by_packaging_display = ( + rec.current_move_line_id.product_qty_by_packaging_display + ) diff --git a/stock_vertical_lift_qty_by_packaging/readme/CONTRIBUTORS.rst b/stock_vertical_lift_qty_by_packaging/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..e99779dc9 --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +Simone Orsi +Sébastien Alix diff --git a/stock_vertical_lift_qty_by_packaging/readme/DESCRIPTION.rst b/stock_vertical_lift_qty_by_packaging/readme/DESCRIPTION.rst new file mode 100644 index 000000000..c35e9baf4 --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Glue module for `stock_product_qty_by_packaging` and `stock_vertical_lift`. diff --git a/stock_vertical_lift_qty_by_packaging/views/vertical_lift_operation_base_views.xml b/stock_vertical_lift_qty_by_packaging/views/vertical_lift_operation_base_views.xml new file mode 100644 index 000000000..5ffb088fb --- /dev/null +++ b/stock_vertical_lift_qty_by_packaging/views/vertical_lift_operation_base_views.xml @@ -0,0 +1,26 @@ + + + + vertical.lift.operation.transfer.screen.view + vertical.lift.operation.transfer + + + + + 1 + + + 1 + + + + + + + From b1d685fb54f0df4ad67d6d10980efba496c10aef Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 4 Jun 2021 07:43:47 +0200 Subject: [PATCH 4/4] stock_vertical_lift_kardex: make pre-commit happy --- stock_vertical_lift_kardex/proxy/README.rst | 1 + stock_vertical_lift_kardex/proxy/kardex-proxy.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 stock_vertical_lift_kardex/proxy/README.rst diff --git a/stock_vertical_lift_kardex/proxy/README.rst b/stock_vertical_lift_kardex/proxy/README.rst new file mode 100644 index 000000000..00dcb4d59 --- /dev/null +++ b/stock_vertical_lift_kardex/proxy/README.rst @@ -0,0 +1 @@ +Kardex device proxy. diff --git a/stock_vertical_lift_kardex/proxy/kardex-proxy.py b/stock_vertical_lift_kardex/proxy/kardex-proxy.py index 97607999d..75609cbc1 100755 --- a/stock_vertical_lift_kardex/proxy/kardex-proxy.py +++ b/stock_vertical_lift_kardex/proxy/kardex-proxy.py @@ -6,7 +6,7 @@ import os import ssl import time -import aiohttp +import aiohttp # pylint: disable=missing-manifest-dependency _logger = logging.getLogger(__name__)