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

Proposed by Nehal Panchal (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-584846-port-nep
Merge into: lp:openobject-addons/7.0
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/7.0-opw-584846-port-nep
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Needs Fixing
Review via email: mp+146080@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.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hi

@line 17: your are taking id's of payslips from browse_record instance and in the next line you are again browsing the same ids back :) you could simple iterate over batches.slip_ids

also as you have toremove=[] for batches you can have the same for payslips too and delete only those that are in draft state.

review: Needs Fixing

Unmerged revisions

8643. 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-12-17 15:23:03 +0000
3+++ hr_payroll/hr_payroll.py 2013-02-01 09:44:21 +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