Prevent division by zero when migrating effort into progress

issue10990
review370341002
This commit is contained in:
Raimon Esteve committed 2021-12-06 23:21:49 +01:00
1 parent eed21d0b2a
commit 4a0ea7973f
1 file changed
+2 -1
+2 -1
View File
@@ -11,6 +11,7 @@ from sql import Null
from sql.aggregate import Sum
from sql.functions import Extract
from sql.operators import Concat
from sql.conditionals import NullIf
from trytond.i18n import gettext
from trytond.model import ModelSQL, ModelView, fields
@@ -663,7 +664,7 @@ class WorkInvoicedProgress(ModelView, ModelSQL):
# Don't use UPDATE FROM because SQLite does not support it.
value = work.select(
(Extract('EPOCH', sql_table.effort_duration)
/ Extract('EPOCH', work.effort_duration)),
/ NullIf(Extract('EPOCH', work.effort_duration), 0)),
where=work.id == sql_table.work)
cursor.execute(*sql_table.update([sql_table.progress], [value]))