Skip to content
Permalink
Browse files

Introduce salary structure category

  • Loading branch information...
tivisse committed Mar 13, 2019
1 parent 43c5eec commit 9fab9071888b11b6f02e7f29f316d0cfd311e6ce
@@ -2,22 +2,6 @@
<odoo>
<data noupdate="1">

<!-- Contract Types -->
<record id="hr_contract_type_emp" model="hr.contract.type">
<field name="name">Employee</field>
<field name="sequence">5</field>
</record>

<record id="hr_contract_type_wrkr" model="hr.contract.type">
<field name="name">Worker</field>
<field name="sequence">10</field>
</record>

<record id="hr_contract_type_sub" model="hr.contract.type">
<field name="name">Subcontractor</field>
<field name="sequence">15</field>
</record>

<!-- Contract-related subtypes for messaging / Chatter -->
<record id="mt_contract_pending" model="mail.message.subtype">
<field name="name">To Renew</field>
@@ -3,7 +3,6 @@

<record id="hr_contract_admin" model="hr.contract">
<field name="name">Mitchell Admin Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y')+'-1-1'"/>
<field name="employee_id" ref="hr.employee_admin"/>
<field name="job_id" model="hr.job"
@@ -16,7 +15,6 @@

<record id="hr_contract_al" model="hr.contract">
<field name="name">Ronnie Hart Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y')+'-1-1'"/>
<field name="employee_id" ref="hr.employee_al"/>
<field name="job_id" model="hr.job"
@@ -29,7 +27,6 @@

<record id="hr_contract_mit" model="hr.contract">
<field name="name">Marketing Executive Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y')+'-3-1'"/>
<field name="employee_id" ref="hr.employee_mit"/>
<field name="job_id" model="hr.job"
@@ -42,7 +39,6 @@

<record id="hr_contract_stw" model="hr.contract">
<field name="name">Randall Lewis Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y')+'-2-1'"/>
<field name="date_end" eval="time.strftime('%Y')+'-12-1'"/>
<field name="employee_id" ref="hr.employee_stw"/>
@@ -56,7 +52,6 @@

<record id="hr_contract_qdp" model="hr.contract">
<field name="name">Demo Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y')+'-3-1'"/>
<field name="employee_id" ref="hr.employee_qdp"/>
<field name="job_id" model="hr.job"
@@ -69,7 +64,6 @@

<record id="hr_contract_han" model="hr.contract">
<field name="name">Walter Horton Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y')+'-3-1'"/>
<field name="employee_id" ref="hr.employee_han"/>
<field name="job_id" model="hr.job"
@@ -82,7 +76,6 @@

<record id="hr_contract_niv" model="hr.contract">
<field name="name">Sharlene Rhodes Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="date_end" eval="time.strftime('%Y')+'-12-1'"/>
<field name="employee_id" ref="hr.employee_niv"/>
@@ -96,7 +89,6 @@

<record id="hr_contract_jth" model="hr.contract">
<field name="name">Toni Jimenez</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="date_end" eval="time.strftime('%Y')+'-12-1'"/>
<field name="employee_id" ref="hr.employee_jth"/>
@@ -110,7 +102,6 @@

<record id="hr_contract_chs" model="hr.contract">
<field name="name">Jennie Fletcher Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="employee_id" ref="hr.employee_chs"/>
<field name="job_id" model="hr.job"
@@ -123,7 +114,6 @@

<record id="hr_contract_jve" model="hr.contract">
<field name="name">Paul Williams Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="employee_id" ref="hr.employee_jve"/>
<field name="job_id" model="hr.job"
@@ -136,7 +126,6 @@

<record id="hr_contract_fme" model="hr.contract">
<field name="name">Keith Byrd Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="'2015-1-1'"/>
<field name="date_end" eval="time.strftime('%Y-%m-%d')"/>
<field name="employee_id" ref="hr.employee_fme"/>
@@ -150,7 +139,6 @@

<record id="hr_contract_fpi" model="hr.contract">
<field name="name">Audrey Peterson Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="'2015-1-1'"/>
<field name="date_end" eval="'2017-12-1'"/>
<field name="employee_id" ref="hr.employee_fpi"/>
@@ -164,7 +152,6 @@

<record id="hr_contract_vad" model="hr.contract">
<field name="name">Tina Williamson Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="'2015-1-1'"/>
<field name="date_end" eval="'2018-2-1'"/>
<field name="employee_id" ref="hr.employee_vad"/>
@@ -48,18 +48,7 @@ def _get_all_contracts(self, date_from, date_to, states=['open', 'pending']):
return self.search([])._get_contracts(date_from, date_to, states=states)


class ContractType(models.Model):

_name = 'hr.contract.type'
_description = 'Contract Type'
_order = 'sequence, id'

name = fields.Char(string='Contract Type', required=True)
sequence = fields.Integer(help="Gives the sequence when displaying a list of Contract.", default=10)


class Contract(models.Model):

