[IMP] improve code so it will calculate lines for type=code
bzr revid: psi@tinyerp.co.in-20110314133428-cey6umex57d62po8
This commit is contained in:
parent
748259854c
commit
fd1bf58bfb
|
@ -976,9 +976,10 @@ class hr_payslip(osv.osv):
|
|||
value = line.amount
|
||||
else:
|
||||
value = line.amount
|
||||
# elif line.amount_type == 'code': # Need some clarification so this option remains
|
||||
# value = slip_line_pool.execute_function(cr, uid, line.id, amt, context)
|
||||
# line.amount = value
|
||||
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,
|
||||
|
@ -1200,8 +1201,10 @@ class hr_salary_rule(osv.osv):
|
|||
'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': '''# price_unit\n\nresult = basic * 0.10''',
|
||||
'conditions': 'True',
|
||||
'computational_expression': 'basic',
|
||||
'sequence': 5,
|
||||
|
|
|
@ -81,9 +81,9 @@
|
|||
<field name="parent_id"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Salary Rules">
|
||||
<field colspan="4" name="rule_ids" nolabel="1" />
|
||||
</page>
|
||||
<page string="Salary Rules">
|
||||
<field colspan="4" name="rule_ids" nolabel="1" />
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
|
@ -599,33 +599,35 @@
|
|||
</group>
|
||||
<notebook colspan="6">
|
||||
<page string="General">
|
||||
<group col="6" colspan="6">
|
||||
<group col="2" colspan="2">
|
||||
<separator colspan="4" string="Calculations"/>
|
||||
<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="conditions"/>
|
||||
<field name="condition_range_min"/>
|
||||
<field name="condition_range_max"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<group col="2" colspan="2">
|
||||
<separator colspan="4" string="Company contribution"/>
|
||||
<field name="register_id"/>
|
||||
<field name="company_contrib"/>
|
||||
</group>
|
||||
<group col="2" colspan="4">
|
||||
<separator colspan="4" string="Computational Expression"/>
|
||||
<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')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group col="6" colspan="6">
|
||||
<group col="2" colspan="2">
|
||||
<separator colspan="4" string="Calculations"/>
|
||||
<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="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">
|
||||
<separator colspan="4" string="Company contribution"/>
|
||||
<field name="register_id"/>
|
||||
<field name="company_contrib"/>
|
||||
</group>
|
||||
<group col="2" colspan="4">
|
||||
<separator colspan="4" string="Computational Expression"/>
|
||||
<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')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Child Rules">
|
||||
<separator colspan="4" string="Children definition"/>
|
||||
|
|
Loading…
Reference in New Issue