[MERGE] branch merged with trunk-payroll
bzr revid: mtr@mtr-20110527061311-2tn9n7cbu5gb7l6a
This commit is contained in:
commit
45ec4a4110
|
@ -559,10 +559,11 @@ class hr_payslip(osv.osv):
|
||||||
for rule in obj_rule.browse(cr, uid, sorted_rule_ids, context=context):
|
for rule in obj_rule.browse(cr, uid, sorted_rule_ids, context=context):
|
||||||
key = rule.code + '-' + str(contract.id)
|
key = rule.code + '-' + str(contract.id)
|
||||||
localdict['result'] = None
|
localdict['result'] = None
|
||||||
|
localdict['result_qty'] = 1.0
|
||||||
#check if the rule can be applied
|
#check if the rule can be applied
|
||||||
if obj_rule.satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist:
|
if obj_rule.satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist:
|
||||||
#compute the amount of the rule
|
#compute the amount of the rule
|
||||||
amount = obj_rule.compute_rule(cr, uid, rule.id, localdict, context=context)
|
amount, qty = obj_rule.compute_rule(cr, uid, rule.id, localdict, context=context)
|
||||||
#check if there is already a rule computed with that code
|
#check if there is already a rule computed with that code
|
||||||
previous_amount = rule.code in localdict and localdict[rule.code] or 0.0
|
previous_amount = rule.code in localdict and localdict[rule.code] or 0.0
|
||||||
#set/overwrite the amount computed for this rule in the localdict
|
#set/overwrite the amount computed for this rule in the localdict
|
||||||
|
@ -590,9 +591,9 @@ class hr_payslip(osv.osv):
|
||||||
'amount_percentage': rule.amount_percentage,
|
'amount_percentage': rule.amount_percentage,
|
||||||
'amount_percentage_base': rule.amount_percentage_base,
|
'amount_percentage_base': rule.amount_percentage_base,
|
||||||
'register_id': rule.register_id.id,
|
'register_id': rule.register_id.id,
|
||||||
'total': amount,
|
'amount': amount,
|
||||||
'employee_id': contract.employee_id.id,
|
'employee_id': contract.employee_id.id,
|
||||||
'quantity': rule.quantity,
|
'quantity': qty,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
#blacklist this rule and its children
|
#blacklist this rule and its children
|
||||||
|
@ -815,7 +816,7 @@ result = rules.NET > categories['NET'] * 0.10''',
|
||||||
'amount_select': 'fix',
|
'amount_select': 'fix',
|
||||||
'amount_fix': 0.0,
|
'amount_fix': 0.0,
|
||||||
'amount_percentage': 0.0,
|
'amount_percentage': 0.0,
|
||||||
'quantity': '1',
|
'quantity': '1.0',
|
||||||
}
|
}
|
||||||
|
|
||||||
def _recursive_search_of_rules(self, cr, uid, rule_ids, context=None):
|
def _recursive_search_of_rules(self, cr, uid, rule_ids, context=None):
|
||||||
|
@ -834,24 +835,24 @@ result = rules.NET > categories['NET'] * 0.10''',
|
||||||
"""
|
"""
|
||||||
@param rule_id: id of rule to compute
|
@param rule_id: id of rule to compute
|
||||||
@param localdict: dictionary containing the environement in which to compute the rule
|
@param localdict: dictionary containing the environement in which to compute the rule
|
||||||
@return: returns the result of computation as float
|
@return: returns the result of computation and the quantity as floats
|
||||||
"""
|
"""
|
||||||
rule = self.browse(cr, uid, rule_id, context=context)
|
rule = self.browse(cr, uid, rule_id, context=context)
|
||||||
if rule.amount_select == 'fix':
|
if rule.amount_select == 'fix':
|
||||||
try:
|
try:
|
||||||
return rule.amount_fix * eval(rule.quantity, localdict)
|
return rule.amount_fix, eval(rule.quantity, localdict)
|
||||||
except:
|
except:
|
||||||
raise osv.except_osv(_('Error'), _('Wrong quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
|
raise osv.except_osv(_('Error'), _('Wrong quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
|
||||||
elif rule.amount_select == 'percentage':
|
elif rule.amount_select == 'percentage':
|
||||||
try:
|
try:
|
||||||
amount = rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100
|
amount = rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100
|
||||||
return amount * eval(rule.quantity, localdict)
|
return amount, eval(rule.quantity, localdict)
|
||||||
except:
|
except:
|
||||||
raise osv.except_osv(_('Error'), _('Wrong percentage base or quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
|
raise osv.except_osv(_('Error'), _('Wrong percentage base or quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True)
|
eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True)
|
||||||
return localdict['result']
|
return localdict['result'], 'result_qty' in localdict and localdict['result_qty'] or 1.0
|
||||||
except:
|
except:
|
||||||
raise osv.except_osv(_('Error'), _('Wrong python code defined for salary rule %s (%s) ')% (rule.name, rule.code))
|
raise osv.except_osv(_('Error'), _('Wrong python code defined for salary rule %s (%s) ')% (rule.name, rule.code))
|
||||||
|
|
||||||
|
@ -905,13 +906,22 @@ class hr_payslip_line(osv.osv):
|
||||||
_description = 'Payslip Line'
|
_description = 'Payslip Line'
|
||||||
_order = 'contract_id, sequence'
|
_order = 'contract_id, sequence'
|
||||||
|
|
||||||
|
def _calculate_total(self, cr, uid, ids, name, args, context):
|
||||||
|
if not ids: return {}
|
||||||
|
res = {}
|
||||||
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
|
res[line.id] = float(line.quantity) * line.amount
|
||||||
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'slip_id':fields.many2one('hr.payslip', 'Pay Slip', required=True),
|
'slip_id':fields.many2one('hr.payslip', 'Pay Slip', required=True),
|
||||||
'salary_rule_id':fields.many2one('hr.salary.rule', 'Rule', required=True),
|
'salary_rule_id':fields.many2one('hr.salary.rule', 'Rule', required=True),
|
||||||
'employee_id':fields.many2one('hr.employee', 'Employee', required=True),
|
'employee_id':fields.many2one('hr.employee', 'Employee', required=True),
|
||||||
'contract_id':fields.many2one('hr.contract', 'Contract', required=True),
|
'contract_id':fields.many2one('hr.contract', 'Contract', required=True),
|
||||||
'total': fields.float('Amount', digits_compute=dp.get_precision('Account')),
|
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
|
||||||
|
'quantity': fields.float('Quantity', digits_compute=dp.get_precision('Account')),
|
||||||
'company_contrib': fields.float('Company Contribution', readonly=True, digits_compute=dp.get_precision('Account')),
|
'company_contrib': fields.float('Company Contribution', readonly=True, digits_compute=dp.get_precision('Account')),
|
||||||
|
'total': fields.function(_calculate_total, method=True, type='float', string='Total', digits_compute=dp.get_precision('Account'),store=True ),
|
||||||
}
|
}
|
||||||
|
|
||||||
hr_payslip_line()
|
hr_payslip_line()
|
||||||
|
|
|
@ -141,6 +141,8 @@
|
||||||
<field name="sequence" groups="base.group_extended"/>
|
<field name="sequence" groups="base.group_extended"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
|
<field name="quantity"/>
|
||||||
|
<field name="amount"/>
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
@ -246,6 +248,8 @@
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="category_id"/>
|
<field name="category_id"/>
|
||||||
<field name="sequence" invisible="1"/>
|
<field name="sequence" invisible="1"/>
|
||||||
|
<field name="quantity"/>
|
||||||
|
<field name="amount"/>
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
</tree>
|
</tree>
|
||||||
<form string="Payslip Line">
|
<form string="Payslip Line">
|
||||||
|
@ -254,13 +258,14 @@
|
||||||
<field name="code" select="1"/>
|
<field name="code" select="1"/>
|
||||||
<field name="category_id"/>
|
<field name="category_id"/>
|
||||||
<field name="sequence" groups="base.group_extended"/>
|
<field name="sequence" groups="base.group_extended"/>
|
||||||
|
<field name="quantity"/>
|
||||||
|
<field name="amount"/>
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
<field name="salary_rule_id" groups="base.group_extended"/>
|
<field name="salary_rule_id" groups="base.group_extended"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
<!-- TODO: put me back -->
|
|
||||||
<page string="Details By Salary Rule Category">
|
<page string="Details By Salary Rule Category">
|
||||||
<field name="details_by_salary_rule_category" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
|
<field name="details_by_salary_rule_category" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
|
||||||
<tree string="Payslip Lines" colors="blue:total == 0">
|
<tree string="Payslip Lines" colors="blue:total == 0">
|
||||||
|
|
Loading…
Reference in New Issue