_name = 'hr.contract'
_description = 'Contract'
_inherit = ['mail.thread', 'mail.activity.mixin']
@@ -68,7 +57,6 @@ class Contract(models.Model):
active = fields.Boolean(default=True)
employee_id = fields.Many2one('hr.employee', string='Employee')
department_id = fields.Many2one('hr.department', string="Department")
type_id = fields.Many2one('hr.contract.type', string="Employee Category", required=True, default=lambda self: self.env['hr.contract.type'].search([], limit=1))
job_id = fields.Many2one('hr.job', string='Job Position')
date_start = fields.Date('Start Date', required=True, default=fields.Date.today,
help="Start date of the contract.")
@@ -2,5 +2,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_resource_manager,hr.employee.resource.manager,resource.model_resource_resource,hr.group_hr_manager,1,1,1,1
access_hr_resource_calendar_user,hr.employee.resource.calendar.user,resource.model_resource_calendar,hr.group_hr_user,1,1,1,1
access_hr_resource_calendar_attendance_user,hr.employee.resource.calendar.attendance.user,resource.model_resource_calendar_attendance,hr.group_hr_user,1,1,1,1
access_hr_contract_type_manager,hr.contract.type.manager,model_hr_contract_type,hr_contract.group_hr_contract_manager,1,1,1,1
access_hr_contract_manager,hr.contract.manager,model_hr_contract,hr_contract.group_hr_contract_manager,1,1,1,1
@@ -83,7 +83,6 @@
<group expand="0" string="Group By">
<filter string="Employee" name="employee" domain="[]" context="{'group_by':'employee_id'}"/>
<filter string="Job" name="job" domain="[]" context="{'group_by':'job_id'}"/>
<filter string="Employee Category" name="contract_type" domain="[]" context="{'group_by':'type_id'}"/>
<filter string="State" name='group_by_state' domain="[]" context="{'group_by': 'state'}"/>
</group>
</search>
@@ -117,7 +116,6 @@
<field name="job_id"/>
</group>
<group>
<field name="type_id"/>
<field name="reported_to_secretariat" widget="toggle_button" options='{"active": "Reported to the social secretariat", "inactive": "To report to the social secretariat"}'/>
</group>
</group>
@@ -174,7 +172,6 @@
<field name="name"/>
<field name="employee_id"/>
<field name="job_id"/>
<field name="type_id"/>
<field name="resource_calendar_id"/>
<field name="date_start"/>
<field name="date_end"/>
@@ -239,64 +236,12 @@
</field>
</record>

<record id="hr_contract_type_view_form" model="ir.ui.view">
<field name="name">hr.contract.type.form</field>
<field name="model">hr.contract.type</field>
<field name="arch" type="xml">
<form string="Contract Type">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="hr_contract_type_view_tree" model="ir.ui.view">
<field name="name">hr.contract.type.tree</field>
<field name="model">hr.contract.type</field>
<field name="arch" type="xml">
<tree string="Contract Type">
<field name="sequence" widget="handle"/>
<field colspan="4" name="name"/>
</tree>
</field>
</record>

<record id="hr_contract_type_view_search" model="ir.ui.view">
<field name="name">hr.contract.type.search</field>
<field name="model">hr.contract.type</field>
<field name="arch" type="xml">
<search string="Search Contract Type">
<field name="name" string="Contract Type"/>
<field name="sequence" string="Sequence"/>
</search>
</field>
</record>

<record id="action_hr_contract_type" model="ir.actions.act_window">
<field name="name">Contract Types</field>
<field name="res_model">hr.contract.type</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="hr_contract_type_view_search"/>
</record>

<menuitem
id="menu_human_resources_configuration_contract"
name="Contracts"
parent="hr.menu_human_resources_configuration"
sequence="3"/>

<menuitem
id="hr_menu_contract_type"
name="Types"
action="action_hr_contract_type"
parent="hr_contract.menu_human_resources_configuration_contract"
sequence="3"
groups="base.group_no_one"/>

<menuitem
id="hr_menu_contract"
name="Contracts"
@@ -2,6 +2,10 @@
<odoo>
<data noupdate="0">

<record id="structure_type_employee" model="hr.payroll.structure.type">
<field name="name">Employee</field>
</record>

<record id="resource.resource_calendar_std" model="resource.calendar">
<field name="full_time_required_hours">40</field>
</record>
@@ -24,6 +24,7 @@
<record id="structure_002" model="hr.payroll.structure">
<field name="code">MEGG</field>
<field name="name">Marketing Executive for Gilles Gravie</field>
<field name="type_id" ref="structure_type_employee"/>
</record>

<!-- Salary Rules for Marketing Executive for Gilles Gravie-->
@@ -110,7 +111,6 @@

<record id="hr_contract_firstcontract1" model="hr.contract">
<field name="name">Marketing Executive Contract</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="date_end" eval="time.strftime('%Y')+'-12-31'"/>
<field name="struct_id" ref="hr_payroll.structure_002"/>
@@ -122,7 +122,6 @@

