Skip to content
Snippets Groups Projects
Commit 97892d04 authored by David (dafr)'s avatar David (dafr)
Browse files

[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#117590

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 53fc292a
No related branches found
No related tags found
No related merge requests found
......@@ -303,7 +303,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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment