diff --git a/purchase_request_to_requisition_operating_unit/README.rst b/purchase_request_to_requisition_operating_unit/README.rst new file mode 100644 index 0000000000..33789523ac --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/README.rst @@ -0,0 +1,80 @@ +====================================================== +Purchase Request to Call for Bids with Operating Units +====================================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Foperating--unit-lightgray.png?logo=github + :target: https://github.com/OCA/operating-unit/tree/14.0/purchase_request_to_requisition_operating_unit + :alt: OCA/operating-unit +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/operating-unit-14-0/operating-unit-14-0-purchase_request_to_requisition_operating_unit + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/213/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module introduces the following features: + +* This module pass the Operating Unit from the purchase request to the purchase agreement + +**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 +~~~~~~~ + +* Forgeflow +* Ecosoft +* Serpent Consulting Services Pvt. Ltd. + +Contributors +~~~~~~~~~~~~ + +* Jordi Ballester Alomar +* Aaron Henriquez +* Serpent Consulting Services Pvt. Ltd. +* Kitti U. + +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/operating-unit `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_request_to_requisition_operating_unit/__init__.py b/purchase_request_to_requisition_operating_unit/__init__.py new file mode 100644 index 0000000000..6c41567f38 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/__init__.py @@ -0,0 +1,4 @@ +# © 2016 Forgeflow S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. + +from . import wizard diff --git a/purchase_request_to_requisition_operating_unit/__manifest__.py b/purchase_request_to_requisition_operating_unit/__manifest__.py new file mode 100644 index 0000000000..99aec7a19d --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/__manifest__.py @@ -0,0 +1,20 @@ +# © 2016 Forgeflow S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Request to Call for Bids with Operating Units", + "version": "15.0.1.0.0", + "author": "Forgeflow,Ecosoft," + "Serpent Consulting Services Pvt. Ltd.," + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/operating-unit", + "category": "Purchase Management", + "depends": [ + "purchase_request_to_requisition", + "purchase_request_operating_unit", + "purchase_requisition_operating_unit", + ], + "installable": True, +} diff --git a/purchase_request_to_requisition_operating_unit/i18n/purchase_request_to_requisition_operating_unit.pot b/purchase_request_to_requisition_operating_unit/i18n/purchase_request_to_requisition_operating_unit.pot new file mode 100644 index 0000000000..03fd99f161 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/i18n/purchase_request_to_requisition_operating_unit.pot @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_to_requisition_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: purchase_request_to_requisition_operating_unit +#: code:addons/purchase_request_to_requisition_operating_unit/wizard/purchase_request_line_make_purchase_requisition.py:0 +#, python-format +msgid "Could not process !" +msgstr "" + +#. module: purchase_request_to_requisition_operating_unit +#: model:ir.model.fields,field_description:purchase_request_to_requisition_operating_unit.field_purchase_request_line_make_purchase_requisition__display_name +msgid "Display Name" +msgstr "" + +#. module: purchase_request_to_requisition_operating_unit +#: model:ir.model.fields,field_description:purchase_request_to_requisition_operating_unit.field_purchase_request_line_make_purchase_requisition__id +msgid "ID" +msgstr "" + +#. module: purchase_request_to_requisition_operating_unit +#: model:ir.model.fields,field_description:purchase_request_to_requisition_operating_unit.field_purchase_request_line_make_purchase_requisition____last_update +msgid "Last Modified on" +msgstr "" + +#. module: purchase_request_to_requisition_operating_unit +#: model:ir.model.fields,field_description:purchase_request_to_requisition_operating_unit.field_purchase_request_line_make_purchase_requisition__operating_unit_id +msgid "Operating Unit" +msgstr "" + +#. module: purchase_request_to_requisition_operating_unit +#: model:ir.model,name:purchase_request_to_requisition_operating_unit.model_purchase_request_line_make_purchase_requisition +msgid "Purchase Request Line Make Purchase Agreement" +msgstr "" + +#. module: purchase_request_to_requisition_operating_unit +#: code:addons/purchase_request_to_requisition_operating_unit/wizard/purchase_request_line_make_purchase_requisition.py:0 +#, python-format +msgid "You have to select lines from the same operating unit." +msgstr "" diff --git a/purchase_request_to_requisition_operating_unit/readme/CONTRIBUTORS.rst b/purchase_request_to_requisition_operating_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..4e39cff197 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Jordi Ballester Alomar +* Aaron Henriquez +* Serpent Consulting Services Pvt. Ltd. +* Kitti U. +* Saran Lim. diff --git a/purchase_request_to_requisition_operating_unit/readme/DESCRIPTION.rst b/purchase_request_to_requisition_operating_unit/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..14eacc3155 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module introduces the following features: + +* This module pass the Operating Unit from the purchase request to the purchase agreement diff --git a/purchase_request_to_requisition_operating_unit/static/description/icon.png b/purchase_request_to_requisition_operating_unit/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/purchase_request_to_requisition_operating_unit/static/description/icon.png differ diff --git a/purchase_request_to_requisition_operating_unit/static/description/index.html b/purchase_request_to_requisition_operating_unit/static/description/index.html new file mode 100644 index 0000000000..733f50f1d8 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Purchase Request to Call for Bids with Operating Units + + + +
+

