[IMP] change for amount_type='code' on hr.salary.rule object improve the calculation for the same

bzr revid: psi@tinyerp.co.in-20110317113535-7o5j9gz8bf3g8zmx
This commit is contained in:
psi (Open ERP) 2011-03-17 17:05:35 +05:30
parent 468631afd7
commit aeb88e7675
2 changed files with 13 additions and 15 deletions

View File

@ -991,8 +991,8 @@ class hr_payslip(osv.osv):
else:
value = line.amount
elif line.amount_type=='code':
localdict = {'basic':amt}
exec line.python_code in localdict
localdict = {'basic':amt, 'employee':employee_id, 'contract':contract}
exec line.python_compute in localdict
value = localdict['result']
total += value
vals = {
@ -1172,16 +1172,17 @@ class hr_payslip_line(osv.osv):
('per','Percentage (%)'),
('fix','Fixed Amount'),
('code','Python Code'),
],'Amount Type', select=True, required=True),
'amount': fields.float('Amount / Percentage', digits=(16, 4)),
],'Amount Type', select=True, required=True, help="The computation method for the rule amount."),
'amount': fields.float('Amount / Percentage', digits_compute=dp.get_precision('Account'), help="For rule of type percentage, enter % ratio between 0-1."),
'total': fields.float('Sub Total', digits_compute=dp.get_precision('Account')),
'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, 4)),
'company_contrib': fields.float('Company Contribution', readonly=True, digits_compute=dp.get_precision('Account')),
'sequence': fields.integer('Sequence'),
'note':fields.text('Description'),
}
_order = 'sequence'
_defaults = {
'amount_type': 'per'
'amount_type': 'per',
'amount': 0.0,
}
hr_payslip_line()
@ -1213,11 +1214,10 @@ class hr_salary_rule(osv.osv):
'conditions':fields.char('Condition', size=1024, required=True, readonly=False, help='Applied this head for calculation if condition is true'),
'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'),
'active':fields.boolean('Active'),
'python_code': fields.text('Python code'),
'python_compute':fields.text('Python Code'),
}
_defaults = {
'python_compute': '''# basic\n\nresult = basic * 0.10''',
'python_compute': '''# basic\n# employee: hr.employee object or None\n# contract: hr.contract object or None\n\nresult = basic * 0.10''',
'conditions': 'True',
'computational_expression': 'basic',
'sequence': 5,

View File

@ -162,7 +162,7 @@
<field name="category_id" on_change="onchange_category(category_id)"/>
<field name="type"/>
<field name="amount_type"/>
<field name="amount" on_change="onchange_amount(amount, amount_type)" attrs="{'readonly':[('amount_type','=','func')]}"/>
<field name="amount" on_change="onchange_amount(amount, amount_type)" attrs="{'readonly':[('amount_type','=','code')]}"/>
<field name="sequence" groups="base.group_extended"/>
</group>
<group col="2" colspan="2">
@ -233,7 +233,7 @@
<field name="category_id" on_change="onchange_category(category_id)"/>
<field name="type"/>
<field name="amount_type"/>
<field name="amount" on_change="onchange_amount(amount, amount_type)" attrs="{'readonly':[('amount_type','=','func')]}"/>
<field name="amount" on_change="onchange_amount(amount, amount_type)" attrs="{'readonly':[('amount_type','=','code')]}"/>
<field name="sequence" groups="base.group_extended"/>
</group>
<group col="2" colspan="2">
@ -605,12 +605,10 @@
<field name="category_id" on_change="onchange_category(category_id)"/>
<field name="type"/>
<field name="amount_type"/>
<field name="amount" on_change="onchange_amount(amount, amount_type)" attrs="{'readonly':[('amount_type','=','func')]}"/>
<field name="amount" on_change="onchange_amount(amount, amount_type)" attrs="{'readonly':[('amount_type','=','code')]}"/>
<field name="conditions"/>
<field name="condition_range_min"/>
<field name="condition_range_max"/>
<separator colspan="2" string="Compute Code"/>
<field colspan="2" name="python_compute" nolabel="1" attrs="{'readonly':[('amount_type','!=','code')], 'required':[('amount_type','=','code')]}"/>
</group>
<group col="2" colspan="2">
<group col="2" colspan="2">
@ -623,8 +621,8 @@
<field name="computational_expression" colspan="4" nolabel="1"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Applicable code (if Amount Type = Python code)"/>
<field name="python_code" nolabel="1" attrs="{'readonly':[('amount_type','!=','code')],'required':[('amount_type','=','code')]}"/>
<separator colspan="2" string="Compute Code"/>
<field colspan="2" name="python_compute" nolabel="1" attrs="{'readonly':[('amount_type','!=','code')], 'required':[('amount_type','=','code')]}"/>
</group>
</group>
</group>