Skip to content

Commit 7654cc7

Browse files
committed
[IMP] purchase_only_by_packaging round up product qty
1 parent 547d0cd commit 7654cc7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

purchase_only_by_packaging/models/purchase_order_line.py

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from odoo import _, api, models
55
from odoo.exceptions import ValidationError
66
from odoo.tools import float_compare
7+
from math import ceil
78

89

910
class PurchaseOrderLine(models.Model):
@@ -46,6 +47,15 @@ def _force_qty_with_package(self):
4647
)
4748
self.product_qty = qty
4849
return True
50+
51+
52+
@api.onchange("product_packaging_id")
53+
def _onchange_product_packaging_id(self):
54+
# Round up to the next integer and avoid the Warning raised by
55+
# _onchange_product_packaging_id defined in the purchase addon
56+
ceiled_product_packaging_qty = ceil(self.product_packaging_qty)
57+
self.product_packaging_qty = ceiled_product_packaging_qty or 1
58+
return super()._onchange_product_packaging_id()
4959

5060
@api.onchange("product_qty")
5161
def _onchange_product_qty(self):

0 commit comments

Comments
 (0)