diff --git a/README.md b/README.md index 72a37bf8705..b0283c3bd0b 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ addon | version | maintainers | summary [purchase_reception_notify](purchase_reception_notify/) | 17.0.1.0.1 | | Purchase Reception Notify [purchase_request](purchase_request/) | 17.0.1.3.1 | | Use this module to have notification of requirements of materials and/or external services and keep track of such requirements. [purchase_request_tier_validation](purchase_request_tier_validation/) | 17.0.1.0.0 | | Extends the functionality of Purchase Requests to support a tier validation process. +[purchase_requisition_multiple_vendor](purchase_requisition_multiple_vendor/) | 17.0.1.0.0 | | Create multiple purchase alternatives for different vendors using the same wizard. [purchase_requisition_tier_validation](purchase_requisition_tier_validation/) | 17.0.1.0.0 | | Extends the functionality of Purchase Agreements to support a tier validation process. [purchase_sale_link_by_origin](purchase_sale_link_by_origin/) | 17.0.1.0.0 | | Link PO/SO by the PO's Origin in addition to the default behavior that only links them by their lines [purchase_security](purchase_security/) | 17.0.1.0.1 | [![pilarvargas-tecnativa](https://github.com/pilarvargas-tecnativa.png?size=30px)](https://github.com/pilarvargas-tecnativa) | See only your purchase orders diff --git a/purchase_mass_mail/i18n/it.po b/purchase_mass_mail/i18n/it.po index c0e994bf476..9df98a9400f 100644 --- a/purchase_mass_mail/i18n/it.po +++ b/purchase_mass_mail/i18n/it.po @@ -6,32 +6,34 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2025-02-19 12:06+0000\n" +"Last-Translator: mymage \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 5.6.2\n" #. module: purchase_mass_mail #: model:ir.model,name:purchase_mass_mail.model_mail_compose_message msgid "Email composition wizard" -msgstr "" +msgstr "Procedura guidata creazione e-mail" #. module: purchase_mass_mail #. odoo-python #: code:addons/purchase_mass_mail/models/purchase_order.py:0 #, python-format msgid "Mass mailing for purchases" -msgstr "" +msgstr "E-mail di massa per acquisti" #. module: purchase_mass_mail #: model:ir.model,name:purchase_mass_mail.model_purchase_order msgid "Purchase Order" -msgstr "" +msgstr "Ordine di acquisto" #. module: purchase_mass_mail #: model:ir.actions.server,name:purchase_mass_mail.action_purchase_order_mass_send msgid "Send email to selected purchases" -msgstr "" +msgstr "Invia e-mail ad acquisti selezionati" diff --git a/purchase_requisition_multiple_vendor/README.rst b/purchase_requisition_multiple_vendor/README.rst new file mode 100644 index 00000000000..1fbfbd97968 --- /dev/null +++ b/purchase_requisition_multiple_vendor/README.rst @@ -0,0 +1,89 @@ +==================================== +Purchase Requisition Multiple Vendor +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0304960fe226651525a51fcad3aecca28f88d9c167978ed29506c40dd265b6ee + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/17.0/purchase_requisition_multiple_vendor + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-17-0/purchase-workflow-17-0-purchase_requisition_multiple_vendor + :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/purchase-workflow&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This modules allows to select multiple vendors in the "Create +Alternative" wizard in purchase orders, so multiple alternatives can be +created altogether. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +- Click on the "Create Alternative" in the "Alternatives" tab in a + purchase order. +- Select as many vendors as needed in the "Partners" field. A purchase + order alternative will be created for each selected partner. + +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 +------- + +* Sygel + +Contributors +------------ + +- Manuel Regidor manuel.regidor@sygel.es +- Valentin Vinagre valentin.vinagre@sygel.es + +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/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_requisition_multiple_vendor/__init__.py b/purchase_requisition_multiple_vendor/__init__.py new file mode 100644 index 00000000000..40272379f72 --- /dev/null +++ b/purchase_requisition_multiple_vendor/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/purchase_requisition_multiple_vendor/__manifest__.py b/purchase_requisition_multiple_vendor/__manifest__.py new file mode 100644 index 00000000000..803b7edcec3 --- /dev/null +++ b/purchase_requisition_multiple_vendor/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2025 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Requisition Multiple Vendor", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Sygel, Odoo Community Association (OCA)", + "category": "Purchase", + "summary": """ + Create multiple purchase alternatives for different vendors + using the same wizard.""", + "website": "https://github.com/OCA/purchase-workflow", + "depends": [ + "purchase_requisition", + ], + "data": [ + "wizard/purchase_requisition_create_alternative.xml", + ], +} diff --git a/purchase_requisition_multiple_vendor/i18n/purchase_requisition_multiple_vendor.pot b/purchase_requisition_multiple_vendor/i18n/purchase_requisition_multiple_vendor.pot new file mode 100644 index 00000000000..d3da268e11c --- /dev/null +++ b/purchase_requisition_multiple_vendor/i18n/purchase_requisition_multiple_vendor.pot @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_requisition_multiple_vendor +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_requisition_multiple_vendor +#: model:ir.model.fields,help:purchase_requisition_multiple_vendor.field_purchase_requisition_create_alternative__partner_id +msgid "Choose a vendor for alternative PO" +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#: model:ir.model.fields,field_description:purchase_requisition_multiple_vendor.field_purchase_requisition_create_alternative__partner_ids +msgid "Partners" +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#. odoo-python +#: code:addons/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py:0 +#, python-format +msgid "Purchase Order Alternatives" +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#. odoo-python +#: code:addons/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py:0 +#, python-format +msgid "" +"The vendor you have selected or at least one of the products you are copying" +" from the original order has a blocking warning on it and cannot be selected" +" to create an alternative." +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#. odoo-python +#: code:addons/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py:0 +#, python-format +msgid "This is a blocking warning!\n" +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#: model:ir.model.fields,field_description:purchase_requisition_multiple_vendor.field_purchase_requisition_create_alternative__partner_id +msgid "Vendor" +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#. odoo-python +#: code:addons/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py:0 +#, python-format +msgid "" +"Warning for %(partner)s:\n" +"%(warning_message)s\n" +msgstr "" + +#. module: purchase_requisition_multiple_vendor +#: model:ir.model,name:purchase_requisition_multiple_vendor.model_purchase_requisition_create_alternative +msgid "Wizard to preset values for alternative PO" +msgstr "" diff --git a/purchase_requisition_multiple_vendor/pyproject.toml b/purchase_requisition_multiple_vendor/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_requisition_multiple_vendor/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_requisition_multiple_vendor/readme/CONTRIBUTORS.md b/purchase_requisition_multiple_vendor/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..32503b48df8 --- /dev/null +++ b/purchase_requisition_multiple_vendor/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Manuel Regidor +- Valentin Vinagre diff --git a/purchase_requisition_multiple_vendor/readme/DESCRIPTION.md b/purchase_requisition_multiple_vendor/readme/DESCRIPTION.md new file mode 100644 index 00000000000..dbf08642b64 --- /dev/null +++ b/purchase_requisition_multiple_vendor/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This modules allows to select multiple vendors in the "Create Alternative" wizard in purchase orders, so multiple alternatives can be created altogether. diff --git a/purchase_requisition_multiple_vendor/readme/USAGE.md b/purchase_requisition_multiple_vendor/readme/USAGE.md new file mode 100644 index 00000000000..a9420e6549b --- /dev/null +++ b/purchase_requisition_multiple_vendor/readme/USAGE.md @@ -0,0 +1,4 @@ +To use this module, you need to: + +- Click on the "Create Alternative" in the "Alternatives" tab in a purchase order. +- Select as many vendors as needed in the "Partners" field. A purchase order alternative will be created for each selected partner. diff --git a/purchase_requisition_multiple_vendor/static/description/icon.png b/purchase_requisition_multiple_vendor/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_requisition_multiple_vendor/static/description/icon.png differ diff --git a/purchase_requisition_multiple_vendor/static/description/index.html b/purchase_requisition_multiple_vendor/static/description/index.html new file mode 100644 index 00000000000..f3f1fc28d42 --- /dev/null +++ b/purchase_requisition_multiple_vendor/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +Purchase Requisition Multiple Vendor + + + +
+

