Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions hr_payroll_document/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=====================
HR - Payroll Document
=====================
Expand All @@ -11,13 +7,13 @@ HR - Payroll Document
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8541f32cab0e71108ff8c422d602825bb599e0141fe69b9342c16742bee0b915
!! source digest: sha256:3f9b184eea79f0c56b920d38a9ed320b6a41331383aa18c126b2583f13c30e2e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github
Expand All @@ -35,6 +31,10 @@ HR - Payroll Document
This module have a wizard view to manage the different payrolls of
employees which is identified by the identification_id attribute.

By default, the employee's payroll is encrypted using their
identification number. This behavior can be changed by the employee in
their profile or by HR in the employee's form.

**Table of contents**

.. contents::
Expand Down Expand Up @@ -66,6 +66,10 @@ Contributors
- Antoni Marroig <[email protected]>
- Miquel Alzanillas <[email protected]>

- `PyTech <https://www.pytech.it>`__:

- Simone Rubino <[email protected]>

Maintainers
-----------

Expand Down
8 changes: 8 additions & 0 deletions hr_payroll_document/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
class Employee(models.Model):
_inherit = "hr.employee"

no_payroll_encryption = fields.Boolean(
string="Disable payrolls encryption",
help="If this is disabled (default), "
"the PDF payrolls are encrypted using the Identification No.\n"
"Only future payrolls are affected by this change, "
"existing payrolls will not change their encryption status.",
)

payroll_count = fields.Integer(
compute="_compute_payroll_count",
)
Expand Down
15 changes: 14 additions & 1 deletion hr_payroll_document/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
from odoo import models
# Copyright 2025 Simone Rubino - PyTech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models

from odoo.addons.hr.models.res_users import HR_WRITABLE_FIELDS

HR_WRITABLE_FIELDS.append("no_payroll_encryption")


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

no_payroll_encryption = fields.Boolean(
related="employee_id.no_payroll_encryption",
readonly=False,
related_sudo=False,
)

def action_get_attachment_tree_view(self):
action = self.env.ref("base.action_attachment").sudo().read()[0]
action["context"] = {
Expand Down
2 changes: 2 additions & 0 deletions hr_payroll_document/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- [APSL-Nagarro](https://www.apsl.tech):
- Antoni Marroig \<<[email protected]>\>
- Miquel Alzanillas \<<[email protected]>\>
- [PyTech](https://www.pytech.it):
- Simone Rubino \<<[email protected]>\>
3 changes: 3 additions & 0 deletions hr_payroll_document/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
This module have a wizard view to manage the different payrolls of employees which is identified by the identification_id attribute.

By default, the employee's payroll is encrypted using their identification number.
This behavior can be changed by the employee in their profile or by HR in the employee's form.
33 changes: 17 additions & 16 deletions hr_payroll_document/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>HR - Payroll Document</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,23 +360,21 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="hr-payroll-document">
<h1 class="title">HR - Payroll Document</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="hr-payroll-document">
<h1>HR - Payroll Document</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8541f32cab0e71108ff8c422d602825bb599e0141fe69b9342c16742bee0b915
!! source digest: sha256:3f9b184eea79f0c56b920d38a9ed320b6a41331383aa18c126b2583f13c30e2e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<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>
<p>This module have a wizard view to manage the different payrolls of
employees which is identified by the identification_id attribute.</p>
<p>By default, the employee’s payroll is encrypted using their
identification number. This behavior can be changed by the employee in
their profile or by HR in the employee’s form.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -390,33 +388,37 @@ <h1>HR - Payroll Document</h1>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/payroll/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<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>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<ul class="simple">
<li>APSL</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.apsl.tech">APSL-Nagarro</a>:<ul>
<li>Antoni Marroig &lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;</li>
<li>Miquel Alzanillas &lt;<a class="reference external" href="mailto:malzanillas&#64;apsl.net">malzanillas&#64;apsl.net</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -431,6 +433,5 @@ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
35 changes: 35 additions & 0 deletions hr_payroll_document/tests/test_hr_payroll_document.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import base64
import io

import pypdf

from odoo import _
from odoo.exceptions import UserError, ValidationError
Expand Down Expand Up @@ -107,3 +110,35 @@ def test_send_payrolls_correctly(self):
self.wizard.send_payrolls()["params"]["message"],
_("Payrolls sent to employees correctly"),
)

def test_optional_encryption(self):
"""The employee's payroll can be not encrypted."""
# Arrange
self.fill_company_id()
employee = self.employee_emp
employee.update(
{
"identification_id": "51000278D",
"no_payroll_encryption": True,
}
)
# pre-condition
self.assertTrue(employee.no_payroll_encryption)

# Act
self.wizard.send_payrolls()

# Assert
payroll = (
self.env["ir.attachment.payroll.custom"]
.search(
[
("identification_id", "=", employee.identification_id),
]
)
.attachment_id
)
self.assertTrue(payroll)
payroll_content = base64.b64decode(payroll.datas)
payroll_pdf = pypdf.PdfReader(io.BytesIO(payroll_content))
self.assertFalse(payroll_pdf.is_encrypted)
Loading