[IMP] hr_payroll:created a method for three function fields.

bzr revid: mtr@mtr-20110328123241-m0tul6jysd4cr2k8
This commit is contained in:
mtr 2011-03-28 18:02:41 +05:30
parent 95c62bbaa2
commit 8eaf9ae4a5
2 changed files with 31 additions and 41 deletions

View File

@ -475,15 +475,16 @@ class hr_payslip(osv.osv):
parent = self._get_parent_structure(cr, uid, parent, context)
return struct_id + parent
def _applied_salary_rule(self, cr, uid, ids, field_names, arg=None, context=None):
def _get_salary_rules(self, cr, uid, ids, field_names, arg=None, context=None):
structure_obj = self.pool.get('hr.payroll.structure')
result = {}
res = {}
sal_structure = []
lines = []
rules = []
rul = []
for record in self.browse(cr, uid, ids, context=context):
function = record.struct_id.id
sal_structure = []
lines = []
rules = []
rule = []
res[record.id] = {}
if function:
sal_structure = self._get_parent_structure(cr, uid, [function], context=context)
for struct in sal_structure:
@ -493,36 +494,24 @@ class hr_payslip(osv.osv):
for r in rl.child_ids:
lines.append(r)
rules.append(rl)
for r in rules:
if r.id not in rule:
rule.append(r.id)
result[record.id] = rule
return result
def _appears_on_payslip_rule(self, cr, uid, ids, field_names, arg=None, context=None):
struct_obj = self.pool.get('hr.payroll.structure')
result = {}
for record in self.browse(cr, uid, ids, context=context):
structure = record.struct_id.id
sal_struct = []
lines = []
rules = []
rule = []
if structure:
sal_struct = self._get_parent_structure(cr, uid, [structure], context=context)
for struct in sal_struct:
lines = struct_obj.browse(cr, uid, struct, context=context).rule_ids
for rl in lines:
if rl.child_ids:
for r in rl.child_ids:
lines.append(r)
rules.append(rl)
for r in rules:
for fn in field_names:
if fn == 'applied_salary_rule':
for r in rules:
if r.id not in rul:
rul.append(r.id)
res[record.id] = {fn: rul}
elif fn == 'appears_on_payslip_rule':
for r in rules:
if r.appears_on_payslip:
if r.id not in rule:
rule.append(r.id)
result[record.id] = rule
return result
if r.id not in rul:
rul.append(r.id)
res[record.id] = {fn: rul}
elif fn == 'details_by_salary_head':
for r in rules:
if r.id not in rul:
rul.append(r.id)
res[record.id] = {fn: rul}
return res
def _compute(self, cr, uid, id, value, context=None):
rule_obj = self.pool.get('hr.salary.rule')
@ -569,9 +558,9 @@ class hr_payslip(osv.osv):
'igross': fields.float('Calculaton Field', readonly=True, digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
'inet': fields.float('Calculaton Field', readonly=True, digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
'holiday_ids': fields.function(_get_holidays, method=True, type='one2many', relation='hr.holidays', string='Holiday Lines', required=False),
'applied_salary_rule': fields.function(_applied_salary_rule, method=True, type='one2many', relation='hr.salary.rule', string='Applied Salary Rules', required=False),
'appears_on_payslip_rule': fields.function(_appears_on_payslip_rule, method=True, type='one2many', relation='hr.salary.rule', string='Appears on Payslip', required=False),
# 'details_by_salary_head': fields.function(_get_salary_rules, method=True, type='one2many', relation='hr.salary.rule', string='Details by Salary Head'),
'applied_salary_rule': fields.function(_get_salary_rules, method=True, type='one2many', relation='hr.salary.rule', string='Applied Salary Rules', multi='applied_salary_rule'),
'appears_on_payslip_rule': fields.function(_get_salary_rules, method=True, type='one2many', relation='hr.salary.rule', string='Appears on Payslip', multi='appears_on_payslip_rule'),
'details_by_salary_head': fields.function(_get_salary_rules, method=True, type='one2many', relation='hr.salary.rule', string='Details by Salary Head', multi='details_by_salary_head'),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),

View File

@ -286,11 +286,12 @@
<page string="Applied Salary Rules">
<field name="applied_salary_rule" nolabel="1" />
</page>
<page string="Appears on payslip">
<page string="Appears On Payslip">
<field name="appears_on_payslip_rule" nolabel="1"/>
</page>
<page string="Details by salary head">
</page>
<page string="Details By Salary Head">
<field name="details_by_salary_head" nolabel="1" context="{'group_by': 'category_id'}"/>
</page>
</notebook>
<group col="10" colspan="4">
<field name="state"/>