Purchase Requisition Multiple Vendor

+ + +

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

This modules allows to select multiple vendors in the “Create +Alternative” wizard in purchase orders, so multiple alternatives can be +created altogether.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  • Click on the “Create Alternative” in the “Alternatives” tab in a +purchase order.
  • +
  • Select as many vendors as needed in the “Partners” field. A purchase +order alternative will be created for each selected partner.
  • +
+
+
+

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

+
    +
  • Sygel
  • +
+
+
+

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/purchase-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/purchase_requisition_multiple_vendor/tests/__init__.py b/purchase_requisition_multiple_vendor/tests/__init__.py new file mode 100644 index 00000000000..fbce0b0ca0b --- /dev/null +++ b/purchase_requisition_multiple_vendor/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_purchase_requisition_multiple_vendors diff --git a/purchase_requisition_multiple_vendor/tests/test_purchase_requisition_multiple_vendors.py b/purchase_requisition_multiple_vendor/tests/test_purchase_requisition_multiple_vendors.py new file mode 100644 index 00000000000..6fa353f6c59 --- /dev/null +++ b/purchase_requisition_multiple_vendor/tests/test_purchase_requisition_multiple_vendors.py @@ -0,0 +1,207 @@ +# Copyright 2025 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import Command +from odoo.exceptions import UserError +from odoo.tests import Form +from odoo.tests.common import tagged + +from odoo.addons.purchase_requisition.tests.common import TestPurchaseRequisitionCommon + + +@tagged("post_install", "-at_install") +class TestPurchaseRequisitionMultipleVendors(TestPurchaseRequisitionCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.alternative_vendor_1 = cls.env["res.partner"].create( + {"name": "Alternative Vendor-1"} + ) + cls.alternative_vendor_2 = cls.env["res.partner"].create( + {"name": "Alternative Vendor-2"} + ) + + def create_purchase(self): + return self.env["purchase.order"].create( + { + "partner_id": self.res_partner_1.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": self.product_09.id, + "name": "Product", + "product_qty": 5.0, + "product_uom": self.env.ref("uom.product_uom_dozen").id, + "price_unit": 50.0, + }, + ), + ( + 0, + 0, + { + "name": "Products", + "display_type": "line_section", + "product_qty": 0.0, + }, + ), + ( + 0, + 0, + { + "name": "Products", + "display_type": "line_section", + "product_qty": 0.0, + }, + ), + ], + } + ) + + def create_requisition_wizard(self, orig_po, copy=True): + action = orig_po.action_create_alternative() + alt_po_wiz = Form( + self.env["purchase.requisition.create.alternative"].with_context( + **action["context"] + ) + ) + alt_po_wiz.partner_ids = self.alternative_vendor_1 + self.alternative_vendor_2 + alt_po_wiz.copy_products = copy + alt_po_wiz = alt_po_wiz.save() + return alt_po_wiz + + def test_requisition_multiple_vendors_single(self): + orig_po = self.create_purchase() + action = orig_po.action_create_alternative() + alt_po_wiz = Form( + self.env["purchase.requisition.create.alternative"].with_context( + **action["context"] + ) + ) + alt_po_wiz.partner_ids = self.alternative_vendor_1 + self.assertEqual(alt_po_wiz.partner_id, self.alternative_vendor_1) + alt_po_wiz = alt_po_wiz.save() + alt_po_wiz.action_create_alternative() + self.assertEqual(len(orig_po.alternative_po_ids), 2) + alt_po = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_1 + ) + self.assertTrue(alt_po) + self.assertEqual(len(alt_po.alternative_po_ids), 2) + + def test_requisition_multiple_vendors_copy_lines(self): + orig_po = self.create_purchase() + alt_po_wiz = self.create_requisition_wizard(orig_po) + alt_po_wiz.action_create_alternative() + self.assertEqual(len(orig_po.alternative_po_ids), 3) + + alt_po_1 = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_1 + ) + self.assertTrue(alt_po_1) + self.assertEqual(len(alt_po_1.order_line), 3) + self.assertEqual( + orig_po.order_line[0].product_id, alt_po_1.order_line[0].product_id + ) + self.assertEqual( + orig_po.order_line[0].product_qty, alt_po_1.order_line[0].product_qty + ) + self.assertEqual( + orig_po.order_line[0].product_uom, alt_po_1.order_line[0].product_uom + ) + self.assertEqual( + (orig_po.order_line[1].display_type, orig_po.order_line[1].name), + (alt_po_1.order_line[1].display_type, alt_po_1.order_line[1].name), + ) + self.assertEqual( + (orig_po.order_line[2].display_type, orig_po.order_line[2].name), + (alt_po_1.order_line[2].display_type, alt_po_1.order_line[2].name), + ) + self.assertEqual(len(alt_po_1.alternative_po_ids), 3) + + alt_po_2 = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_2 + ) + self.assertTrue(alt_po_2) + self.assertEqual(len(alt_po_2.order_line), 3) + self.assertEqual( + orig_po.order_line[0].product_id, alt_po_2.order_line[0].product_id + ) + self.assertEqual( + orig_po.order_line[0].product_qty, alt_po_2.order_line[0].product_qty + ) + self.assertEqual( + orig_po.order_line[0].product_uom, alt_po_2.order_line[0].product_uom + ) + self.assertEqual( + (orig_po.order_line[1].display_type, orig_po.order_line[1].name), + (alt_po_2.order_line[1].display_type, alt_po_2.order_line[1].name), + ) + self.assertEqual( + (orig_po.order_line[2].display_type, orig_po.order_line[2].name), + (alt_po_2.order_line[2].display_type, alt_po_2.order_line[2].name), + ) + self.assertEqual(len(alt_po_2.alternative_po_ids), 3) + + def test_requisition_multiple_vendors_no_copy_lines(self): + orig_po = self.env["purchase.order"].create( + { + "partner_id": self.res_partner_1.id, + } + ) + alt_po_wiz = self.create_requisition_wizard(orig_po, False) + alt_po_wiz.action_create_alternative() + self.assertEqual(len(orig_po.alternative_po_ids), 3) + + alt_po_1 = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_1 + ) + self.assertTrue(alt_po_1) + self.assertEqual(len(alt_po_1.order_line), 0) + + alt_po_2 = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_2 + ) + self.assertTrue(alt_po_2) + self.assertEqual(len(alt_po_2.order_line), 0) + + def test_requisition_multiple_vendors_second_flow(self): + orig_po = self.create_purchase() + # First Flow + alt_po_wiz = self.create_requisition_wizard(orig_po) + alt_po_wiz.action_create_alternative() + # Second Flow + alt_po_wiz = self.create_requisition_wizard(orig_po) + alt_po_wiz.action_create_alternative() + + self.assertEqual(len(orig_po.alternative_po_ids), 5) + + alt_po_1 = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_1 + ) + self.assertEqual(len(alt_po_1), 2) + self.assertEqual(len(alt_po_1[0].alternative_po_ids), 5) + self.assertEqual(len(alt_po_1[1].alternative_po_ids), 5) + + alt_po_2 = orig_po.alternative_po_ids.filtered( + lambda po: po.partner_id == self.alternative_vendor_2 + ) + self.assertEqual(len(alt_po_2), 2) + self.assertEqual(len(alt_po_2[0].alternative_po_ids), 5) + self.assertEqual(len(alt_po_2[1].alternative_po_ids), 5) + + def test_requisition_multiple_vendors_creation_block(self): + orig_po = self.create_purchase() + self.alternative_vendor_2.write( + {"purchase_warn": "block", "purchase_warn_msg": "block message"} + ) + self.env.ref("purchase.group_warning_purchase").write( + {"users": [Command.link(self.env.user.id)]} + ) + alt_po_wiz = self.create_requisition_wizard(orig_po) + self.assertTrue(alt_po_wiz.creation_blocked) + self.assertTrue(alt_po_wiz.purchase_warn_msg) + self.assertTrue(self.alternative_vendor_2.name in alt_po_wiz.purchase_warn_msg) + with self.assertRaises(UserError): + alt_po_wiz.action_create_alternative() diff --git a/purchase_requisition_multiple_vendor/wizard/__init__.py b/purchase_requisition_multiple_vendor/wizard/__init__.py new file mode 100644 index 00000000000..db9853757b3 --- /dev/null +++ b/purchase_requisition_multiple_vendor/wizard/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import purchase_requisition_create_alternative diff --git a/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py b/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py new file mode 100644 index 00000000000..976d6b77d9e --- /dev/null +++ b/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.py @@ -0,0 +1,85 @@ +# Copyright 2025 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class PurchaseRequisitionCreateAlternative(models.TransientModel): + _inherit = "purchase.requisition.create.alternative" + + partner_id = fields.Many2one(compute="_compute_partner_id", readonly=False) + partner_ids = fields.Many2many( + string="Partners", comodel_name="res.partner", required=True + ) + + @api.depends("partner_ids") + def _compute_partner_id(self): + for wizard in self: + partner_id = False + if wizard.partner_ids: + partner_id = wizard.partner_ids[0].id + wizard.partner_id = partner_id + + @api.depends("partner_ids") + def _compute_purchase_warn(self): + ret_vals = super()._compute_purchase_warn() + if self.env.user.has_group("purchase.group_warning_purchase"): + for partner in self.partner_ids - self.partner_id: + if partner.purchase_warn == "no-message": + partner = partner.parent_id + if partner and partner.purchase_warn != "no-message": + self.purchase_warn_msg = _( + "Warning for %(partner)s:\n%(warning_message)s\n", + partner=partner.name, + warning_message=partner.purchase_warn_msg, + ) + if partner.purchase_warn == "block": + self.creation_blocked = True + self.purchase_warn_msg += _("This is a blocking warning!\n") + return ret_vals + + def _get_alternative_values_multiple_vendors(self): + self.ensure_one() + vals = self._get_alternative_values() + all_vendor_vals = [vals] + for partner in self.partner_ids - self.partner_id: + partner_vals = vals.copy() + partner_vals["partner_id"] = partner.id + all_vendor_vals.append(partner_vals) + return all_vendor_vals + + def create_alternative_multiple_vendors(self): + if ( + self.env.user.has_group("purchase.group_warning_purchase") + and self.creation_blocked + ): + raise UserError( + _( + "The vendor you have selected or at least one of the products " + "you are copying from the original order has a blocking warning" + " on it and cannot be selected to create an alternative." + ) + ) + vals = self._get_alternative_values_multiple_vendors() + alt_pos = ( + self.env["purchase.order"] + .with_context( + origin_po_id=self.origin_po_id.id, default_requisition_id=False + ) + .create(vals) + ) + alt_pos.order_line._compute_tax_id() + return { + "name": _("Purchase Order Alternatives"), + "type": "ir.actions.act_window", + "view_mode": "tree,form", + "res_model": "purchase.order", + "domain": [("id", "in", alt_pos.ids)], + } + + def action_create_alternative(self): + if len(self.partner_ids) == 1: + return super().action_create_alternative() + else: + return self.create_alternative_multiple_vendors() diff --git a/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.xml b/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.xml new file mode 100644 index 00000000000..fdbd6e29f0c --- /dev/null +++ b/purchase_requisition_multiple_vendor/wizard/purchase_requisition_create_alternative.xml @@ -0,0 +1,24 @@ + + + + purchase.requisition.multiple.vendors.create.alternative.form + purchase.requisition.create.alternative + + + + 1 + + + + + + + diff --git a/setup/_metapackage/pyproject.toml b/setup/_metapackage/pyproject.toml index 46c7ab79819..1d4019f0229 100644 --- a/setup/_metapackage/pyproject.toml +++ b/setup/_metapackage/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "odoo-addons-oca-purchase-workflow" -version = "17.0.20250218.0" +version = "17.0.20250219.0" dependencies = [ "odoo-addon-procurement_purchase_no_grouping>=17.0dev,<17.1dev", "odoo-addon-purchase_advance_payment>=17.0dev,<17.1dev", @@ -34,6 +34,7 @@ dependencies = [ "odoo-addon-purchase_reception_notify>=17.0dev,<17.1dev", "odoo-addon-purchase_request>=17.0dev,<17.1dev", "odoo-addon-purchase_request_tier_validation>=17.0dev,<17.1dev", + "odoo-addon-purchase_requisition_multiple_vendor>=17.0dev,<17.1dev", "odoo-addon-purchase_requisition_tier_validation>=17.0dev,<17.1dev", "odoo-addon-purchase_sale_link_by_origin>=17.0dev,<17.1dev", "odoo-addon-purchase_security>=17.0dev,<17.1dev",