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