diff --git a/sale_stock_secondary_unit/README.rst b/sale_stock_secondary_unit/README.rst new file mode 100644 index 00000000000..8f33ac102ab --- /dev/null +++ b/sale_stock_secondary_unit/README.rst @@ -0,0 +1,92 @@ +========================= +Sale Stock Secondary Unit +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:1156f67110248c2f602ed1d370a419741f4068f7a8bc3857a071409145810ea1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/15.0/sale_stock_secondary_unit + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_stock_secondary_unit + :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/sale-workflow&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of stock secondary unit module and +sale_order_secondary_unit to allow copy secondary sale data to stock move when +a sale order is confirmed. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module you need to: + +#. Go to a *Product > General Information tab*. +#. Create any record in "Secondary unit of measure". +#. Set the conversion factor. +#. Go to *Sale > Quotation* and create a sale order with this product. +#. Confirm the sale order. +#. Go to picking from this sale order, you will see secondary unit information. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* Carlos Dauden +* Sergio Teruel +* Tony Gu + +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/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_stock_secondary_unit/__init__.py b/sale_stock_secondary_unit/__init__.py new file mode 100644 index 00000000000..3275ac2adf3 --- /dev/null +++ b/sale_stock_secondary_unit/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/sale_stock_secondary_unit/__manifest__.py b/sale_stock_secondary_unit/__manifest__.py new file mode 100644 index 00000000000..097387caf69 --- /dev/null +++ b/sale_stock_secondary_unit/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Sale Stock Secondary Unit", + "summary": "Get product quantities in a secondary unit", + "version": "16.0.1.0.0", + "development_status": "Production/Stable", + "category": "stock", + "website": "https://github.com/OCA/sale-workflow", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["sale_order_secondary_unit", "stock_secondary_unit"], + "auto_install": True, +} diff --git a/sale_stock_secondary_unit/i18n/de.po b/sale_stock_secondary_unit/i18n/de.po new file mode 100644 index 00000000000..95addc15dda --- /dev/null +++ b/sale_stock_secondary_unit/i18n/de.po @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: de\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" + +#. module: sale_stock_secondary_unit +#: model:ir.model,name:sale_stock_secondary_unit.model_stock_rule +msgid "Stock Rule" +msgstr "" diff --git a/sale_stock_secondary_unit/i18n/es.po b/sale_stock_secondary_unit/i18n/es.po new file mode 100644 index 00000000000..185fc1feab8 --- /dev/null +++ b/sale_stock_secondary_unit/i18n/es.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-27 10:19+0000\n" +"Last-Translator: Daniel Martinez Vila \n" +"Language-Team: none\n" +"Language: es\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 3.10\n" + +#. module: sale_stock_secondary_unit +#: model:ir.model,name:sale_stock_secondary_unit.model_stock_rule +msgid "Stock Rule" +msgstr "Regla de stock" diff --git a/sale_stock_secondary_unit/i18n/it.po b/sale_stock_secondary_unit/i18n/it.po new file mode 100644 index 00000000000..e4952a23792 --- /dev/null +++ b/sale_stock_secondary_unit/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-06 17:10+0000\n" +"Last-Translator: Francesco Foresti \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 4.17\n" + +#. module: sale_stock_secondary_unit +#: model:ir.model,name:sale_stock_secondary_unit.model_stock_rule +msgid "Stock Rule" +msgstr "Regola di giacenza" diff --git a/sale_stock_secondary_unit/i18n/sale_stock_secondary_unit.pot b/sale_stock_secondary_unit/i18n/sale_stock_secondary_unit.pot new file mode 100644 index 00000000000..12cc94dabc8 --- /dev/null +++ b/sale_stock_secondary_unit/i18n/sale_stock_secondary_unit.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: sale_stock_secondary_unit +#: model:ir.model,name:sale_stock_secondary_unit.model_stock_rule +msgid "Stock Rule" +msgstr "" diff --git a/sale_stock_secondary_unit/i18n/zh_CN.po b/sale_stock_secondary_unit/i18n/zh_CN.po new file mode 100644 index 00000000000..405560cef4b --- /dev/null +++ b/sale_stock_secondary_unit/i18n/zh_CN.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_secondary_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Tony Gu\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_stock_secondary_unit +#: model:ir.model,name:sale_stock_secondary_unit.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#~ msgid "Procurement Rule" +#~ msgstr "补货规则" diff --git a/sale_stock_secondary_unit/models/__init__.py b/sale_stock_secondary_unit/models/__init__.py new file mode 100644 index 00000000000..b57efdd1e62 --- /dev/null +++ b/sale_stock_secondary_unit/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import stock_rule diff --git a/sale_stock_secondary_unit/models/stock_rule.py b/sale_stock_secondary_unit/models/stock_rule.py new file mode 100644 index 00000000000..990b9632e58 --- /dev/null +++ b/sale_stock_secondary_unit/models/stock_rule.py @@ -0,0 +1,44 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + def _get_stock_move_values( + self, + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + ): + res = super()._get_stock_move_values( + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + ) + sale_line_id = values.get("sale_line_id", False) + # Record can be a sale order line or a stock move depending of pull + # and push rules + if sale_line_id: + record = self.env["sale.order.line"].browse(sale_line_id) + else: + record = values.get("move_dest_ids", self.env["stock.move"].browse())[:1] + if record and record.secondary_uom_id: + res.update( + { + "secondary_uom_id": record.secondary_uom_id.id, + "secondary_uom_qty": record.secondary_uom_qty, + } + ) + return res diff --git a/sale_stock_secondary_unit/readme/CONTRIBUTORS.rst b/sale_stock_secondary_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..5b7daa8b552 --- /dev/null +++ b/sale_stock_secondary_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Carlos Dauden +* Sergio Teruel +* Tony Gu diff --git a/sale_stock_secondary_unit/readme/DESCRIPTION.rst b/sale_stock_secondary_unit/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..8442eeb8caa --- /dev/null +++ b/sale_stock_secondary_unit/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module extends the functionality of stock secondary unit module and +sale_order_secondary_unit to allow copy secondary sale data to stock move when +a sale order is confirmed. diff --git a/sale_stock_secondary_unit/readme/USAGE.rst b/sale_stock_secondary_unit/readme/USAGE.rst new file mode 100644 index 00000000000..5b8ec66bad3 --- /dev/null +++ b/sale_stock_secondary_unit/readme/USAGE.rst @@ -0,0 +1,8 @@ +To use this module you need to: + +#. Go to a *Product > General Information tab*. +#. Create any record in "Secondary unit of measure". +#. Set the conversion factor. +#. Go to *Sale > Quotation* and create a sale order with this product. +#. Confirm the sale order. +#. Go to picking from this sale order, you will see secondary unit information. diff --git a/sale_stock_secondary_unit/static/description/icon.png b/sale_stock_secondary_unit/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_stock_secondary_unit/static/description/icon.png differ diff --git a/sale_stock_secondary_unit/static/description/index.html b/sale_stock_secondary_unit/static/description/index.html new file mode 100644 index 00000000000..42d25d2fdf6 --- /dev/null +++ b/sale_stock_secondary_unit/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +Sale Stock Secondary Unit + + + +
+