<record id="hr_contract_gilles_gravie" model="hr.contract">
<field name="name">Contract For Gilles Gravie</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="date_end" eval="time.strftime('%Y')+'-12-31'"/>
<field name="struct_id" ref="hr_payroll.structure_002"/>
@@ -133,7 +132,6 @@

<record id="hr_contract_admin" model="hr.contract">
<field name="name">Contract For Mitchell Admin</field>
<field name="type_id" ref="hr_contract.hr_contract_type_emp"/>
<field name="date_start" eval="time.strftime('%Y-%m')+'-1'"/>
<field name="date_end" eval="time.strftime('%Y')+'-12-31'"/>
<field name="struct_id" ref="hr_payroll.structure_002"/>
@@ -4,11 +4,13 @@
from odoo import api, fields, models
from datetime import date


class HrContract(models.Model):
_inherit = 'hr.contract'
_description = 'Employee Contract'

struct_id = fields.Many2one('hr.payroll.structure', string='Salary Structure')
structure_type_id = fields.Many2one(related='struct_id.type_id')
schedule_pay = fields.Selection([
('monthly', 'Monthly'),
('quarterly', 'Quarterly'),
@@ -20,7 +22,6 @@ class HrContract(models.Model):
], string='Scheduled Pay', index=True, default='monthly',
help="Defines the frequency of the wage payment.")
resource_calendar_id = fields.Many2one(required=True, help="Employee's working schedule.")

hours_per_week = fields.Float(related='resource_calendar_id.hours_per_week')
full_time_required_hours = fields.Float(related='resource_calendar_id.full_time_required_hours')
is_fulltime = fields.Boolean(related='resource_calendar_id.is_fulltime')
@@ -29,6 +30,13 @@ class HrContract(models.Model):
def _check_contracts(self):
self._get_leaves()._check_contracts()

@api.onchange('struct_id')
def _onchange_struct_id(self):
if self.struct_id.type_id.default_schedule_pay:
self.schedule_pay = self.struct_id.type_id.default_schedule_pay
if self.struct_id.type_id.default_resource_calendar_id:
self.resource_calendar_id = self.struct_id.type_id.default_resource_calendar_id

@api.multi
def _get_leaves(self):
return self.env['hr.leave'].search([
@@ -8,12 +8,6 @@
from odoo.addons import decimal_precision as dp

class HrPayrollStructure(models.Model):
"""
Salary structure used to defined
- Basic
- Allowances
- Deductions
"""
_name = 'hr.payroll.structure'
_description = 'Salary Structure'

@@ -56,6 +50,7 @@ def _get_default_rule_ids(self):

name = fields.Char(required=True)
code = fields.Char(string='Reference', required=True)
type_id = fields.Many2one('hr.payroll.structure.type', default=lambda self: self.env.ref('hr_payroll.structure_type_employee', raise_if_not_found=False))
country_id = fields.Many2one('res.country', string='Country')
note = fields.Text(string='Description')
rule_ids = fields.One2many(
@@ -74,6 +69,24 @@ def copy(self, default=None):
return super(HrPayrollStructure, self).copy(default)


class HrPayrollStructureType(models.Model):
_name = 'hr.payroll.structure.type'
_description = 'Salary Structure Type'

name = fields.Char('Structure Type')
default_schedule_pay = fields.Selection([
('monthly', 'Monthly'),
('quarterly', 'Quarterly'),
('semi-annually', 'Semi-annually'),
('annually', 'Annually'),
('weekly', 'Weekly'),
('bi-weekly', 'Bi-weekly'),
('bi-monthly', 'Bi-monthly'),
], string='Default Scheduled Pay', default='monthly',
help="Defines the frequency of the wage payment.")
default_resource_calendar_id = fields.Many2one(
'resource.calendar', 'Default Working Hours')

class HrContributionRegister(models.Model):
_name = 'hr.contribution.register'
_description = 'Contribution Register'
@@ -13,3 +13,4 @@ access_hr_benefit,access_hr_benefit,model_hr_benefit,group_hr_payroll_user,1,1,1
access_hr_benefit_type_officer,access_hr_benefit_type_officer,model_hr_benefit_type,group_hr_payroll_user,1,0,0,0
access_hr_benefit_employee,hr.benefit.employee,model_hr_user_benefit_employee,group_hr_payroll_user,1,1,1,1
access_hr_benefit_type_manager,access_hr_benefit_type_manager,model_hr_benefit_type,group_hr_payroll_manager,1,1,1,1
access_hr_payroll_structure_type,hr.payroll.structure.type,model_hr_payroll_structure_type,hr_payroll.group_hr_payroll_user,1,1,1,1
Oops, something went wrong.

0 comments on commit 9fab907

Please sign in to comment.
You can’t perform that action at this time.