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..7aa51a354 --- /dev/null +++ b/stock_product_qty_by_packaging/README.rst @@ -0,0 +1,97 @@ +========================== +Stock packaging calculator +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_product_qty_by_packaging + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_product_qty_by_packaging + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module for `stock_packaging_calculator` and `stock`. +It adds product qty computed by packaging to: + +* stock move +* stock move line +* stock quant +* stock inventory line + +Displays it: + +* stock picking view for move line +* on inventory line tree view for stock_inventory_line + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +Simone Orsi +Sébastien Alix +* `Trobz `_: +* Nguyen Hoang Hiep + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp + +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. + +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. 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..30ac87ca3 --- /dev/null +++ b/stock_product_qty_by_packaging/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +{ + "name": "Stock packaging calculator", + "summary": "Compute product quantity to pick by packaging", + "version": "14.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": "AGPL-3", + "installable": True, + "depends": ["stock_packaging_calculator", "stock"], + "data": ["views/stock_picking.xml", "views/stock_inventory_line.xml"], +} diff --git a/stock_product_qty_by_packaging/i18n/stock_product_qty_by_packaging.pot b/stock_product_qty_by_packaging/i18n/stock_product_qty_by_packaging.pot new file mode 100644 index 000000000..d4ba59cee --- /dev/null +++ b/stock_product_qty_by_packaging/i18n/stock_product_qty_by_packaging.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_product_qty_by_packaging +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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: stock_product_qty_by_packaging +#: model:ir.model,name:stock_product_qty_by_packaging.model_stock_inventory_line +msgid "Inventory Line" +msgstr "" + +#. module: stock_product_qty_by_packaging +#: model:ir.model,name:stock_product_qty_by_packaging.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: stock_product_qty_by_packaging +#: model:ir.model,name:stock_product_qty_by_packaging.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_product_qty_by_packaging +#: model:ir.model,name:stock_product_qty_by_packaging.model_stock_move +msgid "Stock Move" +msgstr "" 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..d438dc58a --- /dev/null +++ b/stock_product_qty_by_packaging/models/__init__.py @@ -0,0 +1,4 @@ +from . import stock_inventory_line +from . import stock_move +from . import stock_move_line +from . import stock_quant diff --git a/stock_product_qty_by_packaging/models/stock_inventory_line.py b/stock_product_qty_by_packaging/models/stock_inventory_line.py new file mode 100644 index 000000000..e0c697d40 --- /dev/null +++ b/stock_product_qty_by_packaging/models/stock_inventory_line.py @@ -0,0 +1,12 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class StockInventoryLine(models.Model): + + _name = "stock.inventory.line" + _inherit = ["stock.inventory.line", "product.qty_by_packaging.mixin"] + + _qty_by_pkg__qty_field_name = "theoretical_qty" 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..80f1c46a3 --- /dev/null +++ b/stock_product_qty_by_packaging/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +Simone Orsi +Sébastien Alix +* `Trobz `_: +* Nguyen Hoang Hiep diff --git a/stock_product_qty_by_packaging/readme/CREDITS.rst b/stock_product_qty_by_packaging/readme/CREDITS.rst new file mode 100644 index 000000000..f37ebe757 --- /dev/null +++ b/stock_product_qty_by_packaging/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp 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..5cb95da42 --- /dev/null +++ b/stock_product_qty_by_packaging/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +Glue module for `stock_packaging_calculator` and `stock`. +It adds product qty computed by packaging to: + +* stock move +* stock move line +* stock quant +* stock inventory line + +Displays it: + +* stock picking view for move line +* on inventory line tree view for stock_inventory_line diff --git a/stock_product_qty_by_packaging/static/description/icon.png b/stock_product_qty_by_packaging/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_product_qty_by_packaging/static/description/icon.png differ diff --git a/stock_product_qty_by_packaging/static/description/index.html b/stock_product_qty_by_packaging/static/description/index.html new file mode 100644 index 000000000..ea0e81cc7 --- /dev/null +++ b/stock_product_qty_by_packaging/static/description/index.html @@ -0,0 +1,443 @@ + + + + + + +Stock packaging calculator + + + +
+

Stock packaging calculator

+ + +

Alpha License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

Glue module for stock_packaging_calculator and stock. +It adds product qty computed by packaging to:

+
    +
  • stock move
  • +
  • stock move line
  • +
  • stock quant
  • +
  • stock inventory line
  • +
+

Displays it:

+
    +
  • stock picking view for move line
  • +
  • on inventory line tree view for stock_inventory_line
  • +
+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+

Simone Orsi <simone.orsi@camptocamp.com> +Sébastien Alix <sebastien.alix@camptocamp.com> +* Trobz: +* Nguyen Hoang Hiep <hiepnh@trobz.com>

+
+
+

Other credits

+

The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

+

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

+
+
+
+ + 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..2af8a6dde --- /dev/null +++ b/stock_product_qty_by_packaging/tests/test_stock.py @@ -0,0 +1,63 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +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_inventory_line.xml b/stock_product_qty_by_packaging/views/stock_inventory_line.xml new file mode 100644 index 000000000..199d26be1 --- /dev/null +++ b/stock_product_qty_by_packaging/views/stock_inventory_line.xml @@ -0,0 +1,15 @@ + + + + + stock.inventory.line.tree.inherit + stock.inventory.line + + + + + + + + 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 + + + + + + + +