Purchase Request to Call for Bids with Operating Units

+ + +

Beta License: AGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runbot

+

This module introduces the following features:

+
    +
  • This module pass the Operating Unit from the purchase request to the purchase agreement
  • +
+

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

+
    +
  • Forgeflow
  • +
  • Ecosoft
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+
+

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/operating-unit project on GitHub.

+

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

+
+
+
+ + diff --git a/purchase_request_to_requisition_operating_unit/tests/__init__.py b/purchase_request_to_requisition_operating_unit/tests/__init__.py new file mode 100644 index 0000000000..9557b31cb3 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/tests/__init__.py @@ -0,0 +1,4 @@ +# © 2016 Forgeflow S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. + +from . import test_purchase_request_to_requisition_operating_unit diff --git a/purchase_request_to_requisition_operating_unit/tests/test_purchase_request_to_requisition_operating_unit.py b/purchase_request_to_requisition_operating_unit/tests/test_purchase_request_to_requisition_operating_unit.py new file mode 100644 index 0000000000..9627189cef --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/tests/test_purchase_request_to_requisition_operating_unit.py @@ -0,0 +1,79 @@ +# © 2016 Forgeflow S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import SUPERUSER_ID +from odoo.exceptions import UserError +from odoo.tests.common import Form, TransactionCase + + +class TestPurchaseRequestToRequisition(TransactionCase): + def setUp(self): + super(TestPurchaseRequestToRequisition, self).setUp() + self.purchase_request = self.env["purchase.request"] + self.purchase_request_line_obj = self.env["purchase.request.line"] + self.wiz = self.env["purchase.request.line.make.purchase.requisition"] + self.purchase_order = self.env["purchase.order"] + # Main Operating Unit + self.ou1 = self.env.ref("operating_unit.main_operating_unit") + # B2C Operating Unit + self.b2c = self.env.ref("operating_unit.b2c_operating_unit") + # Products + self.product1 = self.env.ref("product.product_product_9") + self.purchase_request = self._create_purchase_request() + + def _create_purchase_request(self): + vals = { + "picking_type_id": self.env.ref("stock.picking_type_in").id, + "requested_by": SUPERUSER_ID, + "operating_unit_id": self.ou1.id, + "line_ids": [ + ( + 0, + 0, + { + "product_id": self.product1.id, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + "product_qty": 5.0, + }, + ) + ], + } + return self.purchase_request.create(vals) + + def test_purchase_request_to_purchase_requisition(self): + # Test multi purchase request with diff operating unit + self.purchase_request2 = self._create_purchase_request() + picking_type = self.env["stock.picking.type"].search( + [ + ("code", "=", "incoming"), + ("warehouse_id.operating_unit_id", "=", self.b2c.id), + ], + limit=1, + ) + with Form(self.purchase_request2) as pr: + pr.picking_type_id = picking_type + pr.operating_unit_id = self.b2c + pr.save() + self.purchase_request_line = self.purchase_request.line_ids + # Lines with difference ou, should error + with self.assertRaises(UserError): + self.wiz.with_context( + active_model="purchase.request.line", + active_ids=[ + self.purchase_request_line.id, + self.purchase_request2.line_ids.id, + ], + ).create({}) + # Check send context with purchase.request + wiz = self.wiz.with_context( + active_model="purchase.request", + active_ids=[self.purchase_request.id], + ).create({}) + wiz.make_purchase_requisition() + requisition_id = self.purchase_request_line.requisition_lines.requisition_id + self.assertEqual( + requisition_id.operating_unit_id, + self.purchase_request_line.operating_unit_id, + "Should have the same Operating Unit", + ) diff --git a/purchase_request_to_requisition_operating_unit/wizard/__init__.py b/purchase_request_to_requisition_operating_unit/wizard/__init__.py new file mode 100644 index 0000000000..a0aa5e3313 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/wizard/__init__.py @@ -0,0 +1,4 @@ +# © 2016 Forgeflow S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. + +from . import purchase_request_line_make_purchase_requisition diff --git a/purchase_request_to_requisition_operating_unit/wizard/purchase_request_line_make_purchase_requisition.py b/purchase_request_to_requisition_operating_unit/wizard/purchase_request_line_make_purchase_requisition.py new file mode 100644 index 0000000000..2a124733e4 --- /dev/null +++ b/purchase_request_to_requisition_operating_unit/wizard/purchase_request_line_make_purchase_requisition.py @@ -0,0 +1,56 @@ +# © 2016 Forgeflow S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class PurchaseRequestLineMakePurchaseRequisition(models.TransientModel): + _inherit = "purchase.request.line.make.purchase.requisition" + + operating_unit_id = fields.Many2one( + "operating.unit", + string="Operating Unit", + readonly=True, + ) + + @api.model + def default_get(self, fields): + res = super().default_get(fields) + # By default, expect called from PR Line + request_line_obj = self.env["purchase.request.line"] + request_line_ids = self.env.context.get("active_ids") + active_model = self.env.context.get("active_model") + # For case called from PR + if active_model == "purchase.request": + request_ids = self.env.context.get("active_ids") + requests = self.env["purchase.request"].browse(request_ids) + request_line_ids = requests.mapped("line_ids").ids + active_model = "purchase.request.line" + operating_unit_id = False + for line in request_line_obj.browse(request_line_ids): + line_operating_unit_id = ( + line.request_id.operating_unit_id + and line.request_id.operating_unit_id.id + or False + ) + if operating_unit_id and line_operating_unit_id != operating_unit_id: + raise UserError( + _( + "Could not process!\ + \nYou have to select lines from the same operating unit." + ), + ) + else: + operating_unit_id = line_operating_unit_id + res["operating_unit_id"] = operating_unit_id + return res + + @api.model + def _prepare_purchase_requisition(self, item, picking_type_id, company_id): + res = super( + PurchaseRequestLineMakePurchaseRequisition, self + )._prepare_purchase_requisition(item, picking_type_id, company_id) + if self.operating_unit_id: + res.update({"operating_unit_id": self.operating_unit_id.id}) + return res diff --git a/setup/purchase_request_to_requisition_operating_unit/odoo/addons/purchase_request_to_requisition_operating_unit b/setup/purchase_request_to_requisition_operating_unit/odoo/addons/purchase_request_to_requisition_operating_unit new file mode 120000 index 0000000000..ba8fd1d714 --- /dev/null +++ b/setup/purchase_request_to_requisition_operating_unit/odoo/addons/purchase_request_to_requisition_operating_unit @@ -0,0 +1 @@ +../../../../purchase_request_to_requisition_operating_unit \ No newline at end of file diff --git a/setup/purchase_request_to_requisition_operating_unit/setup.py b/setup/purchase_request_to_requisition_operating_unit/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/purchase_request_to_requisition_operating_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)