diff --git a/setup/stock_orderpoint_manual_procurement_uom/odoo/addons/stock_orderpoint_manual_procurement_uom b/setup/stock_orderpoint_manual_procurement_uom/odoo/addons/stock_orderpoint_manual_procurement_uom new file mode 120000 index 000000000..be5ae9eaa --- /dev/null +++ b/setup/stock_orderpoint_manual_procurement_uom/odoo/addons/stock_orderpoint_manual_procurement_uom @@ -0,0 +1 @@ +../../../../stock_orderpoint_manual_procurement_uom \ No newline at end of file diff --git a/setup/stock_orderpoint_manual_procurement_uom/setup.py b/setup/stock_orderpoint_manual_procurement_uom/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_orderpoint_manual_procurement_uom/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_orderpoint_manual_procurement_uom/README.rst b/stock_orderpoint_manual_procurement_uom/README.rst new file mode 100644 index 000000000..8409a7eac --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/README.rst @@ -0,0 +1,83 @@ +======================================= +Stock Orderpoint Manual Procurement UoM +======================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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/13.0/stock_orderpoint_manual_procurement_uom + :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-13-0/stock-logistics-warehouse-13-0-stock_orderpoint_manual_procurement_uom + :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/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module for ``stock_orderpoint_uom`` and +``stock_orderpoint_manual_procurement`` + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +The recommended quantity to procure is adjusted to the procurement unit of +measure indicated in the reordering rule. + +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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Lois Rilo Antelo +* Bhavesh Odedra +* Kitti Upariphutthiphong +* Pimolnat Suntian + +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_orderpoint_manual_procurement_uom/__init__.py b/stock_orderpoint_manual_procurement_uom/__init__.py new file mode 100644 index 000000000..e1e144406 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from . import wizards diff --git a/stock_orderpoint_manual_procurement_uom/__manifest__.py b/stock_orderpoint_manual_procurement_uom/__manifest__.py new file mode 100644 index 000000000..4c434ecec --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2018-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Orderpoint Manual Procurement UoM", + "summary": "Glue module for stock_orderpoint_uom and " + "stock_orderpoint_manual_procurement", + "version": "14.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse Management", + "depends": ["stock_orderpoint_uom", "stock_orderpoint_manual_procurement"], + "license": "AGPL-3", + "installable": True, + "application": False, +} diff --git a/stock_orderpoint_manual_procurement_uom/i18n/stock_orderpoint_manual_procurement_uom.pot b/stock_orderpoint_manual_procurement_uom/i18n/stock_orderpoint_manual_procurement_uom.pot new file mode 100644 index 000000000..3eae69372 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/i18n/stock_orderpoint_manual_procurement_uom.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_manual_procurement_uom +# +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_orderpoint_manual_procurement_uom +#: model:ir.model,name:stock_orderpoint_manual_procurement_uom.model_make_procurement_orderpoint_item +msgid "Make Procurements from Orderpoint Item" +msgstr "" + +#. module: stock_orderpoint_manual_procurement_uom +#: model:ir.model,name:stock_orderpoint_manual_procurement_uom.model_make_procurement_orderpoint +msgid "Make Procurements from Orderpoints" +msgstr "" + +#. module: stock_orderpoint_manual_procurement_uom +#: model:ir.model,name:stock_orderpoint_manual_procurement_uom.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "" diff --git a/stock_orderpoint_manual_procurement_uom/i18n/zh_CN.po b/stock_orderpoint_manual_procurement_uom/i18n/zh_CN.po new file mode 100644 index 000000000..a7a483f49 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/i18n/zh_CN.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_manual_procurement_uom +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-10-12 16:36+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: stock_orderpoint_manual_procurement_uom +#: model:ir.model,name:stock_orderpoint_manual_procurement_uom.model_make_procurement_orderpoint_item +msgid "Make Procurements from Orderpoint Item" +msgstr "从订单点项进行补货" + +#. module: stock_orderpoint_manual_procurement_uom +#: model:ir.model,name:stock_orderpoint_manual_procurement_uom.model_make_procurement_orderpoint +msgid "Make Procurements from Orderpoints" +msgstr "从订单点项进行补货" + +#. module: stock_orderpoint_manual_procurement_uom +#: model:ir.model,name:stock_orderpoint_manual_procurement_uom.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "最小库存规则" diff --git a/stock_orderpoint_manual_procurement_uom/models/__init__.py b/stock_orderpoint_manual_procurement_uom/models/__init__.py new file mode 100644 index 000000000..14b7c7a48 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import stock_warehouse_orderpoint diff --git a/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py b/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py new file mode 100644 index 000000000..4675ce0e2 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py @@ -0,0 +1,18 @@ +# Copyright 2018-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class StockWarehouseOrderpoint(models.Model): + _inherit = "stock.warehouse.orderpoint" + + def _get_procure_recommended_qty(self, virtual_qty, op_qtys): + product_qty = super( + StockWarehouseOrderpoint, self + )._get_procure_recommended_qty(virtual_qty, op_qtys) + if self.procure_uom_id: + product_qty = self.product_id.uom_id._compute_quantity( + product_qty, self.procure_uom_id + ) + return product_qty diff --git a/stock_orderpoint_manual_procurement_uom/readme/CONTRIBUTORS.rst b/stock_orderpoint_manual_procurement_uom/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..1d4f33339 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Lois Rilo Antelo +* Bhavesh Odedra +* Kitti Upariphutthiphong +* Pimolnat Suntian diff --git a/stock_orderpoint_manual_procurement_uom/readme/DESCRIPTION.rst b/stock_orderpoint_manual_procurement_uom/readme/DESCRIPTION.rst new file mode 100644 index 000000000..7311361bf --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Glue module for ``stock_orderpoint_uom`` and +``stock_orderpoint_manual_procurement`` diff --git a/stock_orderpoint_manual_procurement_uom/readme/USAGE.rst b/stock_orderpoint_manual_procurement_uom/readme/USAGE.rst new file mode 100644 index 000000000..2088fa8ac --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/readme/USAGE.rst @@ -0,0 +1,2 @@ +The recommended quantity to procure is adjusted to the procurement unit of +measure indicated in the reordering rule. diff --git a/stock_orderpoint_manual_procurement_uom/static/description/icon.png b/stock_orderpoint_manual_procurement_uom/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_orderpoint_manual_procurement_uom/static/description/icon.png differ diff --git a/stock_orderpoint_manual_procurement_uom/static/description/index.html b/stock_orderpoint_manual_procurement_uom/static/description/index.html new file mode 100644 index 000000000..834ea3b87 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +Stock Orderpoint Manual Procurement UoM + + + +
+

