Skip to content

Commit

Permalink
[FIX] hr_timesheet_sheet: delete related analytic lines when deleting…
Browse files Browse the repository at this point in the history
… timesheet.sheet

When deleting a timesheet sheet, delete also the analytic lines related
to the timesheet lines.
  • Loading branch information
anthony-muschang committed Feb 17, 2015
1 parent 058a010 commit afe4a97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions addons/hr_timesheet_sheet/hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ def unlink(self, cr, uid, ids, context=None):
raise osv.except_osv(_('Invalid Action!'), _('You cannot delete a timesheet which is already confirmed.'))
elif sheet['total_attendance'] <> 0.00:
raise osv.except_osv(_('Invalid Action!'), _('You cannot delete a timesheet which have attendance entries.'))

toremove = []
analytic_line = self.pool.get('account.analytic.line')
for sheet in self.browse(cr, uid, ids, context=context):
for timesheet in sheet.timesheet_ids:
toremove.append(timesheet.line_id.id)
analytic_line.unlink(cr, uid, toremove, context=context)

return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context)

def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
Expand Down

0 comments on commit afe4a97

Please sign in to comment.