Skip to content

Commit 7ea24a8

Browse files
committed
[ADD] payroll_rule_tag
1 parent 7badc0e commit 7ea24a8

18 files changed

Lines changed: 751 additions & 0 deletions

payroll_rule_tag/README.rst

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
================
2+
Payroll Rule Tag
3+
================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:5ee9008067f86ba06d52efcdc02644a97437611ee4feaf74fcadaf545845b2db
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_rule_tag
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_rule_tag
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+
Assign tags to Salary Rules.
32+
33+
These tags can be used to compute totals, and can work as a more flexble
34+
alternative to salary rule Categories.
35+
36+
**Table of contents**
37+
38+
.. contents::
39+
:local:
40+
41+
Configuration
42+
=============
43+
44+
Salary rule Tags can be defined from the Payroll / Configuration menu,
45+
and are assigned to Salary Rules using the "Tags" field in the
46+
Computation form area.
47+
48+
Usage
49+
=====
50+
51+
On Salary Rules form, one or more tags can be selected and assigne to
52+
the rule, on the "Tags" field.
53+
54+
In salary rules with Python code, totals for a tag can be accessed using
55+
the ``tags`` browseable collection with the uppercase tag name.
56+
57+
Example:
58+
59+
::
60+
61+
result = tags.TAXABLE
62+
63+
Bug Tracker
64+
===========
65+
66+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/payroll/issues>`_.
67+
In case of trouble, please check there if your issue has already been reported.
68+
If you spotted it first, help us to smash it by providing a detailed and welcomed
69+
`feedback <https://github.com/OCA/payroll/issues/new?body=module:%20payroll_rule_tag%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
70+
71+
Do not contact contributors directly about support or help with technical issues.
72+
73+
Credits
74+
=======
75+
76+
Authors
77+
-------
78+
79+
* Daniel Reis
80+
81+
Contributors
82+
------------
83+
84+
- Daniel Reis <<dreis@opensourceintegrators.com>>
85+
86+
Maintainers
87+
-----------
88+
89+
This module is maintained by the OCA.
90+
91+
.. image:: https://odoo-community.org/logo.png
92+
:alt: Odoo Community Association
93+
:target: https://odoo-community.org
94+
95+
OCA, or the Odoo Community Association, is a nonprofit organization whose
96+
mission is to support the collaborative development of Odoo features and
97+
promote its widespread use.
98+
99+
.. |maintainer-dreispt| image:: https://github.com/dreispt.png?size=40px
100+
:target: https://github.com/dreispt
101+
:alt: dreispt
102+
103+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
104+
105+
|maintainer-dreispt|
106+
107+
This module is part of the `OCA/payroll <https://github.com/OCA/payroll/tree/18.0/payroll_rule_tag>`_ project on GitHub.
108+
109+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

payroll_rule_tag/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

payroll_rule_tag/__manifest__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Open Source Integrators (www.opensourceintegrators.com)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
{
4+
"name": "Payroll Rule Tag",
5+
"version": "18.0.1.0.0",
6+
"category": "Payroll",
7+
"website": "https://github.com/OCA/payroll",
8+
"license": "LGPL-3",
9+
"author": "Daniel Reis, Odoo Community Association (OCA)",
10+
"depends": ["payroll"],
11+
"data": [
12+
"security/ir.model.access.csv",
13+
"views/hr_salary_rule.xml",
14+
"views/hr_salary_rule_tag.xml",
15+
],
16+
"maintainers": ["dreispt"],
17+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import hr_payslip
2+
from . import hr_salary_rule
3+
from . import hr_salary_rule_tag
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2025 Open Source Integrators (www.opensourceintegrators.com)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
from odoo import models
4+
5+
from odoo.addons.payroll.models.base_browsable import BrowsableObject
6+
7+
8+
class HrPayslip(models.Model):
9+
_inherit = "hr.payslip"
10+
11+
def _get_baselocaldict(self, contracts):
12+
localdict = super()._get_baselocaldict(contracts)
13+
localdict["tags"] = BrowsableObject(self.employee_id.id, {}, self.env)
14+
return localdict
15+
16+
def _get_lines_dict(
17+
self, rule, localdict, lines_dict, key, values, previous_amount
18+
):
19+
localdict, lines_dict = super()._get_lines_dict(
20+
rule, localdict, lines_dict, key, values, previous_amount
21+
)
22+
# sum the amount for salary rule tags
23+
total = lines_dict[key]["total"]
24+
for tag in rule.tag_ids:
25+
localdict = self._sum_salary_rule_tag(
26+
localdict, tag.name, total - previous_amount
27+
)
28+
return localdict, lines_dict
29+
30+
def _sum_salary_rule_tag(self, localdict, tag_name, amount):
31+
self.ensure_one()
32+
if tag_name:
33+
code = tag_name.upper()
34+
localdict["tags"].dict[code] = localdict["tags"].dict.get(code, 0) + amount
35+
return localdict
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2025 Open Source Integrators (www.opensourceintegrators.com)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
from odoo import fields, models
4+
5+
6+
class HrSalaryRule(models.Model):
7+
_inherit = "hr.salary.rule"
8+
9+
tag_ids = fields.Many2many("hr.salary.rule.tag", string="Tags")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2025 Open Source Integrators (www.opensourceintegrators.com)
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
from odoo import fields, models
4+
5+
6+
class HrSalaryRuleTag(models.Model):
7+
_name = "hr.salary.rule.tag"
8+
_description = "Salary Rule Tag"
9+
_order = "name"
10+
11+
name = fields.Char(required=True)
12+
salary_rules_ids = fields.Many2many("hr.salary.rule")

payroll_rule_tag/pyproject.toml

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Salary rule Tags can be defined from the Payroll / Configuration menu,
2+
and are assigned to Salary Rules using the "Tags" field in the Computation form area.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Daniel Reis \<\<<dreis@opensourceintegrators.com>\>\>

0 commit comments

Comments
 (0)