Skip to content

Commit

Permalink
[FIX] don't recompute sheet_id when account name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Dec 4, 2018
1 parent 8321c1e commit 33bb664
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hr_timesheet_improvement/hr_timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ class HrAnalyticTimesheet(models.Model):

account_name = fields.Char(related='account_id.name',
store=True, readonly=True)

def _register_hook(self, cr):
"""Patch recomputation of sheet_id to never recompute when
account_name changes"""
if self._columns['sheet_id'].store.get(
'hr.analytic.timesheet', [None, None, None]
)[1] is None:
trigger = self._columns['sheet_id'].store['hr.analytic.timesheet']
self._columns['sheet_id'].store['hr.analytic.timesheet'] = (
trigger[0],
[f for f in self._columns.keys() if f != 'account_name'],
trigger[2],
)
return super(HrAnalyticTimesheet, self)._register_hook(cr)

0 comments on commit 33bb664

Please sign in to comment.