-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "Payroll Value Table", | ||
"version": "18.0.1.0.0", | ||
"category": "Payroll", | ||
"website": "https://github.com/OCA/payroll", | ||
"license": "LGPL-3", | ||
"author": "Daniel Reis, Odoo Community Association (OCA)", | ||
"depends": ["payroll", "hr_master_data"], | ||
"data": [ | ||
"security/hr_payroll_security.xml", | ||
"security/ir.model.access.csv", | ||
"views/hr_salary_table.xml", | ||
], | ||
"maintainers": ["dreispt"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import hr_contract | ||
from . import hr_payslip | ||
from . import hr_salary_rule | ||
from . import hr_salary_table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class HrContract(models.Model): | ||
_inherit = "hr.contract" | ||
|
||
@api.depends_context("active_date") | ||
@api.depends("contract_values_ids") | ||
def _compute_active_values_ids(self): | ||
active_date = self.env.context.get("active_date") | ||
for contract in self: | ||
contract.active_values_ids = contract.contract_values_ids.filtered( | ||
lambda x: not active_date | ||
or ( | ||
(not x.date_start or x.date_start <= active_date) | ||
and (not x.date_end or x.date_end >= active_date) | ||
) | ||
) | ||
|
||
contract_values_ids = fields.One2many( | ||
comodel_name="hr.employee.data.value", | ||
inverse_name="contract_id", | ||
) | ||
active_values_ids = fields.One2many( | ||
comodel_name="hr.employee.data.value", | ||
compute="_compute_active_values_ids", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from odoo import models | ||
|
||
|
||
class HrPayslip(models.Model): | ||
_inherit = "hr.payslip" | ||
|
||
def _get_employee_contracts(self): | ||
# Set active_date in the context | ||
# To be used to filter active values | ||
self = self.with_context(active_date=self.date_to) | ||
return super()._get_employee_contracts() | ||
|
||
def localdict_hook(self, localdict): | ||
contract = localdict["contract"] | ||
# TODO: Make values a dotnotaion accessible object | ||
localdict["values"] = contract.active_values_ids | ||
return localdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class HrSalaryRule(models.Model): | ||
_inherit = "hr.salary.rule" | ||
|
||
salary_table_lines_ids = fields.One2many( | ||
comodel_name="hr.salary.table.line", | ||
inverse_name="salary_rule_id", | ||
) | ||
active_salary_table_lines_ids = fields.One2many( | ||
comodel_name="hr.salary.table.line", | ||
compute="_compute_active_salary_table_lines_ids", | ||
) | ||
|
||
@api.depends_context("active_date") | ||
@api.depends("salary_table_lines_ids") | ||
def _compute_active_salary_table_lines_ids(self): | ||
""" | ||
Lists only active salary table lines at a provided date. | ||
Used by the Payslip computation to query the salary table. | ||
""" | ||
active_date = self.env.context.get("active_date") | ||
for rule in self: | ||
lines = rule.salary_table_lines_ids.filtered( | ||
lambda x: not active_date | ||
or ( | ||
(not x.date_start or x.date_start <= active_date) | ||
and (not x.date_end or x.date_end >= active_date) | ||
) | ||
) | ||
rule.active_salary_table_lines_ids = lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class HrSalaryTableTemplate(models.Model): | ||
_name = "hr.salary.table.template" | ||
_description = "Salary Table Template" | ||
|
||
name = fields.Char(required=True) | ||
code = fields.Char() | ||
type_1_id = fields.Many2one("hr.data.type") | ||
type_2_id = fields.Many2one("hr.data.type") | ||
type_3_id = fields.Many2one("hr.data.type") | ||
line_ids = fields.One2many( | ||
comodel_name="hr.salary.table", | ||
inverse_name="template_id", | ||
) | ||
note = fields.Text() | ||
active = fields.Boolean(default=True) | ||
|
||
|
||
class HrSalaryTable(models.Model): | ||
_name = "hr.salary.table" | ||
_description = "Salary Table" | ||
|
||
template_id = fields.Many2one("hr.salary.table.template", required=True) | ||
company_id = fields.Many2one("res.company") | ||
salary_rule_id = fields.Many2one("hr.salary.rule", required=True) | ||
date_start = fields.Date() | ||
date_end = fields.Date() | ||
line_ids = fields.One2many( | ||
comodel_name="hr.salary.table.line", | ||
inverse_name="table_id", | ||
) | ||
note = fields.Text() | ||
|
||
|
||
class HrSalaryTableLine(models.Model): | ||
_name = "hr.salary.table.line" | ||
_description = "Salary Table Line" | ||
|
||
table_id = fields.Many2one("hr.salary.table") | ||
template_id = fields.Many2one( | ||
"hr.salary.table.template", related="table_id.template_id", store=True | ||
) | ||
salary_rule_id = fields.Many2one( | ||
"hr.salary.rule", related="table_id.salary_rule_id", store=True | ||
) | ||
type_1_id = fields.Many2one( | ||
"hr.data.type", related="table_id.template_id.type_1_id" | ||
) | ||
type_2_id = fields.Many2one( | ||
"hr.data.type", related="table_id.template_id.type_2_id" | ||
) | ||
type_3_id = fields.Many2one( | ||
"hr.data.type", related="table_id.template_id.type_3_id" | ||
) | ||
company_id = fields.Many2one( | ||
comodel_name="res.company", related="table_id.company_id", store=True | ||
) | ||
date_start = fields.Date(related="table_id.date_start", store=True) | ||
date_end = fields.Date(related="table_id.date_end", store=True) | ||
value_1_id = fields.Many2one( | ||
"hr.data.type.value", | ||
domain="[('type_id', '=', type_1_id)]", | ||
) | ||
value_2_id = fields.Many2one( | ||
"hr.data.type.value", | ||
domain="[('type_id', '=', type_2_id)]", | ||
) | ||
value_3_id = fields.Many2one( | ||
"hr.data.type.value", | ||
domain="[('type_id', '=', type_3_id)]", | ||
) | ||
number_from = fields.Float() | ||
number_to = fields.Float() | ||
result = fields.Float() | ||
note = fields.Text() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<odoo noupdate="1"> | ||
<!-- Company-restricted Records --> | ||
<record model="ir.rule" id="hr_salary_table_company_rule"> | ||
<field name="name">Salary Table: multi-company</field> | ||
<field name="model_id" ref="model_hr_salary_table" /> | ||
<field name="global" eval="True" /> | ||
<field name="domain_force"> | ||
['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] | ||
</field> | ||
</record> | ||
<record model="ir.rule" id="hr_salary_table_line_company_rule"> | ||
<field name="name">Salary Table Line: multi-company</field> | ||
<field name="model_id" ref="model_hr_salary_table_line" /> | ||
<field name="global" eval="True" /> | ||
<field name="domain_force"> | ||
['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_hr_salary_table_template_user,hr.salary.table.template user,model_hr_salary_table_template,payroll.group_payroll_user,1,1,1,1 | ||
access_hr_salary_table_user,hr.salary.table user,model_hr_salary_table,payroll.group_payroll_user,1,1,1,1 | ||
access_hr_salary_table_line_user,hr.salary.table.line user,model_hr_salary_table_line,payroll.group_payroll_user,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
<odoo> | ||
<!-- Salary Table Temlate List View --> | ||
<record id="view_hr_salary_table_template_list" model="ir.ui.view"> | ||
<field name="name">hr.salary.table.template.list</field> | ||
<field name="model">hr.salary.table.template</field> | ||
<field name="arch" type="xml"> | ||
<list> | ||
<field name="name" /> | ||
<field name="code" /> | ||
<field name="type_1_id" /> | ||
<field name="type_2_id" /> | ||
<field name="type_3_id" /> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<!-- Salary Table Template Form View --> | ||
<record id="view_hr_salary_table_template_form" model="ir.ui.view"> | ||
<field name="name">hr.salary.table.form.template</field> | ||
<field name="model">hr.salary.table.template</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<sheet> | ||
<group> | ||
<field name="name" /> | ||
<field name="code" /> | ||
<field name="type_1_id" /> | ||
<field name="type_2_id" /> | ||
<field name="type_3_id" /> | ||
<field name="active" /> | ||
</group> | ||
<notebook> | ||
<page string="History"> | ||
<field name="line_ids"> | ||
<list> | ||
<field name="company_id" /> | ||
<field name="date_start" /> | ||
<field name="date_end" /> | ||
<field name="note" /> | ||
</list> | ||
</field> | ||
</page> | ||
</notebook> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<!-- Salary Table List View --> | ||
<record id="view_hr_salary_table_list" model="ir.ui.view"> | ||
<field name="name">hr.salary.table.list</field> | ||
<field name="model">hr.salary.table</field> | ||
<field name="arch" type="xml"> | ||
<list> | ||
<field name="template_id" /> | ||
<field name="company_id" /> | ||
<field name="date_start" /> | ||
<field name="date_end" /> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<!-- Salary Table Form View --> | ||
<record id="view_hr_salary_table_form" model="ir.ui.view"> | ||
<field name="name">hr.salary.table.form</field> | ||
<field name="model">hr.salary.table</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<sheet> | ||
<group> | ||
<field name="template_id" /> | ||
<field name="salary_rule_id" /> | ||
<field name="company_id" /> | ||
<field name="date_start" /> | ||
<field name="date_end" /> | ||
<field name="note" /> | ||
</group> | ||
<notebook> | ||
<page string="Lines"> | ||
<field name="line_ids"> | ||
<list editable="bottom"> | ||
<field name="type_1_id" column_invisible="True" /> | ||
<field name="type_2_id" column_invisible="True" /> | ||
<field name="type_3_id" column_invisible="True" /> | ||
<field name="value_1_id" /> | ||
<field name="value_2_id" /> | ||
<field name="value_3_id" /> | ||
<field name="number_from" /> | ||
<field name="number_to" /> | ||
<field name="date_start" /> | ||
<field name="date_end" /> | ||
<field name="result" /> | ||
<field name="note" /> | ||
</list> | ||
</field> | ||
</page> | ||
</notebook> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<!-- Salary Table Line List View --> | ||
<record id="view_hr_salary_table_line_list" model="ir.ui.view"> | ||
<field name="name">hr.salary.table.line.list</field> | ||
<field name="model">hr.salary.table.line</field> | ||
<field name="arch" type="xml"> | ||
<list> | ||
<field name="table_id" /> | ||
<field name="salary_rule_id" /> | ||
<field name="value_1_id" /> | ||
<field name="value_2_id" /> | ||
<field name="value_3_id" /> | ||
<field name="number_from" /> | ||
<field name="number_to" /> | ||
<field name="date_start" /> | ||
<field name="date_end" /> | ||
<field name="result" /> | ||
<field name="note" /> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<!-- Actions --> | ||
<record id="action_hr_salary_table_template" model="ir.actions.act_window"> | ||
<field name="name">Salary Table Templates</field> | ||
<field name="res_model">hr.salary.table.template</field> | ||
<field name="view_mode">list,form</field> | ||
</record> | ||
|
||
<record id="action_hr_salary_table" model="ir.actions.act_window"> | ||
<field name="name">Salary Tables</field> | ||
<field name="res_model">hr.salary.table</field> | ||
<field name="view_mode">list,form</field> | ||
</record> | ||
|
||
<record id="action_hr_salary_table_line" model="ir.actions.act_window"> | ||
<field name="name">Salary Table Lines</field> | ||
<field name="res_model">hr.salary.table.line</field> | ||
<field name="view_mode">list,form</field> | ||
</record> | ||
|
||
<!-- Menu Items --> | ||
<menuitem | ||
id="menu_hr_salary_table_root" | ||
name="Salary Tables" | ||
parent="payroll.payroll_menu_configuration" | ||
sequence="10" | ||
/> | ||
|
||
<menuitem | ||
id="menu_hr_salary_table_template" | ||
name="Salary Table Templates" | ||
parent="menu_hr_salary_table_root" | ||
action="action_hr_salary_table_template" | ||
sequence="10" | ||
/> | ||
<menuitem | ||
id="menu_hr_salary_table" | ||
name="Salary Tables" | ||
parent="menu_hr_salary_table_root" | ||
action="action_hr_salary_table" | ||
sequence="20" | ||
/> | ||
<menuitem | ||
id="menu_hr_salary_table_line" | ||
name="Salary Table Lines" | ||
parent="menu_hr_salary_table_root" | ||
action="action_hr_salary_table_line" | ||
sequence="30" | ||
/> | ||
</odoo> |