summaryrefslogtreecommitdiff
path: root/addons/hr_contract/data
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2019-03-07 16:43:04 +0100
committerYannick Tivisse <yti@odoo.com>2019-03-19 09:24:23 +0100
commitb63128099991358640efb91bf985e25e9d0d72b0 (patch)
treeedf4b23787f00acf8d07525f008c7bc58a811a4b /addons/hr_contract/data
parentedd659f9da596da39bd274280a7b90f275e7f22b (diff)
[REF] hr_payroll: Remove parent_id hierarchy + Add structures categorization
1/ Remove the parent-children relation on salary structures Currently it is difficult to see what rules are applied on salary structures. Most of the structures are inheriting 3 rules (Basic, Gross, Net) from the 'Base for new structures', and those rules are not shown. Same issue if a structure has another one as parent (as in the French localization). This bring more annoying issues: - Since the saas-12.1, we can already set different accounts for different companies on the salary rules for which we want to post journal entries. But for the parent rules, like the 'NET' amount, it's impossible to post the journal entries on different account for different salary structures. (eg: for CP200 employees and CP200 workers). As the rules are following a M2M relation on the structure, we have to remove the parent_id and to recreate all the rules in the final structure. - If we are not at ease with the M2M relation (which is the case for most of the end users), we will simply modify the rule on the parent structure. This was already done on the French localization on which we modified the code, sequence and the name. This could have some desastrous consequences as this will break the order on which the rules are computed for other structures for the sequence, or break other integration with the payroll as we also modify the code, for example the salary configurator. As this parent-children relation on structure could cause several issues difficult to spot and as this is quite difficult to correctly visualize the structure composition, it is better to remove it and define all the rules inside the structure itself. This improves also the code readability as we are not trying to recursively retrieve the rules and find a proper sequence inside them. 2/ Make the rules on the salary structure a o2m instead of a m2m The issues described just above indicates that it would be better to remove the M2M relation between salary structures and salary rules, and make it a O2M relation instead. That way, no more confusion and misconfiguration of the rules fields (code, sequence, accounts, ...). 3/ Remove the parent-children relation on rules A salary rule can have a parent salary rule. This mechanism, which is not obvious at all for an end user allows to specify a parent rules. If the condition is met for the parent rule (eg: the employee has at least 1 child), all the children rules could be applied (eg: Deduction of 90 euros if the number of children is between 1 and 1). Visually it doesn't make a lot of sense, as it displays one line with an amount of 0 for the parent, and one line with the real amount for each applied child. On the other hand, no child rule is linked to the structure and an end user has to click on the parent rule, to see the children and understand that something mystic and hidden is existing. This is equivalent to define as many classic rules as we have children, or even better, define 1 rule that will compute the real amount directly, as the number of children can be accessed from the localdict when computing the salary line. This commit also removed the relation. 4/ Clean some brols in the code (technical) The 3 first points of the spec allow us to clean a little the code readability and complexity. 5/ Adapt all the localizations for these changes All the localizations are impacted by those changes. What is done in this commit is mainly: - l10n_be_hr_payroll: Make 3 separated files for the 3 existing structures (the fourth one, belgian worker, is not correct and is removed). For each structure, define explicitely the rules (in the correct order by sequence). This multiplies the total number of rules as some of them were shared (like the withholding tax rule for example), but all the code that is supposed to be modified each year/quarter/whenever the government decides to modify the law has been moved into a python file, and is available the computation context. This will also allow us to update the computation rules without having to update the module. - l10n_fr_hr_payroll: There were 3 rules following this scheme: Base for new structure | Basic structure | ---------------------- | | Cadre Non-Cadre All the rules parent rules have been duplicated into the 2 remaining structures, cadre and non-cadre. There were a lot of parent-children relations between the rules that have been adapted to the new model. - l10n_in_hr_payroll: There was a lot of rules in data, and a structure in demo data, which was using 4 or 5 of these rules. As the rules doesn't seem to make a lot of sense altogether, everything was moved in demo data. 6/ Introduce a new Salary Structure Type model Currently we have a model hr.contract.type with a M2O on the contracts. This has never been used in 9 years and is removed in this commit. On the other hand, we would like to define a new model hr.payroll.structure.type (eg: CP200 Employee), which will line all the salary structures the Belgian localization could bring (Classic salary, double holidays, 13th month, ...). This field is defined on the structure, and is displayed on the contract (as the same place than the contract type we just removed). On this model we could also define some fields like: - The default pay period: Selection field, default = monthly. This is applied on the contract when selecting the structure. - The Working Schedule, m2o. This is applied on the contract when selecting the structure For example, on the 'commission paritaire' for teachers, we could set the default pay period to 'Every 15 days' and the working schedule to '19 hours / week'. Every contract under this structure would take those values. Migration ========= For a migration point of view: - All the rules that had a parent_rule_id should be set to appears_on_payslip=False. The column parent_rule_id can be dropped afterward. - All the rules that are coming from a parent structure or higher should be duplicated and the field 'struct_id' should be set on the current structure. The column parent_id can be dropped afterward. - All the rules that were defined on the structure should have the field 'struct_id' defined on them. - The rules that are not linked to a structure should be unlinked. - The column type_id on the contract could be dropped, no need to keep the values too. - A default structure type is defined in data ('Employee'). This could be set to all the existing structure for the newly created 'type_id' field. TaskID: 1942832
Diffstat (limited to 'addons/hr_contract/data')
-rw-r--r--addons/hr_contract/data/hr_contract_data.xml16
-rw-r--r--addons/hr_contract/data/hr_contract_demo.xml13
2 files changed, 0 insertions, 29 deletions
diff --git a/addons/hr_contract/data/hr_contract_data.xml b/addons/hr_contract/data/hr_contract_data.xml
index 136ba02ed27..546b36def1b 100644
--- a/addons/hr_contract/data/hr_contract_data.xml
+++ b/addons/hr_contract/data/hr_contract_data.xml
@@ -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>
diff --git a/addons/hr_contract/data/hr_contract_demo.xml b/addons/hr_contract/data/hr_contract_demo.xml
index eef59fd9813..c7092205f57 100644
--- a/addons/hr_contract/data/hr_contract_demo.xml
+++ b/addons/hr_contract/data/hr_contract_demo.xml
@@ -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"/>