odoo-addon-hr-payroll-document 16.0.1.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. odoo/addons/hr_payroll_document/README.rst +95 -0
  2. odoo/addons/hr_payroll_document/__init__.py +2 -0
  3. odoo/addons/hr_payroll_document/__manifest__.py +24 -0
  4. odoo/addons/hr_payroll_document/data/email_payroll_employee.xml +20 -0
  5. odoo/addons/hr_payroll_document/i18n/ca_ES.po +309 -0
  6. odoo/addons/hr_payroll_document/i18n/es.po +309 -0
  7. odoo/addons/hr_payroll_document/i18n/hr_payroll_document.pot +245 -0
  8. odoo/addons/hr_payroll_document/i18n/it.po +315 -0
  9. odoo/addons/hr_payroll_document/models/__init__.py +4 -0
  10. odoo/addons/hr_payroll_document/models/hr_employee.py +34 -0
  11. odoo/addons/hr_payroll_document/models/ir_attachment.py +14 -0
  12. odoo/addons/hr_payroll_document/models/ir_attachment_payroll_custom.py +18 -0
  13. odoo/addons/hr_payroll_document/models/res_users.py +18 -0
  14. odoo/addons/hr_payroll_document/readme/CONTRIBUTORS.rst +5 -0
  15. odoo/addons/hr_payroll_document/readme/DESCRIPTION.rst +4 -0
  16. odoo/addons/hr_payroll_document/security/ir.model.access.csv +3 -0
  17. odoo/addons/hr_payroll_document/static/description/icon.png +0 -0
  18. odoo/addons/hr_payroll_document/static/description/index.html +438 -0
  19. odoo/addons/hr_payroll_document/tests/__init__.py +1 -0
  20. odoo/addons/hr_payroll_document/tests/common.py +76 -0
  21. odoo/addons/hr_payroll_document/tests/test.docx +0 -0
  22. odoo/addons/hr_payroll_document/tests/test.pdf +0 -0
  23. odoo/addons/hr_payroll_document/tests/test_hr_payroll_document.py +122 -0
  24. odoo/addons/hr_payroll_document/views/hr_employee_views.xml +20 -0
  25. odoo/addons/hr_payroll_document/views/res_users_views.xml +27 -0
  26. odoo/addons/hr_payroll_document/wizard/__init__.py +1 -0
  27. odoo/addons/hr_payroll_document/wizard/payroll_management_wizard.py +216 -0
  28. odoo/addons/hr_payroll_document/wizard/payroll_management_wizard.xml +42 -0
  29. odoo_addon_hr_payroll_document-16.0.1.3.1.dist-info/METADATA +112 -0
  30. odoo_addon_hr_payroll_document-16.0.1.3.1.dist-info/RECORD +32 -0
  31. odoo_addon_hr_payroll_document-16.0.1.3.1.dist-info/WHEEL +5 -0
  32. odoo_addon_hr_payroll_document-16.0.1.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,438 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6
