Merge lp:~openerp-dev/openobject-addons/6.1-opw-584846-nep into lp:openobject-addons/6.1

Proposed by Nehal Panchal (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-584846-nep
Merge into: lp:openobject-addons/6.1
Diff against target: 25 lines (+16/-0)
1 file modified
hr_payroll/hr_payroll.py (+16/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-584846-nep
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+146076@code.launchpad.net

Description of the change

Hello,

If you delete Payslip Batches, related payslips are not deleted.

This fixes the issue.

Thanks

To post a comment you must log in.

Unmerged revisions

7141. By Nehal Panchal (OpenERP)

[FIX] hr_payroll : While deleting Paylips Batches, related payslips are not deleted

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_payroll/hr_payroll.py'
2--- hr_payroll/hr_payroll.py 2012-01-31 13:36:57 +0000
3+++ hr_payroll/hr_payroll.py 2013-02-01 09:33:09 +0000
4@@ -234,6 +234,22 @@
5
6 def close_payslip_run(self, cr, uid, ids, context=None):
7 return self.write(cr, uid, ids, {'state': 'close'}, context=context)
8+
9+ def unlink(self, cr, uid, ids, context=None):
10+ if context is None:
11+ context = {}
12+ toremove = []
13+ payslip_obj = self.pool.get('hr.payslip')
14+ for batches in self.browse(cr, uid, ids, context=context):
15+ if batches['state'] != 'draft':
16+ raise osv.except_osv(_('Warning !'), _('You can not delete a closed payslip batch "%s" ') % batches['name'])
17+ payslip_ids = map(lambda x: x.id, batches.slip_ids)
18+ for payslip in payslip_obj.browse(cr, uid, payslip_ids):
19+ if payslip.state != 'draft':
20+ raise osv.except_osv(_('Warning !'), _('You can not delete payslip batch "%s" due to any of the confirmed payslip') % batches['name'])
21+ payslip_obj.unlink(cr, uid, payslip_ids, context=context)
22+ toremove.append(batches.id)
23+ return super(hr_payslip_run, self).unlink(cr, uid, toremove, context)
24
25 hr_payslip_run()
26