[IMP] hr_payroll:improved code for child_rules,added display_child_rules field
bzr revid: mtr@mtr-20110317132913-ffrst2r4dxgtw3w8
This commit is contained in:
parent
250d196cb3
commit
de09f57d7b
|
@ -963,38 +963,40 @@ class hr_payslip(osv.osv):
|
|||
raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e))
|
||||
if line.amount_type == 'per':
|
||||
try:
|
||||
if line.parent_rule_id:
|
||||
for rul in [line.parent_rule_id]:
|
||||
# if rul.child_depend:
|
||||
val = rul.amount * amt
|
||||
amt = val
|
||||
value = line.amount * amt
|
||||
if line.condition_range_min or line.condition_range_max:
|
||||
if ((value < line.condition_range_min) or (value > line.condition_range_max)):
|
||||
value = 0.0
|
||||
if line.child_depend == False:
|
||||
if line.parent_rule_id:
|
||||
for rul in [line.parent_rule_id]:
|
||||
val = rul.amount * amt
|
||||
amt = val
|
||||
value = line.amount * amt
|
||||
if line.condition_range_min or line.condition_range_max:
|
||||
if ((value < line.condition_range_min) or (value > line.condition_range_max)):
|
||||
value = 0.0
|
||||
else:
|
||||
value = value
|
||||
else:
|
||||
value = value
|
||||
else:
|
||||
value = value
|
||||
except Exception, e:
|
||||
raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e))
|
||||
|
||||
elif line.amount_type == 'fix':
|
||||
if line.parent_rule_id:
|
||||
if line.child_depend == False:
|
||||
if line.parent_rule_id:
|
||||
for rul in [line.parent_rule_id]:
|
||||
# if rul.child_depend:
|
||||
value = value
|
||||
if line.condition_range_min or line.condition_range_max:
|
||||
if ((line.amount < line.condition_range_min) or (line.amount > line.condition_range_max)):
|
||||
value = value
|
||||
if line.condition_range_min or line.condition_range_max:
|
||||
if ((line.amount < line.condition_range_min) or (line.amount > line.condition_range_max)):
|
||||
value = value
|
||||
else:
|
||||
value = line.amount
|
||||
else:
|
||||
value = line.amount
|
||||
else:
|
||||
value = line.amount
|
||||
elif line.amount_type=='code':
|
||||
localdict = {'basic':amt}
|
||||
exec line.python_code in localdict
|
||||
value = localdict['result']
|
||||
total += value
|
||||
|
||||
vals = {
|
||||
'category_id': line.category_id.id,
|
||||
'name': line.name,
|
||||
|
@ -1008,12 +1010,18 @@ class hr_payslip(osv.osv):
|
|||
# 'function_id': False,
|
||||
'base': line.computational_expression
|
||||
}
|
||||
if line.appears_on_payslip and not line.parent_rule_id:
|
||||
if line.condition_range_min or line.condition_range_max:
|
||||
if not ((value < line.condition_range_min) or (value > line.condition_range_max)):
|
||||
update['value']['line_ids'].append(vals)
|
||||
if line.appears_on_payslip:
|
||||
if line.parent_rule_id:
|
||||
for l in salary_rule_pool.browse(cr, uid, [line.parent_rule_id.id], context=context):
|
||||
if l.display_child_rules == True:
|
||||
update['value']['line_ids'].append(vals)
|
||||
else:
|
||||
update['value']['line_ids'].append(vals)
|
||||
if line.condition_range_min or line.condition_range_max:
|
||||
if not ((value < line.condition_range_min) or (value > line.condition_range_max)):
|
||||
update['value']['line_ids'].append(vals)
|
||||
else:
|
||||
update['value']['line_ids'].append(vals)
|
||||
|
||||
basic = contract.wage
|
||||
number = sequence_obj.get(cr, uid, 'salary.slip')
|
||||
update['value'].update({
|
||||
|
@ -1120,6 +1128,7 @@ class hr_payslip(osv.osv):
|
|||
'worked_days': working_day - leave,
|
||||
'working_days': working_day,
|
||||
})
|
||||
|
||||
return update
|
||||
|
||||
hr_payslip()
|
||||
|
@ -1215,6 +1224,7 @@ class hr_salary_rule(osv.osv):
|
|||
'active':fields.boolean('Active'),
|
||||
'python_code': fields.text('Python code'),
|
||||
'python_compute':fields.text('Python Code'),
|
||||
'display_child_rules': fields.boolean('Display Child Rules', help="Used for the display of Child Rules on payslip"),
|
||||
}
|
||||
_defaults = {
|
||||
'python_compute': '''# basic\n\nresult = basic * 0.10''',
|
||||
|
|
|
@ -632,6 +632,7 @@
|
|||
<page string="Child Rules">
|
||||
<separator colspan="4" string="Children definition"/>
|
||||
<field name="child_depend"/>
|
||||
<field name="display_child_rules"/>
|
||||
<field colspan="4" name="child_ids" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Description">
|
||||
|
|
Loading…
Reference in New Issue