Skip to content

Commit 3c8d9b2

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

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

purchase_only_by_packaging/models/purchase_order_line.py

+12
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,16 @@ 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+
# The issue exists for sale order => odoo issue to fix proposed
57+
# here: https://github.com/odoo/odoo/issues/197598
58+
ceiled_product_packaging_qty = ceil(self.product_packaging_qty)
59+
self.product_packaging_qty = ceiled_product_packaging_qty or 1
60+
return super()._onchange_product_packaging_id()
61+
5062
@api.onchange("product_qty")
5163
def _onchange_product_qty(self):
5264
self._force_qty_with_package()

0 commit comments

Comments
 (0)