Skip to content

Commit 1e36d78

Browse files
committed
Merge PR #247 into 17.0
Signed-off-by peluko00
2 parents 22f07f5 + d85ad9b commit 1e36d78

File tree

9 files changed

+183
-93
lines changed

9 files changed

+183
-93
lines changed

hr_payroll_document/README.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
=====================
62
HR - Payroll Document
73
=====================
@@ -11,13 +7,13 @@ HR - Payroll Document
117
!! This file is generated by oca-gen-addon-readme !!
128
!! changes will be overwritten. !!
139
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14-
!! source digest: sha256:8541f32cab0e71108ff8c422d602825bb599e0141fe69b9342c16742bee0b915
10+
!! source digest: sha256:3f9b184eea79f0c56b920d38a9ed320b6a41331383aa18c126b2583f13c30e2e
1511
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1612
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github
@@ -35,6 +31,10 @@ HR - Payroll Document
3531
This module have a wizard view to manage the different payrolls of
3632
employees which is identified by the identification_id attribute.
3733

34+
By default, the employee's payroll is encrypted using their
35+
identification number. This behavior can be changed by the employee in
36+
their profile or by HR in the employee's form.
37+
3838
**Table of contents**
3939

4040
.. contents::
@@ -66,6 +66,10 @@ Contributors
6666
- Antoni Marroig <[email protected]>
6767
- Miquel Alzanillas <[email protected]>
6868

69+
- `PyTech <https://www.pytech.it>`__:
70+
71+
- Simone Rubino <[email protected]>
72+
6973
Maintainers
7074
-----------
7175

hr_payroll_document/models/hr_employee.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
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
payroll_count = fields.Integer(
917
compute="_compute_payroll_count",
1018
)

hr_payroll_document/models/res_users.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
from odoo import models
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")
29

310

411
class ResUsers(models.Model):
512
_inherit = "res.users"
613

14+
no_payroll_encryption = fields.Boolean(
15+
related="employee_id.no_payroll_encryption",
16+
readonly=False,
17+
related_sudo=False,
18+
)
19+
720
def action_get_attachment_tree_view(self):
821
action = self.env.ref("base.action_attachment").sudo().read()[0]
922
action["context"] = {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
- [APSL-Nagarro](https://www.apsl.tech):
22
- Antoni Marroig \<<[email protected]>\>
33
- Miquel Alzanillas \<<[email protected]>\>
4+
- [PyTech](https://www.pytech.it):
5+
- Simone Rubino \<<[email protected]>\>
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: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>HR - Payroll Document</title>
77
<style type="text/css">
88

99
/*
@@ -360,23 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="hr-payroll-document">
364+
<h1 class="title">HR - Payroll Document</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="hr-payroll-document">
370-
<h1>HR - Payroll Document</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375-
!! source digest: sha256:8541f32cab0e71108ff8c422d602825bb599e0141fe69b9342c16742bee0b915
370+
!! source digest: sha256:3f9b184eea79f0c56b920d38a9ed320b6a41331383aa18c126b2583f13c30e2e
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/17.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-17-0/payroll-17-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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/payroll/tree/17.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-17-0/payroll-17-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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module have a wizard view to manage the different payrolls of
379374
employees which is identified by the identification_id attribute.</p>
375+
<p>By default, the employee’s payroll is encrypted using their
376+
identification number. This behavior can be changed by the employee in
377+
their profile or by HR in the employee’s form.</p>
380378
<p><strong>Table of contents</strong></p>
381379
<div class="contents local topic" id="contents">
382380
<ul class="simple">
@@ -390,33 +388,37 @@ <h1>HR - Payroll Document</h1>
390388
</ul>
391389
</div>
392390
<div class="section" id="bug-tracker">
393-
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
391+
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
394392
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/payroll/issues">GitHub Issues</a>.
395393
In case of trouble, please check there if your issue has already been reported.
396394
If you spotted it first, help us to smash it by providing a detailed and welcomed
397395
<a class="reference external" href="https://github.com/OCA/payroll/issues/new?body=module:%20hr_payroll_document%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
398396
<p>Do not contact contributors directly about support or help with technical issues.</p>
399397
</div>
400398
<div class="section" id="credits">
401-
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
399+
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
402400
<div class="section" id="authors">
403-
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
401+
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
404402
<ul class="simple">
405403
<li>APSL</li>
406404
</ul>
407405
</div>
408406
<div class="section" id="contributors">
409-
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
407+
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
410408
<ul class="simple">
411409
<li><a class="reference external" href="https://www.apsl.tech">APSL-Nagarro</a>:<ul>
412410
<li>Antoni Marroig &lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;</li>
413411
<li>Miquel Alzanillas &lt;<a class="reference external" href="mailto:malzanillas&#64;apsl.net">malzanillas&#64;apsl.net</a>&gt;</li>
414412
</ul>
415413
</li>
414+
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
415+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
416+
</ul>
417+
</li>
416418
</ul>
417419
</div>
418420
<div class="section" id="maintainers">
419-
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
421+
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
420422
<p>This module is maintained by the OCA.</p>
421423
<a class="reference external image-reference" href="https://odoo-community.org">
422424
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -431,6 +433,5 @@ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
431433
</div>
432434
</div>
433435
</div>
434-
</div>
435436
</body>
436437
</html>

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
@@ -107,3 +110,35 @@ def test_send_payrolls_correctly(self):
107110
self.wizard.send_payrolls()["params"]["message"],
108111
_("Payrolls sent to employees correctly"),
109112
)
113+
114+
def test_optional_encryption(self):
115+
"""The employee's payroll can be not encrypted."""
116+
# Arrange
117+
self.fill_company_id()
118+
employee = self.employee_emp
119+
employee.update(
120+
{
121+
"identification_id": "51000278D",
122+
"no_payroll_encryption": True,
123+
}
124+
)
125+
# pre-condition
126+
self.assertTrue(employee.no_payroll_encryption)
127+
128+
# Act
129+
self.wizard.send_payrolls()
130+
131+
# Assert
132+
payroll = (
133+
self.env["ir.attachment.payroll.custom"]
134+
.search(
135+
[
136+
("identification_id", "=", employee.identification_id),
137+
]
138+
)
139+
.attachment_id
140+
)
141+
self.assertTrue(payroll)
142+
payroll_content = base64.b64decode(payroll.datas)
143+
payroll_pdf = pypdf.PdfReader(io.BytesIO(payroll_content))
144+
self.assertFalse(payroll_pdf.is_encrypted)

0 commit comments

Comments
 (0)