[IMP] hr_contract_salary: Remove hr.contract.advantage.template model

It was a failed attempt to make somethig generic. Sometimes we are not the only ones to choose.

Closes #28727
This commit is contained in:
Yannick Tivisse
2018-12-06 13:45:59 +01:00
parent cc2703026a
commit db0de92122
9 changed files with 111 additions and 160 deletions
-24
View File
@@ -29,27 +29,3 @@ class HrContract(models.Model):
"""
structures = self.mapped('struct_id')
return structures._get_parent_structure() if structures else self.env['hr.payroll.structure']
@api.multi
def get_attribute(self, code, attribute):
return self.env['hr.contract.advantage.template'].search([('code', '=', code)], limit=1)[attribute]
@api.multi
def set_attribute_value(self, code, active):
for contract in self:
if active:
value = self.env['hr.contract.advantage.template'].search([('code', '=', code)], limit=1).default_value
contract[code] = value
else:
contract[code] = 0.0
class HrContractAdvandageTemplate(models.Model):
_name = 'hr.contract.advantage.template'
_description = "Employee's Advantage on Contract"
name = fields.Char('Name', required=True)
code = fields.Char('Code', required=True)
lower_bound = fields.Float('Lower Bound', help="Lower bound authorized by the employer for this advantage")
upper_bound = fields.Float('Upper Bound', help="Upper bound authorized by the employer for this advantage")
default_value = fields.Float('Default value for this advantage')
@@ -9,7 +9,5 @@ access_hr_payslip_input_user,hr.payslip.input.user,model_hr_payslip_input,hr_pay
access_hr_payslip_worked_days_officer,hr.payslip.worked_days.officer,model_hr_payslip_worked_days,hr_payroll.group_hr_payroll_user,1,1,1,1
access_hr_payslip_run,hr.payslip.run,model_hr_payslip_run,hr_payroll.group_hr_payroll_manager,1,1,1,1
access_hr_salary_rule_user,hr.salary.rule.user,model_hr_salary_rule,hr_payroll.group_hr_payroll_user,1,1,1,1
access_hr_contract_advantage_template,hr.contract.advantage.template.user,model_hr_contract_advantage_template,hr_payroll.group_hr_payroll_user,1,1,1,1
access_hr_contract_advantage_template_hr_user,hr.contract.advantage.template.hr.user,model_hr_contract_advantage_template,hr.group_hr_user,1,0,0,0
access_hr_benefit,access_hr_benefit,model_hr_benefit,group_hr_payroll_user,1,1,1,1
access_hr_benefit_type,access_hr_benefit_type,model_hr_benefit_type,group_hr_payroll_user,1,1,1,1
access_hr_benefit_type,access_hr_benefit_type,model_hr_benefit_type,group_hr_payroll_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
9 access_hr_payslip_worked_days_officer hr.payslip.worked_days.officer model_hr_payslip_worked_days hr_payroll.group_hr_payroll_user 1 1 1 1
10 access_hr_payslip_run hr.payslip.run model_hr_payslip_run hr_payroll.group_hr_payroll_manager 1 1 1 1
11 access_hr_salary_rule_user hr.salary.rule.user model_hr_salary_rule hr_payroll.group_hr_payroll_user 1 1 1 1
access_hr_contract_advantage_template hr.contract.advantage.template.user model_hr_contract_advantage_template hr_payroll.group_hr_payroll_user 1 1 1 1
access_hr_contract_advantage_template_hr_user hr.contract.advantage.template.hr.user model_hr_contract_advantage_template hr.group_hr_user 1 0 0 0
12 access_hr_benefit access_hr_benefit model_hr_benefit group_hr_payroll_user 1 1 1 1
13 access_hr_benefit_type access_hr_benefit_type model_hr_benefit_type group_hr_payroll_user 1 1 1 1
@@ -24,58 +24,4 @@
</xpath>
</field>
</record>
<record id="hr_contract_advantage_template_view_form" model="ir.ui.view">
<field name="name">hr.contract.advantage.template.form</field>
<field name="model">hr.contract.advantage.template</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_title">
<h1>
<field name="name" placeholder="Advantage Name"/>
</h1>
</div>
<group>
<group>
<field name="code"/>
</group>
</group>
<group>
<group>
<field name="default_value"/>
<field name="lower_bound"/>
<field name="upper_bound"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="hr_contract_advantage_template_view_tree" model="ir.ui.view">
<field name="name">hr.contract.advantage.template.tree</field>
<field name="model">hr.contract.advantage.template</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="code"/>
<field name="lower_bound"/>
<field name="upper_bound"/>
<field name="default_value"/>
</tree>
</field>
</record>
<record id="hr_contract_advantage_template_action" model="ir.actions.act_window">
<field name="name">Contract Advantage Templates</field>
<field name="res_model">hr.contract.advantage.template</field>
<field name="view_type">form</field>
</record>
<menuitem
id="hr_contract_advantage_template_menu_action"
action="hr_contract_advantage_template_action"
parent="menu_hr_payroll_configuration"
sequence="50"/>
</odoo>
@@ -23,5 +23,6 @@ Belgian Payroll Rules.
'data': [
'views/l10n_be_hr_payroll_view.xml',
'data/l10n_be_hr_payroll_data.xml',
'views/res_config_settings_views.xml',
],
}
@@ -533,63 +533,14 @@ result = -min(ip_amount * tax_rate, 11745)
<field name="parent_id" ref="hr_payroll.structure_base"/>
</record>
<!-- Salary advantages definition -->
<record id="hr_contract_advantage_template_meal_voucher_amount" model="hr.contract.advantage.template">
<field name="name">Check Value Meal</field>
<field name="code">meal_voucher_amount</field>
<field name="default_value">7.45</field>
</record>
<record id="hr_contract_advantage_template_internet" model="hr.contract.advantage.template">
<field name="name">Internet</field>
<field name="code">internet</field>
<field name="default_value">38.0</field>
</record>
<record id="hr_contract_advantage_template_mobile" model="hr.contract.advantage.template">
<field name="name">Mobile</field>
<field name="code">mobile</field>
<field name="default_value">30.0</field>
</record>
<record id="hr_contract_advantage_template_mobile_plus" model="hr.contract.advantage.template">
<field name="name">Mobile +</field>
<field name="code">mobile_plus</field>
<field name="default_value">50.0</field>
</record>
<record id="hr_contract_advantage_template_additional_net_amount" model="hr.contract.advantage.template">
<field name="name">Net supplements</field>
<field name="code">additional_net_amount</field>
</record>
<record id="hr_contract_advantage_template_retained_net_amount" model="hr.contract.advantage.template">
<field name="name">Net retained</field>
<field name="code">retained_net_amount</field>
</record>
<record id="hr_contract_advantage_template_commission_on_target" model="hr.contract.advantage.template">
<field name="name">Commission on target</field>
<field name="code">commission_on_target</field>
<field name="default_value">0.0</field>
</record>
<record id="hr_contract_advantage_template_fuel_card" model="hr.contract.advantage.template">
<field name="name">Fuel card</field>
<field name="code">fuel_card</field>
<field name="default_value">150.0</field>
<field name="lower_bound">0.0</field>
<field name="upper_bound">500.0</field>
</record>
<record id="hr_contract_advantage_template_holidays" model="hr.contract.advantage.template">
<field name="name">Leaves duration</field>
<field name="code">holidays</field>
<field name="default_value">20.0</field>
<field name="lower_bound">0.0</field>
<field name="upper_bound">35.0</field>
</record>
<record id="hr_contract_advantage_template_representation_fees" model="hr.contract.advantage.template">
<field name="name">Representation fees</field>
<field name="code">representation_fees</field>
<field name="default_value">150.0</field>
</record>
<record id="hr_contract_advantage_template_eco_checks" model="hr.contract.advantage.template">
<field name="name">Eco-checks</field>
<field name="code">eco_checks</field>
<field name="default_value">250.0</field>
</record>
<!-- Default advantage values -->
<function model="ir.default" name="set" eval="('hr.contract', 'holidays', 20.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'commission_on_target', 0.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'fuel_card', 150.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'representation_fees', 150.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'internet', 38.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'mobile', 30.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'mobile_plus', 50.0)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'meal_voucher_amount', 7.45)"/>
<function model="ir.default" name="set" eval="('hr.contract', 'eco_checks', 250.0)"/>
</odoo>
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import l10n_be_hr_payroll
from . import res_config_settings
@@ -41,35 +41,27 @@ class HrContract(models.Model):
# Advantages
commission_on_target = fields.Monetary(string="Commission on Target",
default=lambda self: self.get_attribute('commission_on_target', 'default_value'),
track_visibility="onchange",
help="Monthly gross amount that the employee receives if the target is reached.")
fuel_card = fields.Monetary(string="Fuel Card",
default=lambda self: self.get_attribute('fuel_card', 'default_value'),
track_visibility="onchange",
help="Monthly amount the employee receives on his fuel card.")
internet = fields.Monetary(string="Internet",
default=lambda self: self.get_attribute('internet', 'default_value'),
track_visibility="onchange",
help="The employee's internet subcription will be paid up to this amount.")
representation_fees = fields.Monetary(string="Representation Fees",
default=lambda self: self.get_attribute('representation_fees', 'default_value'),
track_visibility="onchange",
help="Monthly net amount the employee receives to cover his representation fees.")
mobile = fields.Monetary(string="Mobile",
default=lambda self: self.get_attribute('mobile', 'default_value'),
track_visibility="onchange",
help="The employee's mobile subscription will be paid up to this amount.")
mobile_plus = fields.Monetary(string="International Communication",
default=lambda self: self.get_attribute('mobile_plus', 'default_value'),
track_visibility="onchange",
help="The employee's mobile subscription for international communication will be paid up to this amount.")
meal_voucher_amount = fields.Monetary(string="Meal Vouchers",
default=lambda self: self.get_attribute('meal_voucher_amount', 'default_value'),
track_visibility="onchange",
help="Amount the employee receives in the form of meal vouchers per worked day.")
holidays = fields.Float(string='Legal Leaves',
default=lambda self: self.get_attribute('holidays', 'default_value'),
help="Number of days of paid leaves the employee gets per year.")
holidays_editable = fields.Boolean(string="Editable Leaves", default=True)
holidays_compensation = fields.Monetary(compute='_compute_holidays_compensation', string="Holidays Compensation")
@@ -82,7 +74,6 @@ class HrContract(models.Model):
track_visibility="onchange",
help="Monthly net amount that is retained on the employee's salary.")
eco_checks = fields.Monetary("Eco Vouchers",
default=lambda self: self.get_attribute('eco_checks', 'default_value'),
help="Yearly amount the employee receives in the form of eco vouchers.")
ip = fields.Boolean(default=False, track_visibility="onchange")
ip_wage_rate = fields.Float(string="IP percentage", help="Should be between 0 and 100 %")
@@ -227,19 +218,12 @@ class HrContract(models.Model):
if self.mobile_plus and not self.mobile:
raise ValidationError(_('You should have a mobile subscription to select an international communication amount.'))
def _get_internet_amount(self, has_internet):
if has_internet:
return self.get_attribute('internet', 'default_value')
else:
return 0.0
def _get_mobile_amount(self, has_mobile, international_communication):
if has_mobile and international_communication:
return self.get_attribute('mobile', 'default_value') + self.get_attribute('mobile_plus', 'default_value')
elif has_mobile:
return self.get_attribute('mobile', 'default_value')
else:
return 0.0
return self.env['ir.default'].sudo().get('hr.contract', 'mobile') + self.env['ir.default'].sudo().get('hr.contract', 'mobile_plus')
if has_mobile:
return self.env['ir.default'].sudo().get('hr.contract', 'mobile')
return 0.0
def _get_gross_from_employer_costs(self, yearly_cost):
contract = self
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
default_holidays = fields.Float(string="Legal Leaves", default_model="hr.contract")
default_commission_on_target = fields.Float(string="Commission on Target", default_model="hr.contract")
default_fuel_card = fields.Float(string="Fuel Card", default_model="hr.contract")
default_representation_fees = fields.Float(string="Representation Fees", default_model="hr.contract")
default_internet = fields.Float(string="Internet", default_model="hr.contract")
default_mobile = fields.Float(string="Mobile", default_model="hr.contract")
default_mobile_plus = fields.Float(string="International Communication", default_model="hr.contract")
default_meal_voucher_amount = fields.Float(string="Meal Vouchers", default_model="hr.contract")
default_eco_checks = fields.Float(string="Eco Vouchers", default_model="hr.contract")
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.l10n_be_hr_payroll</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="45"/>
<field name="inherit_id" ref="hr_payroll.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='hr_payroll_accountant']" position="after">
<h2>Belgian Locatization</h2>
<div class="row mt16 o_settings_container" id="l10n_be_hr_payroll">
<div class="col-lg-6 col-12 o_setting_box">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<label for="default_holidays" string="Advantages"/>
<div class="text-muted">
Configure Default Values for Belgian Advantages
</div>
<group class="mt16">
<label for="default_holidays"/>
<div class="o_row">
<field name="default_holidays" nolabel="1"/>
<span>days / year</span>
</div>
<label for="default_commission_on_target"/>
<div class="o_row">
<field name="default_commission_on_target" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_fuel_card"/>
<div class="o_row">
<field name="default_fuel_card" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_representation_fees"/>
<div class="o_row">
<field name="default_representation_fees" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_internet"/>
<div class="o_row">
<field name="default_internet" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_mobile"/>
<div class="o_row">
<field name="default_mobile" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_internet"/>
<div class="o_row">
<field name="default_internet" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_mobile_plus"/>
<div class="o_row">
<field name="default_mobile_plus" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_meal_voucher_amount"/>
<div class="o_row">
<field name="default_meal_voucher_amount" nolabel="1"/>
<span>€ / month</span>
</div>
<label for="default_eco_checks"/>
<div class="o_row">
<field name="default_eco_checks" nolabel="1"/>
<span>€ / year</span>
</div>
</group>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>