Skip to content

Commit 2d60f52

Browse files
committed
[ADD] payroll_contract_advantages_structure: link templates to salary structures, auto-create advantages - helped by Claude Opus-4.7
1 parent b9a6db3 commit 2d60f52

18 files changed

Lines changed: 783 additions & 0 deletions
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
===============================================
2+
Payroll Contract Advantages by Salary Structure
3+
===============================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:4e2708b2de5111c54bcb121100caac1601de32c223a26a0ed4ef73180af13832
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github
20+
:target: https://github.com/OCA/payroll/tree/18.0/payroll_contract_advantages_structure
21+
:alt: OCA/payroll
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/payroll-18-0/payroll-18-0-payroll_contract_advantages_structure
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/payroll&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Attach advantage templates to salary structures and auto-create the
32+
matching ``hr.contract.advantage`` lines on the contract when the
33+
structure is selected. Additive only: existing advantages are kept.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Configuration
41+
=============
42+
43+
1. Go to *Payroll → Configuration → Advantage Templates* and define the
44+
advantage templates you need (name, code, computation mode, quantity
45+
mode...).
46+
2. On each template, set the *Salary Structures* field to the structures
47+
it applies to. Alternatively, on the *Salary Structure* form, the
48+
*Advantage Templates* tab lists the templates attached to that
49+
structure.
50+
51+
Usage
52+
=====
53+
54+
- Selecting a salary structure on a contract auto-creates the advantages
55+
corresponding to its templates that are not already present on the
56+
contract.
57+
- Existing advantages on the contract are never removed nor overwritten.
58+
59+
Bug Tracker
60+
===========
61+
62+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/payroll/issues>`_.
63+
In case of trouble, please check there if your issue has already been reported.
64+
If you spotted it first, help us to smash it by providing a detailed and welcomed
65+
`feedback <https://github.com/OCA/payroll/issues/new?body=module:%20payroll_contract_advantages_structure%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
66+
67+
Do not contact contributors directly about support or help with technical issues.
68+
69+
Credits
70+
=======
71+
72+
Authors
73+
-------
74+
75+
* INVITU
76+
77+
Contributors
78+
------------
79+
80+
- Cyril VINH-TUNG <cyril@invitu.com>
81+
82+
Maintainers
83+
-----------
84+
85+
This module is maintained by the OCA.
86+
87+
.. image:: https://odoo-community.org/logo.png
88+
:alt: Odoo Community Association
89+
:target: https://odoo-community.org
90+
91+
OCA, or the Odoo Community Association, is a nonprofit organization whose
92+
mission is to support the collaborative development of Odoo features and
93+
promote its widespread use.
94+
95+
This module is part of the `OCA/payroll <https://github.com/OCA/payroll/tree/18.0/payroll_contract_advantages_structure>`_ project on GitHub.
96+
97+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2026 INVITU (<https://www.invitu.com>)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2026 INVITU (<https://www.invitu.com>)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
{
5+
"name": "Payroll Contract Advantages by Salary Structure",
6+
"version": "18.0.1.0.0",
7+
"category": "Payroll",
8+
"website": "https://github.com/OCA/payroll",
9+
"summary": "Attach advantage templates to salary structures and"
10+
" auto-create the advantages on the contract.",
11+
"license": "LGPL-3",
12+
"author": "INVITU, Odoo Community Association (OCA)",
13+
"depends": ["payroll_contract_advantages_base"],
14+
"data": [
15+
"views/hr_contract_advantage_template_views.xml",
16+
"views/hr_payroll_structure_views.xml",
17+
],
18+
"demo": ["demo/payroll_contract_advantages_structure_demo.xml"],
19+
"installable": True,
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2026 INVITU (<https://www.invitu.com>)
3+
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
4+
<odoo>
5+
<record
6+
id="payroll_contract_advantages.advantage_template_meal"
7+
model="hr.contract.advantage.template"
8+
>
9+
<field name="structure_ids" eval="[(6, 0, [ref('payroll.structure_001')])]" />
10+
</record>
11+
</odoo>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2026 INVITU (<https://www.invitu.com>)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from . import hr_contract_advantage_template
5+
from . import hr_payroll_structure
6+
from . import hr_contract
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2026 INVITU (<https://www.invitu.com>)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from odoo import api, models
5+
6+
7+
class HrContract(models.Model):
8+
_inherit = "hr.contract"
9+
10+
def _get_applicable_advantage_templates(self):
11+
"""Templates rattached to the contract's salary structure."""
12+
self.ensure_one()
13+
return self.struct_id.advantage_template_ids
14+
15+
@api.onchange("struct_id")
16+
def _onchange_struct_id_sync_advantages(self):
17+
for contract in self:
18+
contract._sync_advantages_from_templates()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2026 INVITU (<https://www.invitu.com>)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from odoo import fields, models
5+
6+
7+
class HrContractAdvantageTemplate(models.Model):
8+
_inherit = "hr.contract.advantage.template"
9+
10+
structure_ids = fields.Many2many(
11+
comodel_name="hr.payroll.structure",
12+
relation="hr_contract_advantage_template_structure_rel",
13+
column1="template_id",
14+
column2="structure_id",
15+
string="Salary Structures",
16+
help="Salary structures that auto-create this advantage on the"
17+
" contract when selected.",
18+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2026 INVITU (<https://www.invitu.com>)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from odoo import fields, models
5+
6+
7+
class HrPayrollStructure(models.Model):
8+
_inherit = "hr.payroll.structure"
9+
10+
advantage_template_ids = fields.Many2many(
11+
comodel_name="hr.contract.advantage.template",
12+
relation="hr_contract_advantage_template_structure_rel",
13+
column1="structure_id",
14+
column2="template_id",
15+
string="Advantage Templates",
16+
help="Templates auto-created on a contract when this structure" " is selected.",
17+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
1. Go to *Payroll → Configuration → Advantage Templates* and define
2+
the advantage templates you need (name, code, computation mode,
3+
quantity mode...).
4+
2. On each template, set the *Salary Structures* field to the
5+
structures it applies to. Alternatively, on the *Salary Structure*
6+
form, the *Advantage Templates* tab lists the templates attached
7+
to that structure.

0 commit comments

Comments
 (0)