Merge lp:~openerp-dev/openobject-addons/7.0-payroll-recursive-fix-csn into lp:openobject-addons/7.0

Proposed by Cedric Snauwaert (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-payroll-recursive-fix-csn
Merge into: lp:openobject-addons/7.0
Diff against target: 41 lines (+16/-2)
1 file modified
hr_payroll/hr_payroll.py (+16/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-payroll-recursive-fix-csn
Reviewer Review Type Date Requested Status
qdp (OpenERP) Pending
Review via email: mp+159774@code.launchpad.net

Description of the change

fix recursion problem in hr_payroll_structure due to same class structure defined below, change are made for v7.0 Do not forward in trunk

To post a comment you must log in.

Unmerged revisions

9043. By Cedric Snauwaert (OpenERP)

[FIX]hr_payroll: forgot to remove one extra field (bad for v7.0)

9042. By Cedric Snauwaert (OpenERP)

[FIX]hr_payroll: fix recursion problem for v7.0 in hr_payroll_structure due to another class with same name
defined later in file, also add recursion check constraint. Do not forward those change in trunk

9041. By Cedric Snauwaert (OpenERP)

[FIX]hr_payroll: fix recursion problem in hr_payroll_structure due to another class with same name
defined later in file, also add recursion check constraint

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-04-19 08:39:37 +0000
4@@ -68,6 +68,20 @@
5 'parent_id': _get_parent,
6 }
7
8+ def _check_recursion(self, cr, uid, ids, context=None):
9+ level = 100
10+ while len(ids):
11+ cr.execute('select distinct parent_id from hr_payroll_structure where id IN %s',(tuple(ids),))
12+ ids = filter(None, map(lambda x:x[0], cr.fetchall()))
13+ if not level:
14+ return False
15+ level -= 1
16+ return True
17+
18+ _constraints = [
19+ (_check_recursion, 'Error ! You cannot create recursive Salary Structure.', ['parent_id'])
20+ ]
21+
22 def copy(self, cr, uid, id, default=None, context=None):
23 """
24 Create a new record in hr_payroll_structure model from existing one
25@@ -951,14 +965,14 @@
26
27 hr_payslip_line()
28
29-class hr_payroll_structure(osv.osv):
30+class hr_payroll_structure_(osv.osv):
31
32 _inherit = 'hr.payroll.structure'
33 _columns = {
34 'rule_ids':fields.many2many('hr.salary.rule', 'hr_structure_salary_rule_rel', 'struct_id', 'rule_id', 'Salary Rules'),
35 }
36
37-hr_payroll_structure()
38+hr_payroll_structure_()
39
40 class hr_employee(osv.osv):
41 '''