Sale Stock Secondary Unit

+ + +

Production/Stable License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This module extends the functionality of stock secondary unit module and +sale_order_secondary_unit to allow copy secondary sale data to stock move when +a sale order is confirmed.

+

Table of contents

+ +
+

Usage

+

To use this module you need to:

+
    +
  1. Go to a Product > General Information tab.
  2. +
  3. Create any record in “Secondary unit of measure”.
  4. +
  5. Set the conversion factor.
  6. +
  7. Go to Sale > Quotation and create a sale order with this product.
  8. +
  9. Confirm the sale order.
  10. +
  11. Go to picking from this sale order, you will see secondary unit information.
  12. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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.

+

This module is part of the OCA/sale-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/sale_stock_secondary_unit/tests/__init__.py b/sale_stock_secondary_unit/tests/__init__.py new file mode 100644 index 00000000000..7917dbdb9cd --- /dev/null +++ b/sale_stock_secondary_unit/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_sale_stock_secondary_unit diff --git a/sale_stock_secondary_unit/tests/test_sale_stock_secondary_unit.py b/sale_stock_secondary_unit/tests/test_sale_stock_secondary_unit.py new file mode 100644 index 00000000000..3579f90421e --- /dev/null +++ b/sale_stock_secondary_unit/tests/test_sale_stock_secondary_unit.py @@ -0,0 +1,92 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestSaleStockOrderSecondaryUnit(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Remove this variable in v16 and put instead: + # from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + DISABLED_MAIL_CONTEXT = { + "tracking_disable": True, + "mail_create_nolog": True, + "mail_create_nosubscribe": True, + "mail_notrack": True, + "no_reset_password": True, + } + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.product_uom_kg = cls.env.ref("uom.product_uom_kgm") + cls.product_uom_gram = cls.env.ref("uom.product_uom_gram") + cls.product_uom_unit = cls.env.ref("uom.product_uom_unit") + cls.product = cls.env["product.product"].create( + { + "name": "test", + "type": "product", + "uom_id": cls.product_uom_kg.id, + "uom_po_id": cls.product_uom_kg.id, + } + ) + # Set secondary uom on product template + cls.product.product_tmpl_id.write( + { + "secondary_uom_ids": [ + ( + 0, + 0, + { + "name": "unit-700", + "uom_id": cls.product_uom_unit.id, + "factor": 0.7, + }, + ) + ], + } + ) + StockQuant = cls.env["stock.quant"] + StockQuant.create( + { + "product_id": cls.product.id, + "location_id": cls.warehouse.lot_stock_id.id, + "quantity": 2000, + } + ) + cls.secondary_unit = cls.env["product.secondary.unit"].search( + [("product_tmpl_id", "=", cls.product.product_tmpl_id.id)] + ) + cls.product.sale_secondary_uom_id = cls.secondary_unit.id + cls.partner = cls.env["res.partner"].create({"name": "test - partner"}) + so = cls.env["sale.order"].new( + { + "partner_id": cls.partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": cls.product.name, + "product_id": cls.product.id, + "product_uom_qty": 1, + "product_uom": cls.product.uom_id.id, + "price_unit": 1000.00, + }, + ) + ], + "pricelist_id": cls.env.ref("product.list0").id, + } + ) + so.onchange_partner_id() + cls.order = cls.env["sale.order"].create(so._convert_to_write(so._cache)) + + def test_stock_move_line_secondary_unit(self): + self.order.order_line.write( + {"secondary_uom_id": self.secondary_unit.id, "secondary_uom_qty": 5} + ) + self.order.order_line._onchange_helper_product_uom_for_secondary() + self.order.action_confirm() + picking = self.order.picking_ids + # Second qty on sml only manage done quantities + self.assertEqual(picking.move_line_ids.secondary_uom_qty, 0.0) diff --git a/setup/sale_stock_secondary_unit/odoo/addons/sale_stock_secondary_unit b/setup/sale_stock_secondary_unit/odoo/addons/sale_stock_secondary_unit new file mode 120000 index 00000000000..63f8d8db26d --- /dev/null +++ b/setup/sale_stock_secondary_unit/odoo/addons/sale_stock_secondary_unit @@ -0,0 +1 @@ +../../../../sale_stock_secondary_unit \ No newline at end of file diff --git a/setup/sale_stock_secondary_unit/setup.py b/setup/sale_stock_secondary_unit/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/sale_stock_secondary_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)