[IMP] hr_payroll:removed company contribution object and merged it with salry rules
bzr revid: mtr@mtr-20110301095910-y1qhf82zms1lubrs
This commit is contained in:
parent
8798384504
commit
5778a97065
|
@ -696,97 +696,97 @@ class payment_category(osv.osv):
|
|||
}
|
||||
payment_category()
|
||||
|
||||
class company_contribution(osv.osv):
|
||||
"""
|
||||
Company contribution
|
||||
Allows to configure company contribution for some taxes
|
||||
"""
|
||||
|
||||
_name = 'company.contribution'
|
||||
_description = "Company Contribution"
|
||||
_columns = {
|
||||
# 'category_id':fields.many2one('hr.salary.rule', 'Heads', required=False),
|
||||
'name':fields.char('Name', size=256, required=True, readonly=False),
|
||||
'code':fields.char('Code', size=64, required=True, readonly=False),
|
||||
'gratuity':fields.boolean('Use for Gratuity ?', required=False),
|
||||
'line_ids':fields.one2many('company.contribution.line', 'contribution_id', 'Calculations', required=False),
|
||||
'register_id':fields.property(
|
||||
'hr.contibution.register',
|
||||
type='many2one',
|
||||
relation='hr.contibution.register',
|
||||
string="Contribution Register",
|
||||
method=True,
|
||||
view_load=True,
|
||||
help="Contribution register based on company",
|
||||
required=False
|
||||
),
|
||||
'amount_type':fields.selection([
|
||||
('fix','Fixed Amount'),
|
||||
('per','Percentage'),
|
||||
('func','Function Calculation'),
|
||||
],'Amount Type', select=True),
|
||||
'contribute_per':fields.float('Contribution', digits=(16, 4), help='Define Company contribution ratio 1.00=100% contribution.'),
|
||||
'company_id':fields.many2one('res.company', 'Company', required=False),
|
||||
'active':fields.boolean('Active', required=False),
|
||||
'note': fields.text('Description'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'amount_type': lambda *a:'fix',
|
||||
'active': lambda *a:True,
|
||||
'company_id': lambda self, cr, uid, context: \
|
||||
self.pool.get('res.users').browse(cr, uid, uid,
|
||||
context=context).company_id.id,
|
||||
}
|
||||
|
||||
def _execute_function(self, cr, uid, id, value, context=None):
|
||||
"""
|
||||
self: pointer to self object
|
||||
cr: cursor to database
|
||||
uid: user id of current executer
|
||||
"""
|
||||
line_pool = self.pool.get('company.contribution.line')
|
||||
res = 0
|
||||
ids = line_pool.search(cr, uid, [('category_id','=',id), ('to_val','>=',value),('from_val','<=',value)], context=context)
|
||||
if not ids:
|
||||
ids = line_pool.search(cr, uid, [('category_id','=',id), ('from','<=',value)], context=context)
|
||||
if not ids:
|
||||
res = 0
|
||||
else:
|
||||
res = line_pool.browse(cr, uid, ids, context=context)[0].value
|
||||
return res
|
||||
|
||||
def compute(self, cr, uid, id, value, context=None):
|
||||
contrib = self.browse(cr, uid, id, context=context)
|
||||
if contrib.amount_type == 'fix':
|
||||
return contrib.contribute_per
|
||||
elif contrib.amount_type == 'per':
|
||||
return value * contrib.contribute_per
|
||||
elif contrib.amount_type == 'func':
|
||||
return self._execute_function(cr, uid, id, value, context)
|
||||
return 0.0
|
||||
company_contribution()
|
||||
|
||||
class company_contribution_line(osv.osv):
|
||||
"""
|
||||
Company contribution lines
|
||||
"""
|
||||
|
||||
_name = 'company.contribution.line'
|
||||
_description = 'Allowance Deduction Category'
|
||||
_order = 'sequence'
|
||||
_columns = {
|
||||
'contribution_id':fields.many2one('company.contribution', 'Contribution', required=False),
|
||||
'name':fields.char('Name', size=64, required=False, readonly=False),
|
||||
'from_val': fields.float('From', digits=(16, 4)),
|
||||
'to_val': fields.float('To', digits=(16, 4)),
|
||||
'amount_type':fields.selection([
|
||||
('fix','Fixed Amount'),
|
||||
],'Amount Type', select=True),
|
||||
'sequence':fields.integer('Sequence'),
|
||||
'value': fields.float('Value', digits=(16, 4)),
|
||||
}
|
||||
company_contribution_line()
|
||||
#class company_contribution(osv.osv):
|
||||
# """
|
||||
# Company contribution
|
||||
# Allows to configure company contribution for some taxes
|
||||
# """
|
||||
#
|
||||
# _name = 'company.contribution'
|
||||
# _description = "Company Contribution"
|
||||
# _columns = {
|
||||
## 'category_id':fields.many2one('hr.salary.rule', 'Heads', required=False),
|
||||
# 'name':fields.char('Name', size=256, required=True, readonly=False),
|
||||
# 'code':fields.char('Code', size=64, required=True, readonly=False),
|
||||
# 'gratuity':fields.boolean('Use for Gratuity ?', required=False),
|
||||
# 'line_ids':fields.one2many('company.contribution.line', 'contribution_id', 'Calculations', required=False),
|
||||
# 'register_id':fields.property(
|
||||
# 'hr.contibution.register',
|
||||
# type='many2one',
|
||||
# relation='hr.contibution.register',
|
||||
# string="Contribution Register",
|
||||
# method=True,
|
||||
# view_load=True,
|
||||
# help="Contribution register based on company",
|
||||
# required=False
|
||||
# ),
|
||||
# 'amount_type':fields.selection([
|
||||
# ('fix','Fixed Amount'),
|
||||
# ('per','Percentage'),
|
||||
# ('func','Function Calculation'),
|
||||
# ],'Amount Type', select=True),
|
||||
# 'contribute_per':fields.float('Contribution', digits=(16, 4), help='Define Company contribution ratio 1.00=100% contribution.'),
|
||||
# 'company_id':fields.many2one('res.company', 'Company', required=False),
|
||||
# 'active':fields.boolean('Active', required=False),
|
||||
# 'note': fields.text('Description'),
|
||||
# }
|
||||
#
|
||||
# _defaults = {
|
||||
# 'amount_type': lambda *a:'fix',
|
||||
# 'active': lambda *a:True,
|
||||
# 'company_id': lambda self, cr, uid, context: \
|
||||
# self.pool.get('res.users').browse(cr, uid, uid,
|
||||
# context=context).company_id.id,
|
||||
# }
|
||||
#
|
||||
# def _execute_function(self, cr, uid, id, value, context=None):
|
||||
# """
|
||||
# self: pointer to self object
|
||||
# cr: cursor to database
|
||||
# uid: user id of current executer
|
||||
# """
|
||||
# line_pool = self.pool.get('company.contribution.line')
|
||||
# res = 0
|
||||
# ids = line_pool.search(cr, uid, [('category_id','=',id), ('to_val','>=',value),('from_val','<=',value)], context=context)
|
||||
# if not ids:
|
||||
# ids = line_pool.search(cr, uid, [('category_id','=',id), ('from','<=',value)], context=context)
|
||||
# if not ids:
|
||||
# res = 0
|
||||
# else:
|
||||
# res = line_pool.browse(cr, uid, ids, context=context)[0].value
|
||||
# return res
|
||||
#
|
||||
# def compute(self, cr, uid, id, value, context=None):
|
||||
# contrib = self.browse(cr, uid, id, context=context)
|
||||
# if contrib.amount_type == 'fix':
|
||||
# return contrib.contribute_per
|
||||
# elif contrib.amount_type == 'per':
|
||||
# return value * contrib.contribute_per
|
||||
# elif contrib.amount_type == 'func':
|
||||
# return self._execute_function(cr, uid, id, value, context)
|
||||
# return 0.0
|
||||
#company_contribution()
|
||||
#
|
||||
#class company_contribution_line(osv.osv):
|
||||
# """
|
||||
# Company contribution lines
|
||||
# """
|
||||
#
|
||||
# _name = 'company.contribution.line'
|
||||
# _description = 'Allowance Deduction Category'
|
||||
# _order = 'sequence'
|
||||
# _columns = {
|
||||
# 'contribution_id':fields.many2one('company.contribution', 'Contribution', required=False),
|
||||
# 'name':fields.char('Name', size=64, required=False, readonly=False),
|
||||
# 'from_val': fields.float('From', digits=(16, 4)),
|
||||
# 'to_val': fields.float('To', digits=(16, 4)),
|
||||
# 'amount_type':fields.selection([
|
||||
# ('fix','Fixed Amount'),
|
||||
# ],'Amount Type', select=True),
|
||||
# 'sequence':fields.integer('Sequence'),
|
||||
# 'value': fields.float('Value', digits=(16, 4)),
|
||||
# }
|
||||
#company_contribution_line()
|
||||
|
||||
class hr_holidays_status(osv.osv):
|
||||
|
||||
|
@ -954,7 +954,7 @@ class hr_payslip(osv.osv):
|
|||
return True
|
||||
|
||||
def verify_sheet(self, cr, uid, ids, context=None):
|
||||
register_pool = self.pool.get('company.contribution')
|
||||
# register_pool = self.pool.get('company.contribution')
|
||||
register_line_pool = self.pool.get('hr.contibution.register.line')
|
||||
|
||||
for slip in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -963,25 +963,25 @@ class hr_payslip(osv.osv):
|
|||
'net':slip.net,
|
||||
'gross':slip.grows,
|
||||
}
|
||||
rules = slip.contract_id.struct_id.rule_ids
|
||||
if rules:
|
||||
for rl in rules:
|
||||
if rl.contribute_ids:
|
||||
base[rl.code.lower()] = rl.amount
|
||||
for contrib in rl.contribute_ids:
|
||||
if contrib.register_id:
|
||||
value = eval(rl.category_id.base, base)
|
||||
company_contrib = register_pool.compute(cr, uid, contrib.id, value, context)
|
||||
reg_line = {
|
||||
'name':rl.name,
|
||||
'register_id': contrib.register_id.id,
|
||||
'code':rl.code,
|
||||
'employee_id':slip.employee_id.id,
|
||||
'emp_deduction':rl.amount,
|
||||
'comp_deduction':company_contrib,
|
||||
'total':rl.amount + rl.amount
|
||||
}
|
||||
register_line_pool.create(cr, uid, reg_line)
|
||||
# rules = slip.contract_id.struct_id.rule_ids
|
||||
# if rules:
|
||||
# for rl in rules:
|
||||
# if rl.contribute_ids:
|
||||
# base[rl.code.lower()] = rl.amount
|
||||
# for contrib in rl.contribute_ids:
|
||||
# if contrib.register_id:
|
||||
# value = eval(rl.category_id.base, base)
|
||||
# company_contrib = register_pool.compute(cr, uid, contrib.id, value, context)
|
||||
# reg_line = {
|
||||
# 'name':rl.name,
|
||||
# 'register_id': contrib.register_id.id,
|
||||
# 'code':rl.code,
|
||||
# 'employee_id':slip.employee_id.id,
|
||||
# 'emp_deduction':rl.amount,
|
||||
# 'comp_deduction':company_contrib,
|
||||
# 'total':rl.amount + rl.amount
|
||||
# }
|
||||
# register_line_pool.create(cr, uid, reg_line)
|
||||
|
||||
self.write(cr, uid, ids, {'state':'confirm'}, context=context)
|
||||
return True
|
||||
|
@ -1369,10 +1369,11 @@ class hr_salary_rule(osv.osv):
|
|||
'active': fields.boolean('Active'),
|
||||
'min_range': fields.float('Minimum Range', required=False),
|
||||
'max_range': fields.float('Maximum Range', required=False),
|
||||
'contribute_ids':fields.one2many('company.contribution', 'category_id', 'Contributions', required=False),
|
||||
'sal_rule_id':fields.many2one('hr.salary.rule', 'Parent Salary Structure', select=True),
|
||||
'child_depend':fields.boolean('Children Rule'),
|
||||
'child_ids':fields.one2many('hr.salary.rule', 'sal_rule_id', 'Child Salary Sructure'),
|
||||
'company_id':fields.many2one('res.company', 'Company', required=False),
|
||||
'register_id':fields.many2one('hr.contibution.register', 'Contri Reg', select=True),
|
||||
}
|
||||
_defaults = {
|
||||
'active': 1
|
||||
|
@ -1410,15 +1411,6 @@ class hr_payroll_structure(osv.osv):
|
|||
|
||||
hr_payroll_structure()
|
||||
|
||||
class company_contribution(osv.osv):
|
||||
|
||||
_inherit = 'company.contribution'
|
||||
_columns = {
|
||||
'category_id':fields.many2one('hr.salary.rule', 'Heads', required=False),
|
||||
}
|
||||
|
||||
company_contribution()
|
||||
|
||||
class hr_employee(osv.osv):
|
||||
'''
|
||||
Employee
|
||||
|
|
|
@ -498,9 +498,9 @@
|
|||
<group col="6" colspan="6">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="active" />
|
||||
<field name="type" select="1"/>
|
||||
<field name="sequence"/>
|
||||
<field name="type" select="1"/>
|
||||
<field name="active"/>
|
||||
<group col="2" colspan="4">
|
||||
<separator colspan="4" string="Expression"/>
|
||||
<field name="base" colspan="4" nolabel="1"/>
|
||||
|
@ -511,6 +511,7 @@
|
|||
<field name="condition"/>
|
||||
</group>
|
||||
</group>
|
||||
<separator colspan="4" string="Description"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Description">
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
|
@ -571,7 +572,7 @@
|
|||
<!-- End Payment Heads -->
|
||||
|
||||
<!-- Company Contribution -->
|
||||
<record id="hr_company_contribution_form" model="ir.ui.view">
|
||||
<!-- <record id="hr_company_contribution_form" model="ir.ui.view">
|
||||
<field name="name">company.contribution.form</field>
|
||||
<field name="model">company.contribution</field>
|
||||
<field name="type">form</field>
|
||||
|
@ -663,7 +664,7 @@
|
|||
id="menu_hr_company_contribution_tree"
|
||||
action="action_hr_company_contribution_tree"
|
||||
parent="payroll_configure"
|
||||
/>
|
||||
/>-->
|
||||
<!-- End Company Contribution -->
|
||||
|
||||
<record id="view_hr_bank_advice_tree" model="ir.ui.view">
|
||||
|
@ -938,6 +939,8 @@
|
|||
<group col="2" colspan="2">
|
||||
<separator colspan="4" string="Company contribution"/>
|
||||
<field name="company_contrib"/>
|
||||
<field name="register_id"/>
|
||||
<field name="company_id"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Child Rules" groups="base.group_extended">
|
||||
|
@ -957,44 +960,6 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Contribution">
|
||||
<field name="contribute_ids" colspan="4" nolabel="1" >
|
||||
<form string="Company Contribution">
|
||||
<group col="6" colspan="6">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator colspan="2" string="Contributions"/>
|
||||
<field name="amount_type" attrs="{'required': [('contribute','=',True)]}"/>
|
||||
<field name="contribute_per" attrs="{'required': [('contribute','=',True)], 'readonly':[(('amount_type','=','func'))]}"/>
|
||||
<field name="register_id" attrs="{'required': [('contribute','=',True)]}"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator colspan="2" string="Other Information"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection" select="1"/>
|
||||
<field name="active" select="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Function" attrs="{'readonly': [('amount_type','!=','func')]}">
|
||||
<field name="line_ids" colspan="4" nolabel="1">
|
||||
<tree string="Function Arguments" editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
<field name="from_val"/>
|
||||
<field name="to_val"/>
|
||||
<field name="amount_type"/>
|
||||
<field name="value"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Description">
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Description">
|
||||
<separator colspan="4" string="Description"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
"access_hr_contibution_register","hr.contibution.register","model_hr_contibution_register","base.group_hr_user",1,1,1,1
|
||||
"access_hr_contibution_register_line","hr.contibution.register.line","model_hr_contibution_register_line","base.group_hr_user",1,1,1,1
|
||||
"access_hr_allounce_deduction_category","hr.allounce.deduction.category","model_hr_allounce_deduction_categoty","base.group_hr_user",1,1,1,1
|
||||
"access_company_contribution","company.contribution","model_company_contribution","base.group_hr_user",1,1,1,1
|
||||
"access_company_contribution_line","company.contribution.line","model_company_contribution_line","base.group_hr_user",1,1,1,1
|
||||
"access_hr_payslip","hr.payslip","model_hr_payslip","base.group_hr_user",1,1,1,1
|
||||
"access_hr_payslip_line","hr.payslip.line","model_hr_payslip_line","base.group_hr_user",1,1,1,1
|
||||
"access_hr_payslip_line_line","hr.payslip.line.line","model_hr_payslip_line_line","base.group_hr_user",1,1,1,1
|
||||
|
|
|
Loading…
Reference in New Issue