Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions product_supplierinfo_qty_multiplier/README.rst
Original file line number Diff line number Diff line change
@@ -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
===================================
Expand All @@ -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
Expand Down Expand Up @@ -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).

Expand All @@ -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|

Expand Down Expand Up @@ -98,6 +99,9 @@ Contributors
- Pedro M. Baeza

- Sylvain LE GAL (https://twitter.com/legalsylvain)
- [Binhex] (https://binhex.cloud):

- Ariel Barreiros

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion product_supplierinfo_qty_multiplier/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions product_supplierinfo_qty_multiplier/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import product_supplierinfo
from . import purchase_order_line
from . import purchase_order
15 changes: 15 additions & 0 deletions product_supplierinfo_qty_multiplier/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -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.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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."
)
% (
{
Expand Down
3 changes: 3 additions & 0 deletions product_supplierinfo_qty_multiplier/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
2 changes: 2 additions & 0 deletions product_supplierinfo_qty_multiplier/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
- Víctor Martínez
- Pedro M. Baeza
- Sylvain LE GAL (<https://twitter.com/legalsylvain>)
- [Binhex] (https://binhex.cloud):
- Ariel Barreiros
9 changes: 4 additions & 5 deletions product_supplierinfo_qty_multiplier/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Look great to me.
But I'd to explicit in which case it's interesting to by pass the setting ?
I mean, I developp this module to prevent user to buy one (or 2) bottle of milk, when supplier sell only by 6. In the use cases of my company, my users never said me they want to bypass the feature. Could you write some real use case in the USAGE.md (or DESCRIPTION.md file).

thanks !


![purchase_order_form](../static/description/purchase_order_form.png)
40 changes: 21 additions & 19 deletions product_supplierinfo_qty_multiplier/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Product supplierinfo qty multiplier</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="product-supplierinfo-qty-multiplier">
<h1 class="title">Product supplierinfo qty multiplier</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="product-supplierinfo-qty-multiplier">
<h1>Product supplierinfo qty multiplier</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e828f746aa21f8313c56f048ac9874a5168a304469d48865d2eb5b6e3e8db9e8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/18.0/product_supplierinfo_qty_multiplier"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-product_supplierinfo_qty_multiplier"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/18.0/product_supplierinfo_qty_multiplier"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-product_supplierinfo_qty_multiplier"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to define multiplier quantities at the supplier level
in the products to apply it in the purchase order lines.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -392,60 +387,68 @@ <h1>Product supplierinfo qty multiplier</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<ul class="simple">
<li>Go to Purchase &gt; Products &gt; Products.</li>
<li>Select a product.</li>
<li>Go to the ‘Purchase’ tab and edit a vendor pricelist line to set
‘Multiplier Qty’ to 6.0</li>
</ul>
<p>To allow skipping this multiplier on specific purchase orders, the field
‘Bypass vendor pricelist Qty. Multiplier’ is available on the purchase
order.</p>
<p>(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).</p>
<p><img alt="product_form" src="https://raw.githubusercontent.com/OCA/purchase-workflow/18.0/product_supplierinfo_qty_multiplier/static/description/product_product_form.png" /></p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<ul class="simple">
<li>Create a new purchase order.</li>
<li>Assign it to the partner where the multiplier quantity was previously
set.</li>
<li>Add a product line with the previously edited product.</li>
<li>Quantity is set to 6.0.</li>
<li>Quantity is set to 6.0 by default (based on the vendor multiplier).</li>
<li>If you set 9.0 in the quantity field, the quantity will be rounded up
to 12.0</li>
to 12.0 unless the ‘Bypass vendor pricelist Qty. Multiplier’ flag is
enabled on the purchase order.</li>
</ul>
<p><img alt="purchase_order_form" src="https://raw.githubusercontent.com/OCA/purchase-workflow/18.0/product_supplierinfo_qty_multiplier/static/description/purchase_order_form.png" /></p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20product_supplierinfo_qty_multiplier%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
<li>GRAP</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Víctor Martínez</li>
<li>Pedro M. Baeza</li>
</ul>
</li>
<li>Sylvain LE GAL (<a class="reference external" href="https://twitter.com/legalsylvain">https://twitter.com/legalsylvain</a>)</li>
<li>[Binhex] (<a class="reference external" href="https://binhex.cloud">https://binhex.cloud</a>):<ul>
<li>Ariel Barreiros</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -460,6 +463,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions product_supplierinfo_qty_multiplier/tests/test_purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 13 additions & 0 deletions product_supplierinfo_qty_multiplier/views/purchase_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="purchase_order_form_view" model="ir.ui.view">
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="origin" position="after">
<field name="bypass_supplierinfo_qty_multiplier" />
</field>
</field>
</record>
</odoo>