fix(fusion_clock): migration must recompute net_hours/overtime, not just break
Recomputing only x_fclk_break_minutes left historical x_fclk_net_hours / x_fclk_overtime_hours stale (add_to_compute+flush of one field does not cascade to dependents). Recompute the full chain in dependency order. Caught verifying the entech deploy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,12 @@ def migrate(cr, version):
|
||||
)
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
Attendance = env['hr.attendance']
|
||||
field = Attendance._fields['x_fclk_break_minutes']
|
||||
closed = Attendance.search([('check_out', '!=', False)])
|
||||
if closed:
|
||||
env.add_to_compute(field, closed)
|
||||
closed.flush_recordset(['x_fclk_break_minutes'])
|
||||
# Recompute the break AND everything that derives from it, in dependency
|
||||
# order (break -> net hours -> overtime). Recomputing break alone leaves
|
||||
# stored x_fclk_net_hours / x_fclk_overtime_hours stale, because
|
||||
# add_to_compute + flush of one field does not cascade to its dependents.
|
||||
for fname in ('x_fclk_break_minutes', 'x_fclk_net_hours', 'x_fclk_overtime_hours'):
|
||||
env.add_to_compute(Attendance._fields[fname], closed)
|
||||
closed.flush_recordset([fname])
|
||||
|
||||
Reference in New Issue
Block a user