+ <title>README.rst</title>
7
+ <style type="text/css">
8
+
9
+ /*
10
+ :Author: David Goodger (goodger@python.org)
11
+ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
12
+ :Copyright: This stylesheet has been placed in the public domain.
13
+
14
+ Default cascading style sheet for the HTML output of Docutils.
15
+ Despite the name, some widely supported CSS2 features are used.
16
+
17
+ See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
18
+ customize this style sheet.
19
+ */
20
+
21
+ /* used to remove borders from tables and images */
22
+ .borderless, table.borderless td, table.borderless th {
23
+ border: 0 }
24
+
25
+ table.borderless td, table.borderless th {
26
+ /* Override padding for "table.docutils td" with "! important".
27
+ The right padding separates the table cells. */
28
+ padding: 0 0.5em 0 0 ! important }
29
+
30
+ .first {
31
+ /* Override more specific margin styles with "! important". */
32
+ margin-top: 0 ! important }
33
+
34
+ .last, .with-subtitle {
35
+ margin-bottom: 0 ! important }
36
+
37
+ .hidden {
38
+ display: none }
39
+
40
+ .subscript {
41
+ vertical-align: sub;
42
+ font-size: smaller }
43
+
44
+ .superscript {
45
+ vertical-align: super;
46
+ font-size: smaller }
47
+
48
+ a.toc-backref {
49
+ text-decoration: none ;
50
+ color: black }
51
+
52
+ blockquote.epigraph {
53
+ margin: 2em 5em ; }
54
+
55
+ dl.docutils dd {
56
+ margin-bottom: 0.5em }
57
+
58
+ object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
59
+ overflow: hidden;
60
+ }
61
+
62
+ /* Uncomment (and remove this text!) to get bold-faced definition list terms
63
+ dl.docutils dt {
64
+ font-weight: bold }
65
+ */
66
+
67
+ div.abstract {
68
+ margin: 2em 5em }
69
+
70
+ div.abstract p.topic-title {
71
+ font-weight: bold ;
72
+ text-align: center }
73
+
74
+ div.admonition, div.attention, div.caution, div.danger, div.error,
75
+ div.hint, div.important, div.note, div.tip, div.warning {
76
+ margin: 2em ;
77
+ border: medium outset ;
78
+ padding: 1em }
79
+
80
+ div.admonition p.admonition-title, div.hint p.admonition-title,
81
+ div.important p.admonition-title, div.note p.admonition-title,
82
+ div.tip p.admonition-title {
83
+ font-weight: bold ;
84
+ font-family: sans-serif }
85
+
86
+ div.attention p.admonition-title, div.caution p.admonition-title,
87
+ div.danger p.admonition-title, div.error p.admonition-title,
88
+ div.warning p.admonition-title, .code .error {
89
+ color: red ;
90
+ font-weight: bold ;
91
+ font-family: sans-serif }
92
+
93
+ /* Uncomment (and remove this text!) to get reduced vertical space in
94
+ compound paragraphs.
95
+ div.compound .compound-first, div.compound .compound-middle {
96
+ margin-bottom: 0.5em }
97
+
98
+ div.compound .compound-last, div.compound .compound-middle {
99
+ margin-top: 0.5em }
100
+ */
101
+
102
+ div.dedication {
103
+ margin: 2em 5em ;
104
+ text-align: center ;
105
+ font-style: italic }
106
+
107
+ div.dedication p.topic-title {
108
+ font-weight: bold ;
109
+ font-style: normal }
110
+
111
+ div.figure {
112
+ margin-left: 2em ;
113
+ margin-right: 2em }
114
+
115
+ div.footer, div.header {
116
+ clear: both;
117
+ font-size: smaller }
118
+
119
+ div.line-block {
120
+ display: block ;
121
+ margin-top: 1em ;
122
+ margin-bottom: 1em }
123
+
124
+ div.line-block div.line-block {
125
+ margin-top: 0 ;
126
+ margin-bottom: 0 ;
127
+ margin-left: 1.5em }
128
+
129
+ div.sidebar {
130
+ margin: 0 0 0.5em 1em ;
131
+ border: medium outset ;
132
+ padding: 1em ;
133
+ background-color: #ffffee ;
134
+ width: 40% ;
135
+ float: right ;
136
+ clear: right }
137
+
138
+ div.sidebar p.rubric {
139
+ font-family: sans-serif ;
140
+ font-size: medium }
141
+
142
+ div.system-messages {
143
+ margin: 5em }
144
+
145
+ div.system-messages h1 {
146
+ color: red }
147
+
148
+ div.system-message {
149
+ border: medium outset ;
150
+ padding: 1em }
151
+
152
+ div.system-message p.system-message-title {
153
+ color: red ;
154
+ font-weight: bold }
155
+
156
+ div.topic {
157
+ margin: 2em }
158
+
159
+ h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
160
+ h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
161
+ margin-top: 0.4em }
162
+
163
+ h1.title {
164
+ text-align: center }
165
+
166
+ h2.subtitle {
167
+ text-align: center }
168
+
169
+ hr.docutils {
170
+ width: 75% }
171
+
172
+ img.align-left, .figure.align-left, object.align-left, table.align-left {
173
+ clear: left ;
174
+ float: left ;
175
+ margin-right: 1em }
176
+
177
+ img.align-right, .figure.align-right, object.align-right, table.align-right {
178
+ clear: right ;
179
+ float: right ;
180
+ margin-left: 1em }
181
+
182
+ img.align-center, .figure.align-center, object.align-center {
183
+ display: block;
184
+ margin-left: auto;
185
+ margin-right: auto;
186
+ }
187
+
188
+ table.align-center {
189
+ margin-left: auto;
190
+ margin-right: auto;
191
+ }
192
+
193
+ .align-left {
194
+ text-align: left }
195
+
196
+ .align-center {
197
+ clear: both ;
198
+ text-align: center }
199
+
200
+ .align-right {
201
+ text-align: right }
202
+
203
+ /* reset inner alignment in figures */
204
+ div.align-right {
205
+ text-align: inherit }
206
+
207
+ /* div.align-center * { */
208
+ /* text-align: left } */
209
+
210
+ .align-top {
211
+ vertical-align: top }
212
+
213
+ .align-middle {
214
+ vertical-align: middle }
215
+
216
+ .align-bottom {
217
+ vertical-align: bottom }
218
+
219
+ ol.simple, ul.simple {
220
+ margin-bottom: 1em }
221
+
222
+ ol.arabic {
223
+ list-style: decimal }
224
+
225
+ ol.loweralpha {
226
+ list-style: lower-alpha }
227
+
228
+ ol.upperalpha {
229
+ list-style: upper-alpha }
230
+
231
+ ol.lowerroman {
232
+ list-style: lower-roman }
233
+
234
+ ol.upperroman {
235
+ list-style: upper-roman }
236
+
237
+ p.attribution {
238
+ text-align: right ;
239
+ margin-left: 50% }
240
+
241
+ p.caption {
242
+ font-style: italic }
243
+
244
+ p.credits {
245
+ font-style: italic ;
246
+ font-size: smaller }
247
+
248
+ p.label {
249
+ white-space: nowrap }
250
+
251
+ p.rubric {
252
+ font-weight: bold ;
253
+ font-size: larger ;
254
+ color: maroon ;
255
+ text-align: center }
256
+
257
+ p.sidebar-title {
258
+ font-family: sans-serif ;
259
+ font-weight: bold ;
260
+ font-size: larger }
261
+
262
+ p.sidebar-subtitle {
263
+ font-family: sans-serif ;
264
+ font-weight: bold }
265
+
266
+ p.topic-title {
267
+ font-weight: bold }
268
+
269
+ pre.address {
270
+ margin-bottom: 0 ;
271
+ margin-top: 0 ;
272
+ font: inherit }
273
+
274
+ pre.literal-block, pre.doctest-block, pre.math, pre.code {
275
+ margin-left: 2em ;
276
+ margin-right: 2em }
277
+
278
+ pre.code .ln { color: gray; } /* line numbers */
279
+ pre.code, code { background-color: #eeeeee }
280
+ pre.code .comment, code .comment { color: #5C6576 }
281
+ pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
282
+ pre.code .literal.string, code .literal.string { color: #0C5404 }
283
+ pre.code .name.builtin, code .name.builtin { color: #352B84 }
284
+ pre.code .deleted, code .deleted { background-color: #DEB0A1}
285
+ pre.code .inserted, code .inserted { background-color: #A3D289}
286
+
287
+ span.classifier {
288
+ font-family: sans-serif ;
289
+ font-style: oblique }
290
+
291
+ span.classifier-delimiter {
292
+ font-family: sans-serif ;
293
+ font-weight: bold }
294
+
295
+ span.interpreted {
296
+ font-family: sans-serif }
297
+
298
+ span.option {
299
+ white-space: nowrap }
300
+
301
+ span.pre {
302
+ white-space: pre }
303
+
304
+ span.problematic, pre.problematic {
305
+ color: red }
306
+
307
+ span.section-subtitle {
308
+ /* font-size relative to parent (h1..h6 element) */
309
+ font-size: 80% }
310
+
311
+ table.citation {
312
+ border-left: solid 1px gray;
313
+ margin-left: 1px }
314
+
315
+ table.docinfo {
316
+ margin: 2em 4em }
317
+
318
+ table.docutils {
319
+ margin-top: 0.5em ;
320
+ margin-bottom: 0.5em }
321
+
322
+ table.footnote {
323
+ border-left: solid 1px black;
324
+ margin-left: 1px }
325
+
326
+ table.docutils td, table.docutils th,
327
+ table.docinfo td, table.docinfo th {
328
+ padding-left: 0.5em ;
329
+ padding-right: 0.5em ;
330
+ vertical-align: top }
331
+
332
+ table.docutils th.field-name, table.docinfo th.docinfo-name {
333
+ font-weight: bold ;
334
+ text-align: left ;
335
+ white-space: nowrap ;
336
+ padding-left: 0 }
337
+
338
+ /* "booktabs" style (no vertical lines) */
339
+ table.docutils.booktabs {
340
+ border: 0px;
341
+ border-top: 2px solid;
342
+ border-bottom: 2px solid;
343
+ border-collapse: collapse;
344
+ }
345
+ table.docutils.booktabs * {
346
+ border: 0px;
347
+ }
348
+ table.docutils.booktabs th {
349
+ border-bottom: thin solid;
350
+ text-align: left;
351
+ }
352
+
353
+ h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
354
+ h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
355
+ font-size: 100% }
356
+
357
+ ul.auto-toc {
358
+ list-style-type: none }
359
+
360
+ </style>
361
+ </head>
362
+ <body>
363
+ <div class="document">
364
+
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>
371
+ <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372
+ !! This file is generated by oca-gen-addon-readme !!
373
+ !! changes will be overwritten. !!
374
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375
+ !! source digest: sha256:0a1433fb1fb696e8ffb0fb469e9d901e496d1363488ef86b830516e681153057
376
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377
+ <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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>
378
+ <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>
381
+ <p><strong>Table of contents</strong></p>
382
+ <div class="contents local topic" id="contents">
383
+ <ul class="simple">
384
+ <li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
385
+ <li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
386
+ <li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
387
+ <li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
388
+ <li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
389
+ </ul>
390
+ </li>
391
+ </ul>
392
+ </div>
393
+ <div class="section" id="bug-tracker">
394
+ <h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
395
+ <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/payroll/issues">GitHub Issues</a>.
396
+ In case of trouble, please check there if your issue has already been reported.
397
+ If you spotted it first, help us to smash it by providing a detailed and welcomed
398
+ <a class="reference external" href="https://github.com/OCA/payroll/issues/new?body=module:%20hr_payroll_document%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
399
+ <p>Do not contact contributors directly about support or help with technical issues.</p>
400
+ </div>
401
+ <div class="section" id="credits">
402
+ <h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
403
+ <div class="section" id="authors">
404
+ <h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
405
+ <ul class="simple">
406
+ <li>APSL</li>
407
+ </ul>
408
+ </div>
409
+ <div class="section" id="contributors">
410
+ <h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
411
+ <ul class="simple">
412
+ <li>Antoni Marroig Campomar &lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;</li>
413
+ <li>Miquel Alzanillas Monserrat &lt;<a class="reference external" href="mailto:malzanillas&#64;apsl.net">malzanillas&#64;apsl.net</a>&gt;</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>
418
+ </ul>
419
+ </div>
420
+ <div class="section" id="maintainers">
421
+ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
422
+ <p>This module is maintained by the OCA.</p>
423
+ <a class="reference external image-reference" href="https://odoo-community.org">
424
+ <img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
425
+ </a>
426
+ <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
427
+ mission is to support the collaborative development of Odoo features and
428
+ promote its widespread use.</p>
429
+ <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
430
+ <p><a class="reference external image-reference" href="https://github.com/peluko00"><img alt="peluko00" src="https://github.com/peluko00.png?size=40px" /></a></p>
431
+ <p>This module is part of the <a class="reference external" href="https://github.com/OCA/payroll/tree/16.0/hr_payroll_document">OCA/payroll</a> project on GitHub.</p>
432
+ <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
433
+ </div>
434
+ </div>
435
+ </div>
436
+ </div>
437
+ </body>
438
+ </html>
@@ -0,0 +1 @@
1
+ from . import test_hr_payroll_document
@@ -0,0 +1,76 @@
1
+ # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
+ import base64
3
+ import contextlib
4
+ from unittest import mock
5
+
6
+ from odoo.modules.module import get_module_resource
7
+ from odoo.tests import common
8
+
9
+ from odoo.addons.mail.tests.common import mail_new_test_user
10
+
11
+
12
+ class TestHrPayrollDocument(common.TransactionCase):
13
+ def setUp(self):
14
+ super(TestHrPayrollDocument, self).setUp()
15
+ self.env.user.tz = "Europe/Brussels"
16
+ self.user_admin = self.env.ref("base.user_admin")
17
+
18
+ # Fix Company without country
19
+ self.env.company.country_id = False
20
+
21
+ # Test users to use through the various tests
22
+ self.user_employee = mail_new_test_user(
23
+ self.env, login="david", groups="base.group_user"
24
+ )
25
+ self.user_employee_id = self.user_employee.id
26
+
27
+ # Hr Data
28
+ self.employee_emp = self.env["hr.employee"].create(
29
+ {
30
+ "name": "David Employee",
31
+ "user_id": self.user_employee_id,
32
+ "company_id": 1,
33
+ "identification_id": "30831011V",
34
+ }
35
+ )
36
+
37
+ self.wizard = self._create_wizard(
38
+ "January", ["hr_payroll_document", "tests", "test.pdf"]
39
+ )
40
+
41
+ def _create_wizard(self, subject, file_path):
42
+ with open(get_module_resource(*file_path), "rb") as pdf_file:
43
+ encoded_string = base64.b64encode(pdf_file.read())
44
+ ir_values = {
45
+ "name": "test",
46
+ "type": "binary",
47
+ "datas": encoded_string,
48
+ "store_fname": encoded_string,
49
+ "res_model": "payroll.management.wizard",
50
+ "res_id": 1,
51
+ }
52
+ self.attachment = self.env["ir.attachment"].create(ir_values)
53
+ self.subject = subject
54
+ return self.env["payroll.management.wizard"].create(
55
+ {"payrolls": [self.attachment.id], "subject": self.subject}
56
+ )
57
+
58
+ @contextlib.contextmanager
59
+ def _mock_valid_identification(self, employee, identification_code):
60
+ def _mocked_validate_payroll_identification(self, code=None):
61
+ if code is None:
62
+ code = employee.identification_id
63
+ return code == identification_code
64
+
65
+ with mock.patch.object(
66
+ type(employee),
67
+ "_validate_payroll_identification",
68
+ _mocked_validate_payroll_identification,
69
+ ) as patch:
70
+ patch.side_effect = _mocked_validate_payroll_identification
71
+ yield
72
+
73
+ def fill_company_id(self):
74
+ self.env.company.country_id = self.env["res.country"].search(
75
+ [("name", "=", "Spain")]
76
+ )
@@ -0,0 +1,122 @@
1
+ import base64
2
+ import io
3
+
4
+ import pypdf
5
+
6
+ from odoo import _
7
+ from odoo.exceptions import UserError, ValidationError
8
+
9
+ from odoo.addons.hr_payroll_document.tests.common import TestHrPayrollDocument
10
+
11
+
12
+ class TestHRPayrollDocument(TestHrPayrollDocument):
13
+ def setUp(self, *args, **kwargs):
14
+ super().setUp(*args, **kwargs)
15
+
16
+ def test_extension_error(self):
17
+ self.wizard = self._create_wizard(
18
+ "January", ["hr_payroll_document", "tests", "test.docx"]
19
+ )
20
+ with self.assertRaises(ValidationError):
21
+ self.wizard.send_payrolls()
22
+
23
+ def test_company_id_required(self):
24
+ with self.assertRaises(UserError):
25
+ self.wizard.send_payrolls()
26
+
27
+ def test_employee_vat_not_valid(self):
28
+ self.fill_company_id()
29
+ with self.assertRaises(ValidationError):
30
+ employees = self.env["hr.employee"].search([])
31
+ for employee in employees:
32
+ if not employee.identification_id:
33
+ employee.identification_id = "XXXXXXX"
34
+
35
+ def test_one_employee_not_found(self):
36
+ self.fill_company_id()
37
+ self.env["hr.employee"].search([("id", "=", 1)]).identification_id = "37936636E"
38
+ self.assertEqual(
39
+ self.wizard.send_payrolls(),
40
+ {
41
+ "type": "ir.actions.client",
42
+ "tag": "display_notification",
43
+ "params": {
44
+ "title": _("Employees not found"),
45
+ "message": _("IDs whose employee has not been found: ")
46
+ + "51000278D",
47
+ "sticky": True,
48
+ "type": "warning",
49
+ "next": {
50
+ "name": _("Payrolls sent"),
51
+ "type": "ir.actions.act_window",
52
+ "res_model": "hr.employee",
53
+ "views": [
54
+ (False, "kanban"),
55
+ (False, "tree"),
56
+ (False, "form"),
57
+ (False, "activity"),
58
+ ],
59
+ },
60
+ },
61
+ },
62
+ )
63
+
64
+ def test_send_payrolls_correctly(self):
65
+ self.fill_company_id()
66
+ self.env["hr.employee"].search([("id", "=", 1)]).identification_id = "51000278D"
67
+ self.assertEqual(
68
+ self.wizard.send_payrolls(),
69
+ {
70
+ "type": "ir.actions.client",
71
+ "tag": "display_notification",
72
+ "params": {
73
+ "title": _("Payrolls sent"),
74
+ "message": _("Payrolls sent to employees correctly"),
75
+ "sticky": False,
76
+ "type": "success",
77
+ "next": {
78
+ "name": _("Payrolls sent"),
79
+ "type": "ir.actions.act_window",
80
+ "res_model": "hr.employee",
81
+ "views": [
82
+ (False, "kanban"),
83
+ (False, "tree"),
84
+ (False, "form"),
85
+ (False, "activity"),
86
+ ],
87
+ },
88
+ },
89
+ },
90
+ )
91
+
92
+ def test_optional_encryption(self):
93
+ """The employee's payroll can be not encrypted."""
94
+ # Arrange
95
+ self.fill_company_id()
96
+ employee = self.employee_emp
97
+ employee.update(
98
+ {
99
+ "identification_id": "51000278D",
100
+ "no_payroll_encryption": True,
101
+ }
102
+ )
103
+ # pre-condition
104
+ self.assertTrue(employee.no_payroll_encryption)
105
+
106
+ # Act
107
+ self.wizard.send_payrolls()
108
+
109
+ # Assert
110
+ payroll = (
111
+ self.env["ir.attachment.payroll.custom"]
112
+ .search(
113
+ [
114
+ ("identification_id", "=", employee.identification_id),
115
+ ]
116
+ )
117
+ .attachment_id
118
+ )
119
+ self.assertTrue(payroll)
120
+ payroll_content = base64.b64decode(payroll.datas)
121
+ payroll_pdf = pypdf.PdfReader(io.BytesIO(payroll_content))
122
+ self.assertFalse(payroll_pdf.is_encrypted)
@@ -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>
@@ -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,0 +1 @@
1
+ from . import payroll_management_wizard