Skip to content

Commit 7720c60

Browse files
committed
Merge PR #245 into 16.0
Signed-off-by peluko00
2 parents f835ffe + e01f2c1 commit 7720c60

File tree

11 files changed

+123
-3
lines changed

11 files changed

+123
-3
lines changed

hr_payroll_document/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ HR - Payroll Document
3434

3535
This module have a wizard view to manage the different payrolls of employees which is identified by the identification_id attribute.
3636

37+
By default, the employee's payroll is encrypted using their identification number.
38+
This behavior can be changed by the employee in their profile or by HR in the employee's form.
39+
3740
**Table of contents**
3841

3942
.. contents::

hr_payroll_document/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313
"wizard/payroll_management_wizard.xml",
1414
"security/ir.model.access.csv",
1515
"data/email_payroll_employee.xml",
16+
"views/hr_employee_views.xml",
17+
"views/res_users_views.xml",
1618
],
1719
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from . import ir_attachment_payroll_custom
22
from . import ir_attachment
33
from . import hr_employee
4+
from . import res_users

hr_payroll_document/models/hr_employee.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
from odoo import _, models
1+
from odoo import _, fields, models
22
from odoo.exceptions import ValidationError
33

44

55
class Employee(models.Model):
66
_inherit = "hr.employee"
77

8+
no_payroll_encryption = fields.Boolean(
9+
string="Disable payrolls encryption",
10+
help="If this is disabled (default), "
11+
"the PDF payrolls are encrypted using the Identification No.\n"
12+
"Only future payrolls are affected by this change, "
13+
"existing payrolls will not change their encryption status.",
14+
)
15+
816
def write(self, vals):
917
res = super().write(vals)
1018
if "identification_id" in vals and not self.env["res.partner"].simple_vat_check(
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2025 Simone Rubino - PyTech
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
from odoo.addons.hr.models.res_users import HR_WRITABLE_FIELDS
7+
8+
HR_WRITABLE_FIELDS.append("no_payroll_encryption")
9+
10+
11+
class ResUsers(models.Model):
12+
_inherit = "res.users"
13+
14+
no_payroll_encryption = fields.Boolean(
15+
related="employee_id.no_payroll_encryption",
16+
readonly=False,
17+
related_sudo=False,
18+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
This module have a wizard view to manage the different payrolls of employees which is identified by the identification_id attribute.
2+
3+
By default, the employee's payroll is encrypted using their identification number.
4+
This behavior can be changed by the employee in their profile or by HR in the employee's form.

hr_payroll_document/static/description/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ <h1>HR - Payroll Document</h1>
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377377
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/payroll/tree/16.0/hr_payroll_document"><img alt="OCA/payroll" src="https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/payroll-16-0/payroll-16-0-hr_payroll_document"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/payroll&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module have a wizard view to manage the different payrolls of employees which is identified by the identification_id attribute.</p>
379+
<p>By default, the employee’s payroll is encrypted using their identification number.
380+
This behavior can be changed by the employee in their profile or by HR in the employee’s form.</p>
379381
<p><strong>Table of contents</strong></p>
380382
<div class="contents local topic" id="contents">
381383
<ul class="simple">

hr_payroll_document/tests/test_hr_payroll_document.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import base64
2+
import io
3+
4+
import pypdf
25

36
from odoo import _
47
from odoo.exceptions import UserError, ValidationError
@@ -105,3 +108,35 @@ def test_send_payrolls_correctly(self):
105108
},
106109
},
107110
)
111+
112+
def test_optional_encryption(self):
113+
"""The employee's payroll can be not encrypted."""
114+
# Arrange
115+
self.fill_company_id()
116+
employee = self.employee_emp
117+
employee.update(
118+
{
119+
"identification_id": "51000278D",
120+
"no_payroll_encryption": True,
121+
}
122+
)
123+
# pre-condition
124+
self.assertTrue(employee.no_payroll_encryption)
125+
126+
# Act
127+
self.wizard.send_payrolls()
128+
129+
# Assert
130+
payroll = (
131+
self.env["ir.attachment.payroll.custom"]
132+
.search(
133+
[
134+
("identification_id", "=", employee.identification_id),
135+
]
136+
)
137+
.attachment_id
138+
)
139+
self.assertTrue(payroll)
140+
payroll_content = base64.b64decode(payroll.datas)
141+
payroll_pdf = pypdf.PdfReader(io.BytesIO(payroll_content))
142+
self.assertFalse(payroll_pdf.is_encrypted)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
~ Copyright 2025 Simone Rubino - PyTech
4+
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
-->
6+
<odoo>
7+
<record id="view_employee_form" model="ir.ui.view">
8+
<field name="name">hr.employee.form</field>
9+
<field name="model">hr.employee</field>
10+
<field name="inherit_id" ref="hr.view_employee_form" />
11+
<field name="arch" type="xml">
12+
<group name="payroll_group" position="attributes">
13+
<attribute name="invisible" />
14+
</group>
15+
<group name="payroll_group" position="inside">
16+
<field name="no_payroll_encryption" string="Disable encryption" />
17+
</group>
18+
</field>
19+
</record>
20+
</odoo>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
~ Copyright 2025 Simone Rubino - PyTech
4+
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
-->
6+
<odoo>
7+
<record id="res_users_view_form_profile" model="ir.ui.view">
8+
<field name="name">Add Payroll fields to User profile form view</field>
9+
<field name="model">res.users</field>
10+
<field name="inherit_id" ref="hr.res_users_view_form_profile" />
11+
<field name="arch" type="xml">
12+
<div id="o_work_employee_main" position="inside">
13+
<group name="payroll" string="Payroll">
14+
<field
15+
name="no_payroll_encryption"
16+
string="Disable encryption"
17+
attrs="{
18+
'readonly': [
19+
('can_edit', '=', False),
20+
],
21+
}"
22+
/>
23+
</group>
24+
</div>
25+
</field>
26+
</record>
27+
</odoo>

0 commit comments

Comments
 (0)