[FIX] mrp_workorder: fix duration_percent out of range
duration_percent field is a stored integer. In postgresql, integer are 4 Bytes long, which create a range of -2147483648 to +2147483647. With a small duration_expected, and a big duration, we can easily break these limits. OPW-3253333 closes odoo/odoo#117744 X-original-commit: 97892d04341a2cbbe07e4db6442a451b0cf0b164 Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: David <dafr@odoo.com>
This commit is contained in:
@@ -322,7 +322,7 @@ class MrpWorkorder(models.Model):
|
||||
order.duration = sum(order.time_ids.mapped('duration'))
|
||||
order.duration_unit = round(order.duration / max(order.qty_produced, 1), 2) # rounding 2 because it is a time
|
||||
if order.duration_expected:
|
||||
order.duration_percent = 100 * (order.duration_expected - order.duration) / order.duration_expected
|
||||
order.duration_percent = max(-2147483648, min(2147483647, 100 * (order.duration_expected - order.duration) / order.duration_expected))
|
||||
else:
|
||||
order.duration_percent = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user