Stock Orderpoint Manual Procurement UoM

+ + +

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

+

Glue module for stock_orderpoint_uom and +stock_orderpoint_manual_procurement

+

Table of contents

+ +
+

Usage

+

The recommended quantity to procure is adjusted to the procurement unit of +measure indicated in the reordering rule.

+
+
+

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

+
    +
  • ForgeFlow
  • +
+
+
+

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/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_orderpoint_manual_procurement_uom/tests/__init__.py b/stock_orderpoint_manual_procurement_uom/tests/__init__.py new file mode 100644 index 000000000..7d9283684 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_stock_orderpoint_manual_procurement diff --git a/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py b/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py new file mode 100644 index 000000000..927ee9749 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py @@ -0,0 +1,161 @@ +# Copyright 2018-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestStockWarehouseOrderpoint(common.TransactionCase): + def setUp(self): + super(TestStockWarehouseOrderpoint, self).setUp() + + # Refs + self.group_stock_manager = self.env.ref("stock.group_stock_manager") + self.group_purchase_manager = self.env.ref("purchase.group_purchase_manager") + self.vendor = self.env.ref( + "stock_orderpoint_manual_procurement.product_supplierinfo_product_7" + ) # noqa + self.group_change_procure_qty = self.env.ref( + "stock_orderpoint_manual_procurement." "group_change_orderpoint_procure_qty" + ) + self.company1 = self.env.ref("base.main_company") + + # Get required Model + self.reordering_rule_model = self.env["stock.warehouse.orderpoint"] + self.product_model = self.env["product.product"] + self.purchase_model = self.env["purchase.order"] + self.purchase_line_model = self.env["purchase.order.line"] + self.user_model = self.env["res.users"] + self.product_ctg_model = self.env["product.category"] + self.stock_change_model = self.env["stock.change.product.qty"] + self.make_procurement_orderpoint_model = self.env["make.procurement.orderpoint"] + + # Create users + self.user = self._create_user( + "user_1", + [ + self.group_stock_manager, + self.group_change_procure_qty, + self.group_purchase_manager, + ], + self.company1, + ) + # Get required Model data + self.product_uom = self.env.ref("uom.product_uom_unit") + self.location = self.env.ref("stock.stock_location_stock") + self.product = self.env.ref("product.product_product_7") + self.dozen = self.env.ref("uom.product_uom_dozen") + + # Create Product category and Product + self.product_ctg = self._create_product_category() + self.product = self._create_product() + + # Add default quantity + quantity = 20.00 + self._update_product_qty(self.product, quantity) + + # Create Reordering Rule + self.reorder = self.create_orderpoint() + + def _create_user(self, login, groups, company): + """ Create a user.""" + group_ids = [group.id for group in groups] + user = self.user_model.with_context({"no_reset_password": True}).create( + { + "name": "Test User", + "login": login, + "password": "demo", + "email": "test@yourcompany.com", + "company_id": company.id, + "company_ids": [(4, company.id)], + "groups_id": [(6, 0, group_ids)], + } + ) + return user + + def _create_product_category(self): + """Create a Product Category.""" + product_ctg = self.product_ctg_model.create({"name": "test_product_ctg"}) + return product_ctg + + def _create_product(self): + """Create a Product.""" + product = self.product_model.create( + { + "name": "Test Product", + "categ_id": self.product_ctg.id, + "type": "product", + "uom_id": self.product_uom.id, + "variant_seller_ids": [(6, 0, [self.vendor.id])], + } + ) + return product + + def _update_product_qty(self, product, quantity): + """Update Product quantity.""" + change_product_qty = self.stock_change_model.create( + { + "product_id": product.id, + "product_tmpl_id": product.product_tmpl_id.id, + "new_quantity": quantity, + } + ) + change_product_qty.change_product_qty() + return change_product_qty + + def create_orderpoint(self): + """Create a Reordering Rule""" + reorder = self.reordering_rule_model.with_user(self.user).create( + { + "name": "Order-point", + "product_id": self.product.id, + "product_min_qty": 100.0, + "product_max_qty": 500.0, + "qty_multiple": 1.0, + "procure_uom_id": self.dozen.id, + } + ) + return reorder + + def create_orderpoint_procurement(self): + """Make Procurement from Reordering Rule""" + context = { + "active_model": "stock.warehouse.orderpoint", + "active_ids": self.reorder.ids, + "active_id": self.reorder.id, + } + wizard = ( + self.make_procurement_orderpoint_model.with_user(self.user) + .with_context(context) + .create({}) + ) + for line in wizard.item_ids: + line.onchange_uom_id() + wizard.make_procurement() + return wizard + + def test_security(self): + """Test Manual Procurement created from Order-Point""" + + # Create Manual Procurement from order-point procured quantity + self.create_orderpoint_procurement() + + # As per route configuration, it will create Purchase order + # Assert that Procurement is created with the desired quantity + purchase = self.purchase_model.search([("origin", "ilike", self.reorder.name)]) + self.assertEquals(len(purchase), 1) + purchase_line = self.purchase_line_model.search( + [("orderpoint_id", "=", self.reorder.id), ("order_id", "=", purchase.id)] + ) + self.assertEquals(len(purchase_line), 1) + self.assertEqual(self.reorder.product_id.id, purchase_line.product_id.id) + # it could be using an existing PO, thus there could be more origins. + self.assertTrue(self.reorder.name in purchase.origin) + self.assertNotEqual( + self.reorder.procure_recommended_qty, purchase_line.product_qty + ) + if self.reorder.procure_uom_id == self.reorder.product_id.uom_po_id: + # Our PO unit of measure is also dozens (procure uom) + self.assertEqual(purchase_line.product_qty, 40) + else: + # PO unit of measure is units, not the same as procure uom. + self.assertEqual(purchase_line.product_qty, 480) diff --git a/stock_orderpoint_manual_procurement_uom/wizards/__init__.py b/stock_orderpoint_manual_procurement_uom/wizards/__init__.py new file mode 100644 index 000000000..79fe40f10 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import make_procurement_orderpoint diff --git a/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py b/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py new file mode 100644 index 000000000..09c0a12a0 --- /dev/null +++ b/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py @@ -0,0 +1,28 @@ +# Copyright 2018-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class MakeProcurementOrderpoint(models.TransientModel): + _inherit = "make.procurement.orderpoint" + + @api.model + def _prepare_item(self, orderpoint): + vals = super(MakeProcurementOrderpoint, self)._prepare_item(orderpoint) + if orderpoint.procure_uom_id: + product_uom = orderpoint.procure_uom_id + vals["uom_id"] = product_uom.id + return vals + + +class MakeProcurementOrderpointItem(models.TransientModel): + _inherit = "make.procurement.orderpoint.item" + + @api.onchange("uom_id") + def onchange_uom_id(self): + for rec in self: + uom = rec.orderpoint_id.procure_uom_id or rec.orderpoint_id.product_uom + rec.qty = uom._compute_quantity( + rec.orderpoint_id.procure_recommended_qty, rec.uom_id + )