Skip to content

Commit 31e9f2f

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

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
@@ -1,6 +1,8 @@
11
# Copyright 2023 Camptocamp SA
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
33

4+
from math import ceil
5+
46
from odoo import _, api, models
57
from odoo.exceptions import ValidationError
68
from odoo.tools import float_compare
@@ -47,6 +49,14 @@ def _force_qty_with_package(self):
4749
self.product_qty = qty
4850
return True
4951

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()
59+
5060
@api.onchange("product_qty")
5161
def _onchange_product_qty(self):
5262
self._force_qty_with_package()

0 commit comments

Comments
 (0)