From 6af4cff449a68a490a9a6a9d660253c486190117 Mon Sep 17 00:00:00 2001 From: Ariel Barreiros <50119000+arielbarreiros96@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:44:29 +0000 Subject: [PATCH] [IMP] product_supplierinfo_qty_multiplier: added logic for bypassing multiplier if required --- .../README.rst | 18 +++++---- .../__manifest__.py | 2 +- .../models/__init__.py | 1 + .../models/purchase_order.py | 15 +++++++ .../models/purchase_order_line.py | 7 +++- .../readme/CONFIGURE.md | 3 ++ .../readme/CONTRIBUTORS.md | 2 + .../readme/USAGE.md | 9 ++--- .../static/description/index.html | 40 ++++++++++--------- .../tests/test_purchase_order.py | 18 +++++++++ .../views/purchase_order_view.xml | 13 ++++++ 11 files changed, 95 insertions(+), 33 deletions(-) create mode 100644 product_supplierinfo_qty_multiplier/models/purchase_order.py create mode 100644 product_supplierinfo_qty_multiplier/views/purchase_order_view.xml diff --git a/product_supplierinfo_qty_multiplier/README.rst b/product_supplierinfo_qty_multiplier/README.rst index eafdb44aa7e..c81bad4e92b 100644 --- a/product_supplierinfo_qty_multiplier/README.rst +++ b/product_supplierinfo_qty_multiplier/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - =================================== Product supplierinfo qty multiplier =================================== @@ -17,7 +13,7 @@ Product supplierinfo qty multiplier .. |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/license-AGPL--3-blue.png +.. |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 @@ -48,6 +44,10 @@ Configuration - Go to the 'Purchase' tab and edit a vendor pricelist line to set 'Multiplier Qty' to 6.0 +To allow skipping this multiplier on specific purchase orders, the field +'Bypass vendor pricelist Qty. Multiplier' is available on the purchase +order. + (If you can't find that column, you can activate it by clicking the three dots at the corner of the table and enabling it). @@ -62,9 +62,10 @@ Usage - Assign it to the partner where the multiplier quantity was previously set. - Add a product line with the previously edited product. -- Quantity is set to 6.0. +- Quantity is set to 6.0 by default (based on the vendor multiplier). - If you set 9.0 in the quantity field, the quantity will be rounded up - to 12.0 + to 12.0 unless the 'Bypass vendor pricelist Qty. Multiplier' flag is + enabled on the purchase order. |purchase_order_form| @@ -98,6 +99,9 @@ Contributors - Pedro M. Baeza - Sylvain LE GAL (https://twitter.com/legalsylvain) +- [Binhex] (https://binhex.cloud): + + - Ariel Barreiros Maintainers ----------- diff --git a/product_supplierinfo_qty_multiplier/__manifest__.py b/product_supplierinfo_qty_multiplier/__manifest__.py index b44568d7c21..f1f0d5b67ce 100644 --- a/product_supplierinfo_qty_multiplier/__manifest__.py +++ b/product_supplierinfo_qty_multiplier/__manifest__.py @@ -10,7 +10,7 @@ "installable": True, "depends": ["purchase", "web_notify"], "maintainers": ["victoralmau", "legalsylvain"], - "data": ["views/product_supplierinfo_view.xml"], + "data": ["views/product_supplierinfo_view.xml", "views/purchase_order_view.xml"], "demo": [ "demo/res_partner_demo.xml", "demo/product_product_demo.xml", diff --git a/product_supplierinfo_qty_multiplier/models/__init__.py b/product_supplierinfo_qty_multiplier/models/__init__.py index 78f8d69fc9e..2e5c75ff4c2 100644 --- a/product_supplierinfo_qty_multiplier/models/__init__.py +++ b/product_supplierinfo_qty_multiplier/models/__init__.py @@ -1,2 +1,3 @@ from . import product_supplierinfo from . import purchase_order_line +from . import purchase_order diff --git a/product_supplierinfo_qty_multiplier/models/purchase_order.py b/product_supplierinfo_qty_multiplier/models/purchase_order.py new file mode 100644 index 00000000000..085faa95a8f --- /dev/null +++ b/product_supplierinfo_qty_multiplier/models/purchase_order.py @@ -0,0 +1,15 @@ +# Copyright 2026 Binhex - Ariel Barreiros +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + bypass_supplierinfo_qty_multiplier = fields.Boolean( + string="Bypass vendor pricelist Qty. Multiplier", + help="If checked, the quantity multiplier defined in the " + "vendor pricelist will not be applied to the purchase order lines " + "of this purchase order.", + ) diff --git a/product_supplierinfo_qty_multiplier/models/purchase_order_line.py b/product_supplierinfo_qty_multiplier/models/purchase_order_line.py index 1ad5d0369e1..a19a37d5719 100644 --- a/product_supplierinfo_qty_multiplier/models/purchase_order_line.py +++ b/product_supplierinfo_qty_multiplier/models/purchase_order_line.py @@ -14,6 +14,8 @@ class PurchaseOrderLine(models.Model): def _onchange_product_qty_multiplier_qty(self): if not self.product_id: return + if self.order_id and self.order_id.bypass_supplierinfo_qty_multiplier: + return seller = self.product_id._select_seller( partner_id=self.partner_id, quantity=self.product_qty, @@ -31,7 +33,10 @@ def _onchange_product_qty_multiplier_qty(self): "The selected supplier only sells this product" " by %(multiplier_qty)s %(uom_name)s.\n" "The quantity has been automatically changed" - " to %(new_product_qty)s %(uom_name)s." + " to %(new_product_qty)s %(uom_name)s.\n" + "If you want to avoid this change, enable " + "'Bypass vendor pricelist Qty. Multiplier' on the" + " purchase order." ) % ( { diff --git a/product_supplierinfo_qty_multiplier/readme/CONFIGURE.md b/product_supplierinfo_qty_multiplier/readme/CONFIGURE.md index 19e3a678880..ebccc6272e3 100644 --- a/product_supplierinfo_qty_multiplier/readme/CONFIGURE.md +++ b/product_supplierinfo_qty_multiplier/readme/CONFIGURE.md @@ -3,6 +3,9 @@ - Go to the 'Purchase' tab and edit a vendor pricelist line to set 'Multiplier Qty' to 6.0 +To allow skipping this multiplier on specific purchase orders, the field +'Bypass vendor pricelist Qty. Multiplier' is available on the purchase order. + (If you can't find that column, you can activate it by clicking the three dots at the corner of the table and enabling it). diff --git a/product_supplierinfo_qty_multiplier/readme/CONTRIBUTORS.md b/product_supplierinfo_qty_multiplier/readme/CONTRIBUTORS.md index af54379fb3d..e1c1c6e2c02 100644 --- a/product_supplierinfo_qty_multiplier/readme/CONTRIBUTORS.md +++ b/product_supplierinfo_qty_multiplier/readme/CONTRIBUTORS.md @@ -2,3 +2,5 @@ - Víctor Martínez - Pedro M. Baeza - Sylvain LE GAL () +- [Binhex] (https://binhex.cloud): + - Ariel Barreiros \ No newline at end of file diff --git a/product_supplierinfo_qty_multiplier/readme/USAGE.md b/product_supplierinfo_qty_multiplier/readme/USAGE.md index e0370b0f83f..4707660c785 100644 --- a/product_supplierinfo_qty_multiplier/readme/USAGE.md +++ b/product_supplierinfo_qty_multiplier/readme/USAGE.md @@ -1,9 +1,8 @@ - Create a new purchase order. -- Assign it to the partner where the multiplier quantity was previously - set. +- Assign it to the partner where the multiplier quantity was previously set. - Add a product line with the previously edited product. -- Quantity is set to 6.0. -- If you set 9.0 in the quantity field, the quantity will be rounded up - to 12.0 +- Quantity is set to 6.0 by default (based on the vendor multiplier). +- If you set 9.0 in the quantity field, the quantity will be rounded up to + 12.0 unless the 'Bypass vendor pricelist Qty. Multiplier' flag is enabled on the purchase order. ![purchase_order_form](../static/description/purchase_order_form.png) diff --git a/product_supplierinfo_qty_multiplier/static/description/index.html b/product_supplierinfo_qty_multiplier/static/description/index.html index 6031b91dd71..834024d89df 100644 --- a/product_supplierinfo_qty_multiplier/static/description/index.html +++ b/product_supplierinfo_qty_multiplier/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Product supplierinfo qty multiplier -
+
+

Product supplierinfo qty multiplier

- - -Odoo Community Association - -
-

Product supplierinfo qty multiplier

-

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

+

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

This module allows to define multiplier quantities at the supplier level in the products to apply it in the purchase order lines.

Table of contents

@@ -392,32 +387,36 @@

Product supplierinfo qty multiplier

-

Configuration

+

Configuration

  • Go to Purchase > Products > Products.
  • Select a product.
  • Go to the ‘Purchase’ tab and edit a vendor pricelist line to set ‘Multiplier Qty’ to 6.0
+

To allow skipping this multiplier on specific purchase orders, the field +‘Bypass vendor pricelist Qty. Multiplier’ is available on the purchase +order.

(If you can’t find that column, you can activate it by clicking the three dots at the corner of the table and enabling it).

product_form

-

Usage

+

Usage

  • Create a new purchase order.
  • Assign it to the partner where the multiplier quantity was previously set.
  • Add a product line with the previously edited product.
  • -
  • Quantity is set to 6.0.
  • +
  • Quantity is set to 6.0 by default (based on the vendor multiplier).
  • If you set 9.0 in the quantity field, the quantity will be rounded up -to 12.0
  • +to 12.0 unless the ‘Bypass vendor pricelist Qty. Multiplier’ flag is +enabled on the purchase order.

purchase_order_form

-

Bug Tracker

+

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 @@ -425,16 +424,16 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
  • GRAP
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -460,6 +463,5 @@

Maintainers

-
diff --git a/product_supplierinfo_qty_multiplier/tests/test_purchase_order.py b/product_supplierinfo_qty_multiplier/tests/test_purchase_order.py index 91a196e6834..222c1f37e24 100644 --- a/product_supplierinfo_qty_multiplier/tests/test_purchase_order.py +++ b/product_supplierinfo_qty_multiplier/tests/test_purchase_order.py @@ -71,3 +71,21 @@ def test_various_prices(self): purchase_form.save() self.assertEqual(line_form_2.product_qty, 100) self.assertEqual(line_form_2.price_unit, 95) + + def test_bypass_qty_multiplier(self): + purchase_form = Form(self.env["purchase.order"]) + purchase_form.partner_id = self.partner + purchase_form.bypass_supplierinfo_qty_multiplier = True + with purchase_form.order_line.new() as line_form_1: + line_form_1.product_id = self.product_b + line_form_1.product_qty = 3 + purchase_form.save() + self.assertEqual(line_form_1.product_qty, 3) + self.assertEqual(line_form_1.price_unit, 100) + + with purchase_form.order_line.new() as line_form_2: + line_form_2.product_id = self.product_b + line_form_2.product_qty = 99 + purchase_form.save() + self.assertEqual(line_form_2.product_qty, 99) + self.assertEqual(line_form_2.price_unit, 100) diff --git a/product_supplierinfo_qty_multiplier/views/purchase_order_view.xml b/product_supplierinfo_qty_multiplier/views/purchase_order_view.xml new file mode 100644 index 00000000000..6e1b768cee2 --- /dev/null +++ b/product_supplierinfo_qty_multiplier/views/purchase_order_view.xml @@ -0,0 +1,13 @@ + + + + + purchase.order + + + + + + + +