[MERGE] branch merged with trunk-payroll-salary_rules-psi

bzr revid: mtr@mtr-20110309125647-4qv3bwf6rm6j9b5j
This commit is contained in:
mtr
2011-03-09 18:26:47 +05:30
3 changed files with 27 additions and 10 deletions
+21 -5
View File
@@ -96,7 +96,6 @@ class hr_contract(osv.osv):
_columns = {
'struct_id': fields.many2one('hr.payroll.structure', 'Salary Structure'),
'basic': fields.float('Basic Salary', digits_compute=dp.get_precision('Account')), # i think we can remove this because we have wage field on contract ?
#FIXME not needed as we have the resource.calendar? 'working_days_per_week': fields.integer('Working Days', help="No of Working days / week for an employee"),
}
hr_contract()
@@ -1252,16 +1251,33 @@ class hr_employee(osv.osv):
Employee
'''
def _calculate_basic(self, cr, uid, ids, name, args, context):
if not ids: return {}
vals = {}
current_date = datetime.now().strftime('%Y-%m-%d')
for employee in self.browse(cr, uid, ids, context=context):
if not employee.contract_id:
vals[employee.id] = {'basic': 0.0}
continue
cr.execute( 'SELECT SUM(wage) '\
'FROM hr_contract '\
'WHERE employee_id = %s '\
'AND date_start < %s '\
'AND (date_end > %s OR date_end is NULL)',
(employee.id, current_date, current_date))
result = dict(cr.dictfetchone())
vals[employee.id] = {
'basic': result['sum']
}
return vals
_inherit = 'hr.employee'
_description = 'Employee'
_columns = {
'line_ids':fields.one2many('hr.payslip.line', 'employee_id', 'Salary Structure', required=False),
'slip_ids':fields.one2many('hr.payslip', 'employee_id', 'Payslips', required=False, readonly=True),
'otherid': fields.char('Other Id', size=64),
# 'basic': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Basic Salary', digits=(14,2)),
#FIXME the function has to make the sum of basic field of all the hr.contract for this employee that have date_start < now() and now() < date_stop or not date_stop
# 'emp_sal_rule_ids':fields.many2many('hr.salary.rule', 'hr_emp_salary_rule_rel', 'employee_id', 'rule_id', 'Salary Rules', readonly=False),
'basic': fields.function(_calculate_basic, method=True, multi='dc', type='float', string='Basic Salary', digits_compute=dp.get_precision('Account')),
}
hr_employee()
+5 -5
View File
@@ -31,7 +31,7 @@
<record id="hr_payslip_line_professionaltax1" model="hr.salary.rule">
<field name="amount_type">fix</field>
<field eval="15" name="sequence"/>
<field eval="200.0" name="amount"/>
<field eval="-200.0" name="amount"/>
<field name="code">PT</field>
<field name="type" ref="DED"/>
<field name="category_id" ref="hr_payroll.PT"/>
@@ -43,7 +43,7 @@
<record id="hr_payslip_line_providentfund1" model="hr.salary.rule">
<field name="amount_type">per</field>
<field eval="20" name="sequence"/>
<field eval="0.125" name="amount"/>
<field eval="-0.125" name="amount"/>
<field name="code">PF</field>
<field name="type" ref="DED"/>
<field name="category_id" ref="hr_payroll.PF"/>
@@ -51,16 +51,16 @@
<field name="name">Provident Fund</field>
<field name="sequence" eval="50"/>
</record>
<!-- Salary Structure -->
<record id="structure_001" model="hr.payroll.structure">
<field name="code">ME</field>
<field name="name">Marketing Executive</field>
<field eval="[(6, 0, [ref('hr_payslip_line_houserantallowance1'), ref('hr_payslip_line_convanceallowance1'),ref('hr_payslip_line_professionaltax1'),ref('hr_payslip_line_providentfund1')])]" name="rule_ids"/>
<field name="company_id" ref="base.main_company"/>
</record>
<!-- Employee -->
<record id="hr_employee_bonamy0" model="hr.employee">
<field eval="0" name="manager"/>
+1
View File
@@ -20,6 +20,7 @@
<field name="bank_account_id" context="{'display_partner':True, 'partner_id':partner_id}"/>
<field name="place_of_birth"/>
<field name="children"/>
<field name="basic" invisible="1"/>
</group>
<group colspan="2" col="2">
<separator string="Job Info" colspan="2"/>