[IMP] hr_payroll: renamed hr.salary.category into hr.salary.rule.category

bzr revid: mtr@mtr-20110511071854-ctdf3czpedhe5t6l
This commit is contained in:
mtr 2011-05-11 12:48:54 +05:30
parent 46303f0eb0
commit 7ae069998e
4 changed files with 40 additions and 40 deletions

View File

@ -164,17 +164,17 @@ class contrib_register(osv.osv):
contrib_register()
class hr_salary_category(osv.osv):
class hr_salary_rule_category(osv.osv):
"""
HR Salary Category
HR Salary Rule Category
"""
_name = 'hr.salary.category'
_description = 'Salary Category'
_name = 'hr.salary.rule.category'
_description = 'Salary Rule 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.category', 'Parent', help="Linking a salary category to its parent is used only for the reporting purpose."),
'parent_id':fields.many2one('hr.salary.rule.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),
}
@ -185,7 +185,7 @@ class hr_salary_category(osv.osv):
context=context).company_id.id,
}
hr_salary_category()
hr_salary_rule_category()
class one2many_mod2(fields.one2many):
@ -210,11 +210,11 @@ class hr_payslip(osv.osv):
_name = 'hr.payslip'
_description = 'Pay Slip'
def _get_lines_salary_category(self, cr, uid, ids, field_names, arg=None, context=None):
def _get_lines_salary_rule_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_category AS sh on (pl.category_id = sh.id) \
LEFT JOIN hr_salary_rule_category AS sh on (pl.category_id = sh.id) \
WHERE pl.slip_id in %s \
GROUP BY pl.slip_id, pl.sequence, pl.id ORDER BY pl.sequence''',(tuple(ids),))
res = cr.fetchall()
@ -251,7 +251,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_category': fields.function(_get_lines_salary_category, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Head'),
'details_by_salary_rule_category': fields.function(_get_lines_salary_rule_category, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Rule Category'),
'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another"),
}
_defaults = {
@ -471,9 +471,9 @@ class hr_payslip(osv.osv):
return res
def get_payslip_lines(self, cr, uid, contract_ids, payslip_id, context):
def _sum_salary_category(localdict, category, amount):
def _sum_salary_rule_category(localdict, category, amount):
if category.parent_id:
localdict = _sum_salary_category(localdict, category.parent_id, amount)
localdict = _sum_salary_rule_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
@ -508,7 +508,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 category
localdict = _sum_salary_category(localdict, rule.category_id, amount - previous_amount)
localdict = _sum_salary_rule_category(localdict, rule.category_id, amount - previous_amount)
#create/overwrite the rule in the temporary results
result_dict[key] = {
'salary_rule_id': rule.id,
@ -641,7 +641,7 @@ class hr_salary_rule(osv.osv):
'code':fields.char('Code', size=64, required=True, help="The code of salary rules can be used as reference in computation of other rules. In that case, it is case sensitive."),
'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.category', 'Category', required=True),
'category_id':fields.many2one('hr.salary.rule.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),
@ -681,7 +681,7 @@ class hr_salary_rule(osv.osv):
# employee: hr.employee object
# contract: hr.contract object
# rules: rules code (previously computed)
# categories: dictionary containing the computed categories (sum of amount of all rules belonging to that category). Keys are the category codes.
# categories: dictionary containing the computed salary rule 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'
@ -695,7 +695,7 @@ result = contract.wage * 0.10''',
# employee: hr.employee object
# contract: hr.contract object
# rules: rules code (previously computed)
# categories: dictionary containing the computed categories (sum of amount of all rules belonging to that category). Keys are the category codes.
# categories: dictionary containing the computed salary rule 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'

View File

@ -2,32 +2,32 @@
<openerp>
<data noupdate="1">
<record id="BASIC" model="hr.salary.category">
<record id="BASIC" model="hr.salary.rule.category">
<field name="name">Basic</field>
<field name="code">BASIC</field>
</record>
<record id="ALW" model="hr.salary.category">
<record id="ALW" model="hr.salary.rule.category">
<field name="name">Allowance</field>
<field name="code">ALW</field>
</record>
<record id="DED" model="hr.salary.category">
<record id="DED" model="hr.salary.rule.category">
<field name="name">Deduction</field>
<field name="code">DED</field>
</record>
<record id="GROSS" model="hr.salary.category">
<record id="GROSS" model="hr.salary.rule.category">
<field name="name">Gross</field>
<field name="code">GROSS</field>
</record>
<record id="NET" model="hr.salary.category">
<record id="NET" model="hr.salary.rule.category">
<field name="name">Net</field>
<field name="code">NET</field>
</record>
<record id="COMP" model="hr.salary.category">
<record id="COMP" model="hr.salary.rule.category">
<field name="name">Company Contribution</field>
<field name="code">COMP</field>
</record>

View File

@ -260,8 +260,8 @@
</field>
</page>
<!-- TODO: put me back -->
<page string="Details By Salary Category">
<field name="details_by_salary_category" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
<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">
<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"/>
<!-- Salary Category-->
<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>
<record id="hr_salary_rule_category_form" model="ir.ui.view">
<field name="name">hr.salary.rule.category.form</field>
<field name="model">hr.salary.rule.category</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Salary Categories">
@ -364,9 +364,9 @@
</field>
</record>
<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>
<record id="hr_salary_rule_category_tree" model="ir.ui.view">
<field name="name">hr.salary.rule.category.tree</field>
<field name="model">hr.salary.rule.category</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Salary Rule Categories">
@ -377,9 +377,9 @@
</field>
</record>
<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>
<record id="view_hr_salary_rule_category_filter" model="ir.ui.view">
<field name="name">hr.salary.rule.category.select</field>
<field name="model">hr.salary.rule.category</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Salary Rule Categories">
@ -389,16 +389,16 @@
</field>
</record>
<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>
<record id="action_hr_salary_rule_category" model="ir.actions.act_window">
<field name="name">Salary Rule Categories</field>
<field name="res_model">hr.salary.rule.category</field>
<field name="view_type">form</field>
<field name="view_id" ref="hr_salary_category_tree"/>
<field name="search_view_id" ref="view_hr_salary_category_filter"/>
<field name="view_id" ref="hr_salary_rule_category_tree"/>
<field name="search_view_id" ref="view_hr_salary_rule_category_filter"/>
</record>
<menuitem
id="menu_hr_salary_category"
action="action_hr_salary_category"
id="menu_hr_salary_rule_category"
action="action_hr_salary_rule_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_category","hr.salary.category","model_hr_salary_category","base.group_hr_user",1,1,1,1
"access_hr_salary_rule_category","hr.salary.rule.category","model_hr_salary_rule_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_hr_payslip_input_user","hr.payslip.input.user","model_hr_payslip_input","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_category access_hr_salary_rule_category hr.salary.category hr.salary.rule.category model_hr_salary_category model_hr_salary_rule_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_hr_payslip_input_user hr.payslip.input.user model_hr_payslip_input base.group_hr_user 1 1 1 1