[IMP] hr_payroll: renamed salary head into salary category

bzr revid: mtr@mtr-20110510115411-lkf923pyakj1ykug
This commit is contained in:
mtr 2011-05-10 17:24:11 +05:30
parent efdb84c905
commit 84739f218e
4 changed files with 46 additions and 46 deletions

View File

@ -164,17 +164,17 @@ class contrib_register(osv.osv):
contrib_register()
class hr_salary_head(osv.osv):
class hr_salary_category(osv.osv):
"""
HR Salary Head
HR Salary Category
"""
_name = 'hr.salary.head'
_description = 'Salary Head'
_name = 'hr.salary.category'
_description = 'Salary Category'
_columns = {
'name':fields.char('Name', size=64, required=True, readonly=False),
'code':fields.char('Code', size=64, required=True, readonly=False),
'parent_id':fields.many2one('hr.salary.head', 'Parent', help="Linking a salary head to its parent is used only for the reporting purpose."),
'parent_id':fields.many2one('hr.salary.category', 'Parent', help="Linking a salary category to its parent is used only for the reporting purpose."),
'note': fields.text('Description'),
'company_id':fields.many2one('res.company', 'Company', required=False),
'sequence': fields.integer('Sequence', required=True, help='Display sequence order'),
@ -187,7 +187,7 @@ class hr_salary_head(osv.osv):
'sequence': 5
}
hr_salary_head()
hr_salary_category()
class one2many_mod2(fields.one2many):
@ -212,11 +212,11 @@ class hr_payslip(osv.osv):
_name = 'hr.payslip'
_description = 'Pay Slip'
def _get_lines_salary_head(self, cr, uid, ids, field_names, arg=None, context=None):
def _get_lines_salary_category(self, cr, uid, ids, field_names, arg=None, context=None):
result = {}
if not ids: return result
cr.execute('''SELECT pl.slip_id, pl.id FROM hr_payslip_line AS pl \
LEFT JOIN hr_salary_head AS sh on (pl.category_id = sh.id) \
LEFT JOIN hr_salary_category AS sh on (pl.category_id = sh.id) \
WHERE pl.slip_id in %s \
GROUP BY pl.slip_id, sh.sequence, pl.sequence, pl.id ORDER BY sh.sequence, pl.sequence''',(tuple(ids),))
res = cr.fetchall()
@ -253,7 +253,7 @@ class hr_payslip(osv.osv):
'paid': fields.boolean('Made Payment Order ? ', required=False, readonly=True, states={'draft': [('readonly', False)]}),
'note': fields.text('Description'),
'contract_id': fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'draft': [('readonly', False)]}),
'details_by_salary_head': fields.function(_get_lines_salary_head, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Head'),
'details_by_salary_category': fields.function(_get_lines_salary_category, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Head'),
'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another"),
}
_defaults = {
@ -473,10 +473,10 @@ class hr_payslip(osv.osv):
return res
def get_payslip_lines(self, cr, uid, contract_ids, payslip_id, context):
def _sum_salary_head(localdict, head, amount):
if head.parent_id:
localdict = _sum_salary_head(localdict, head.parent_id, amount)
localdict['heads'][head.code] = head.code in localdict['heads'] and localdict['heads'][head.code] + amount or amount
def _sum_salary_category(localdict, category, amount):
if category.parent_id:
localdict = _sum_salary_category(localdict, category.parent_id, amount)
localdict['categories'][category.code] = category.code in localdict['categories'] and localdict['categories'][category.code] + amount or amount
return localdict
#we keep a dict with the result because a value can be overwritten by another rule with the same code
@ -487,7 +487,7 @@ class hr_payslip(osv.osv):
worked_days = {}
for input_line in payslip.input_line_ids:
worked_days[input_line.code] = input_line
localdict = {'heads': {}, 'payslip': payslip, 'worked_days': worked_days}
localdict = {'categories': {}, 'payslip': payslip, 'worked_days': worked_days}
#get the ids of the structures on the contracts and their parent id as well
structure_ids = self.pool.get('hr.contract').get_all_structures(cr, uid, contract_ids, context=context)
#get the rules of the structure and thier children
@ -510,7 +510,7 @@ class hr_payslip(osv.osv):
#set/overwrite the amount computed for this rule in the localdict
localdict[rule.code] = amount
#sum the amount for its salary head
localdict = _sum_salary_head(localdict, rule.category_id, amount - previous_amount)
localdict = _sum_salary_category(localdict, rule.category_id, amount - previous_amount)
#create/overwrite the rule in the temporary results
result_dict[key] = {
'salary_rule_id': rule.id,
@ -644,7 +644,7 @@ class hr_salary_rule(osv.osv):
'code':fields.char('Code', size=64, required=True),
'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'),
'quantity': fields.char('Quantity', size=256, help="It is used in computation for percentage and fixed amount.For e.g. A rule for Meal Voucher having fixed amount of 1€ per worked day can have its quantity defined in expression like worked_days['WORK100']['number_of_days']."),
'category_id':fields.many2one('hr.salary.head', 'Salary Head', required=True),
'category_id':fields.many2one('hr.salary.category', 'Category', required=True),
'active':fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the salary rule without removing it."),
'appears_on_payslip': fields.boolean('Appears on Payslip', help="Used for the display of rule on payslip"),
'parent_rule_id':fields.many2one('hr.salary.rule', 'Parent Salary Rule', select=True),
@ -684,7 +684,7 @@ class hr_salary_rule(osv.osv):
# employee: hr.employee object
# contract: hr.contract object
# rules: rules code (previously computed)
# heads: dictionary containing the computed heads (sum of amount of all rules belonging to that head). Keys are the head codes.
# categories: dictionary containing the computed categories (sum of amount of all rules belonging to that category). Keys are the category codes.
# worked_days: dictionary containing the computed worked days. Keys are the worked days codes.
# Note: returned value have to be set in the variable 'result'
@ -698,12 +698,12 @@ result = contract.wage * 0.10''',
# employee: hr.employee object
# contract: hr.contract object
# rules: rules code (previously computed)
# heads: dictionary containing the computed heads (sum of amount of all rules belonging to that head). Keys are the head codes.
# categories: dictionary containing the computed categories (sum of amount of all rules belonging to that category). Keys are the category codes.
# worked_days: dictionary containing the computed worked days. Keys are the worked days codes.
# Note: returned value have to be set in the variable 'result'
result = rules['NET'] > heads['NET'] * 0.10''',
result = rules['NET'] > categories['NET'] * 0.10''',
'condition_range': 'contract.wage',
'sequence': 5,
'appears_on_payslip': True,

View File

@ -2,32 +2,32 @@
<openerp>
<data noupdate="1">
<record id="BASIC" model="hr.salary.head">
<record id="BASIC" model="hr.salary.category">
<field name="name">Basic</field>
<field name="code">BASIC</field>
</record>
<record id="ALW" model="hr.salary.head">
<record id="ALW" model="hr.salary.category">
<field name="name">Allowance</field>
<field name="code">ALW</field>
</record>
<record id="DED" model="hr.salary.head">
<record id="DED" model="hr.salary.category">
<field name="name">Deduction</field>
<field name="code">DED</field>
</record>
<record id="GROSS" model="hr.salary.head">
<record id="GROSS" model="hr.salary.category">
<field name="name">Gross</field>
<field name="code">GROSS</field>
</record>
<record id="NET" model="hr.salary.head">
<record id="NET" model="hr.salary.category">
<field name="name">Net</field>
<field name="code">NET</field>
</record>
<record id="COMP" model="hr.salary.head">
<record id="COMP" model="hr.salary.category">
<field name="name">Company Contribution</field>
<field name="code">COMP</field>
</record>
@ -177,7 +177,7 @@
<field name="category_id" ref="hr_payroll.GROSS"/>
<field name="condition_select">none</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = heads['BASIC'] + ('ALW' in heads and heads['ALW'] or 0.0)</field>
<field name="amount_python_compute">result = categories['BASIC'] + ('ALW' in categories and categories['ALW'] or 0.0)</field>
</record>
<record id="hr_rule_net" model="hr.salary.rule">
@ -187,7 +187,7 @@
<field name="category_id" ref="hr_payroll.NET"/>
<field name="condition_select">none</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = heads['BASIC'] + ('ALW' in heads and heads['ALW'] or 0.0) + ('DED' in heads and heads['DED'] or 0.0)</field>
<field name="amount_python_compute">result = categories['BASIC'] + ('ALW' in categories and categories['ALW'] or 0.0) + ('DED' in categories and categories['DED'] or 0.0)</field>
</record>

View File

@ -260,8 +260,8 @@
</field>
</page>
<!-- TODO: put me back -->
<page string="Details By Salary Head">
<field name="details_by_salary_head" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
<page string="Details By Salary Category">
<field name="details_by_salary_category" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
<tree string="Payslip Lines" colors="blue:total == 0">
<field name="category_id"/>
<field name="name"/>
@ -347,9 +347,9 @@
<menuitem action="action_view_hr_payslip_form" id="menu_department_tree" parent="menu_hr_root_payroll"/>
<!-- Payment Heads -->
<record id="hr_salary_head_form" model="ir.ui.view">
<field name="name">hr.salary.head.form</field>
<field name="model">hr.salary.head</field>
<record id="hr_salary_category_form" model="ir.ui.view">
<field name="name">hr.salary.category.form</field>
<field name="model">hr.salary.category</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Salary Heads">
@ -365,9 +365,9 @@
</field>
</record>
<record id="hr_salary_head_tree" model="ir.ui.view">
<field name="name">hr.salary.head.tree</field>
<field name="model">hr.salary.head</field>
<record id="hr_salary_category_tree" model="ir.ui.view">
<field name="name">hr.salary.category.tree</field>
<field name="model">hr.salary.category</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Salary Heads">
@ -379,9 +379,9 @@
</field>
</record>
<record id="view_hr_salary_head_filter" model="ir.ui.view">
<field name="name">hr.salary.head.select</field>
<field name="model">hr.salary.head</field>
<record id="view_hr_salary_category_filter" model="ir.ui.view">
<field name="name">hr.salary.category.select</field>
<field name="model">hr.salary.category</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Salary Heads">
@ -391,16 +391,16 @@
</field>
</record>
<record id="action_hr_salary_head" model="ir.actions.act_window">
<field name="name">Salary Heads</field>
<field name="res_model">hr.salary.head</field>
<record id="action_hr_salary_category" model="ir.actions.act_window">
<field name="name">Salary Categories</field>
<field name="res_model">hr.salary.category</field>
<field name="view_type">form</field>
<field name="view_id" ref="hr_salary_head_tree"/>
<field name="search_view_id" ref="view_hr_salary_head_filter"/>
<field name="view_id" ref="hr_salary_category_tree"/>
<field name="search_view_id" ref="view_hr_salary_category_filter"/>
</record>
<menuitem
id="menu_hr_salary_head"
action="action_hr_salary_head"
id="menu_hr_salary_category"
action="action_hr_salary_category"
parent="payroll_configure"
sequence="11"
/>

View File

@ -1,7 +1,7 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_hr_payroll_structure","hr.payroll.structure","model_hr_payroll_structure","base.group_hr_user",1,1,1,1
"access_hr_contribution_register","hr.contribution.register","model_hr_contribution_register","base.group_hr_user",1,1,1,1
"access_hr_salary_head","hr.salary.head","model_hr_salary_head","base.group_hr_user",1,1,1,1
"access_hr_salary_category","hr.salary.category","model_hr_salary_category","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_res_partner_payroll","res.partner.payroll","base.model_res_partner","base.group_hr_user",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_hr_payroll_structure hr.payroll.structure model_hr_payroll_structure base.group_hr_user 1 1 1 1
3 access_hr_contribution_register hr.contribution.register model_hr_contribution_register base.group_hr_user 1 1 1 1
4 access_hr_salary_head access_hr_salary_category hr.salary.head hr.salary.category model_hr_salary_head model_hr_salary_category base.group_hr_user 1 1 1 1
5 access_hr_payslip hr.payslip model_hr_payslip base.group_hr_user 1 1 1 1
6 access_hr_payslip_line hr.payslip.line model_hr_payslip_line base.group_hr_user 1 1 1 1
7 access_res_partner_payroll res.partner.payroll base.model_res_partner base.group_hr_user 1 1 1 1