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
=== modified file 'hr_payroll/hr_payroll.py'
--- hr_payroll/hr_payroll.py 2012-12-17 15:23:03 +0000
+++ hr_payroll/hr_payroll.py 2013-04-19 08:39:37 +0000
@@ -68,6 +68,20 @@
68 'parent_id': _get_parent,68 'parent_id': _get_parent,
69 }69 }
7070
71 def _check_recursion(self, cr, uid, ids, context=None):
72 level = 100
73 while len(ids):
74 cr.execute('select distinct parent_id from hr_payroll_structure where id IN %s',(tuple(ids),))
75 ids = filter(None, map(lambda x:x[0], cr.fetchall()))
76 if not level:
77 return False
78 level -= 1
79 return True
80
81 _constraints = [
82 (_check_recursion, 'Error ! You cannot create recursive Salary Structure.', ['parent_id'])
83 ]
84
71 def copy(self, cr, uid, id, default=None, context=None):85 def copy(self, cr, uid, id, default=None, context=None):
72 """86 """
73 Create a new record in hr_payroll_structure model from existing one87 Create a new record in hr_payroll_structure model from existing one
@@ -951,14 +965,14 @@
951965
952hr_payslip_line()966hr_payslip_line()
953967
954class hr_payroll_structure(osv.osv):968class hr_payroll_structure_(osv.osv):
955969
956 _inherit = 'hr.payroll.structure'970 _inherit = 'hr.payroll.structure'
957 _columns = {971 _columns = {
958 'rule_ids':fields.many2many('hr.salary.rule', 'hr_structure_salary_rule_rel', 'struct_id', 'rule_id', 'Salary Rules'),972 'rule_ids':fields.many2many('hr.salary.rule', 'hr_structure_salary_rule_rel', 'struct_id', 'rule_id', 'Salary Rules'),
959 }973 }
960974
961hr_payroll_structure()975hr_payroll_structure_()
962976
963class hr_employee(osv.osv):977class hr_employee(osv.osv):
964 '''978 '''