odoo-addon-hr-payroll-document 16.0.1.0.0.2__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.

Potentially problematic release.


This version of odoo-addon-hr-payroll-document might be problematic. Click here for more details.

Files changed (28) hide show
  1. odoo/addons/hr_payroll_document/README.rst +85 -0
  2. odoo/addons/hr_payroll_document/__init__.py +2 -0
  3. odoo/addons/hr_payroll_document/__manifest__.py +17 -0
  4. odoo/addons/hr_payroll_document/data/email_payroll_employee.xml +20 -0
  5. odoo/addons/hr_payroll_document/i18n/ca_ES.po +281 -0
  6. odoo/addons/hr_payroll_document/i18n/es.po +281 -0
  7. odoo/addons/hr_payroll_document/i18n/hr_payroll_document.pot +220 -0
  8. odoo/addons/hr_payroll_document/models/__init__.py +3 -0
  9. odoo/addons/hr_payroll_document/models/hr_employee.py +14 -0
  10. odoo/addons/hr_payroll_document/models/ir_attachment.py +14 -0
  11. odoo/addons/hr_payroll_document/models/ir_attachment_payroll_custom.py +18 -0
  12. odoo/addons/hr_payroll_document/readme/CONTRIBUTORS.rst +2 -0
  13. odoo/addons/hr_payroll_document/readme/DESCRIPTION.rst +1 -0
  14. odoo/addons/hr_payroll_document/security/ir.model.access.csv +3 -0
  15. odoo/addons/hr_payroll_document/static/description/icon.png +0 -0
  16. odoo/addons/hr_payroll_document/static/description/index.html +424 -0
  17. odoo/addons/hr_payroll_document/tests/__init__.py +1 -0
  18. odoo/addons/hr_payroll_document/tests/common.py +51 -0
  19. odoo/addons/hr_payroll_document/tests/test.docx +0 -0
  20. odoo/addons/hr_payroll_document/tests/test.pdf +0 -0
  21. odoo/addons/hr_payroll_document/tests/test_hr_payroll_document.py +107 -0
  22. odoo/addons/hr_payroll_document/wizard/__init__.py +1 -0
  23. odoo/addons/hr_payroll_document/wizard/payroll_management_wizard.py +169 -0
  24. odoo/addons/hr_payroll_document/wizard/payroll_management_wizard.xml +42 -0
  25. odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/METADATA +104 -0
  26. odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/RECORD +28 -0
  27. odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/WHEEL +5 -0
  28. odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,169 @@
1
+ import base64
2
+ from base64 import b64decode
3
+
4
+ from pypdf import PdfReader, PdfWriter
5
+
6
+ from odoo import _, fields, models
7
+ from odoo.exceptions import UserError, ValidationError
8
+
9
+
10
+ class PayrollManagamentWizard(models.TransientModel):
11
+ _name = "payroll.management.wizard"
12
+ _description = "Payroll Management"
13
+
14
+ subject = fields.Char(
15
+ help="Enter the title of the payroll whether it is the month, week, day, etc."
16
+ )
17
+ payrolls = fields.Many2many(
18
+ "ir.attachment",
19
+ "payrol_rel",
20
+ "doc_id",
21
+ "attach_id3",
22
+ copy=False,
23
+ )
24
+
25
+ def send_payrolls(self):
26
+ not_found = set()
27
+ self.merge_pdfs()
28
+ reader = PdfReader("/tmp/merged-pdf.pdf")
29
+ employees = set()
30
+
31
+ # Validate if company have country
32
+ if not self.env.company.country_id:
33
+ raise UserError(_("You must to filled country field of company"))
34
+
35
+ # Find all IDs of the employees
36
+ for page in reader.pages:
37
+ for value in page.extract_text().split():
38
+ if self.validate_id(value) and value != self.env.company.vat:
39
+ employee = self.env["hr.employee"].search(
40
+ [("identification_id", "=", value)]
41
+ )
42
+ if employee:
43
+ employees.add(employee)
44
+ else:
45
+ not_found.add(value)
46
+ break
47
+
48
+ for employee in list(employees):
49
+ pdfWriter = PdfWriter()
50
+ for page in reader.pages:
51
+ if employee.identification_id in page.extract_text():
52
+ # Save pdf with payrolls of employee
53
+ pdfWriter.add_page(page)
54
+
55
+ path = "/tmp/" + _("Payroll ") + employee.name + ".pdf"
56
+
57
+ # Encrypt the payroll file with the identification identifier of the employee
58
+ pdfWriter.encrypt(employee.identification_id, algorithm="AES-256")
59
+
60
+ f = open(path, "wb")
61
+ pdfWriter.write(f)
62
+ f.close()
63
+
64
+ # Send payroll to the employee
65
+ self.send_mail(employee, path)
66
+
67
+ if not_found:
68
+ return {
69
+ "type": "ir.actions.client",
70
+ "tag": "display_notification",
71
+ "params": {
72
+ "title": _("Employees not found"),
73
+ "message": _("IDs whose employee has not been found: ")
74
+ + ", ".join(list(not_found)),
75
+ "sticky": True,
76
+ "type": "warning",
77
+ "next": {
78
+ "name": _("Payrolls sent"),
79
+ "type": "ir.actions.act_window",
80
+ "res_model": "hr.employee",
81
+ "views": [
82
+ (
83
+ self.env.ref("hr.hr_employee_public_view_kanban").id,
84
+ "list",
85
+ )
86
+ ],
87
+ },
88
+ },
89
+ }
90
+
91
+ return {
92
+ "type": "ir.actions.client",
93
+ "tag": "display_notification",
94
+ "params": {
95
+ "title": _("Payrolls sent"),
96
+ "message": _("Payrolls sent to employees correctly"),
97
+ "sticky": False,
98
+ "type": "success",
99
+ "next": {
100
+ "name": _("Payrolls sent"),
101
+ "type": "ir.actions.act_window",
102
+ "res_model": "hr.employee",
103
+ "views": [
104
+ (self.env.ref("hr.hr_employee_public_view_kanban").id, "list")
105
+ ],
106
+ },
107
+ },
108
+ }
109
+
110
+ def merge_pdfs(self):
111
+ # Merge the pdfs together
112
+ pdfs = []
113
+ for file in self.payrolls:
114
+ b64 = file.datas
115
+ btes = b64decode(b64, validate=True)
116
+ if btes[0:4] != b"%PDF":
117
+ raise ValidationError(_("Missing pdf file signature"))
118
+ f = open("/tmp/" + file.name, "wb")
119
+ f.write(btes)
120
+ f.close()
121
+ pdfs.append(f.name)
122
+
123
+ merger = PdfWriter()
124
+
125
+ for pdf in pdfs:
126
+ merger.append(pdf)
127
+
128
+ merger.write("/tmp/merged-pdf.pdf")
129
+ merger.close()
130
+
131
+ def send_mail(self, employee, path):
132
+ # Open Payrolls of employee and encode content
133
+ with open(path, "rb") as pdf_file:
134
+ encoded_string = base64.b64encode(pdf_file.read())
135
+
136
+ # Attach file to email
137
+ ir_values = {
138
+ "name": _("Payroll") + "_" + self.subject + "_" + employee.name,
139
+ "type": "binary",
140
+ "datas": encoded_string,
141
+ "store_fname": encoded_string,
142
+ "res_model": "hr.employee",
143
+ "res_id": employee.id,
144
+ }
145
+
146
+ # Save payroll attachment to all employee payrolls attachments
147
+ self.env["ir.attachment.payroll.custom"].create(
148
+ {
149
+ "attachment_id": self.env["ir.attachment"].create(ir_values).id,
150
+ "employee": employee.name,
151
+ "subject": self.subject,
152
+ "identification_id": employee.identification_id,
153
+ }
154
+ )
155
+
156
+ # Send mail
157
+ mail_template = self.env.ref(
158
+ "hr_payroll_document.payroll_employee_email_template"
159
+ )
160
+ data_id = [(6, 0, [self.env["ir.attachment"].create(ir_values).id])]
161
+ mail_template.attachment_ids = data_id
162
+ mail_template.with_context(**{"subject": self.subject}).send_mail(
163
+ employee.id, force_send=True
164
+ )
165
+
166
+ def validate_id(self, number):
167
+ return self.env["res.partner"].simple_vat_check(
168
+ self.env.company.country_id.code, number
169
+ )
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <odoo>
3
+ <record id="payrolls_management_wizard_form" model="ir.ui.view">
4
+ <field name="name">payroll.management.wizard.form</field>
5
+ <field name="model">payroll.management.wizard</field>
6
+ <field name="arch" type="xml">
7
+ <form>
8
+ <sheet>
9
+ <group>
10
+ <field name="subject" required="1" />
11
+ </group>
12
+ <field name="payrolls" widget="many2many_binary" />
13
+ <footer>
14
+ <button
15
+ string="Send"
16
+ name="send_payrolls"
17
+ type="object"
18
+ class="oe_highlight"
19
+ />
20
+ <button
21
+ string="Close"
22
+ class="btn btn-secondary"
23
+ special="cancel"
24
+ />
25
+ </footer>
26
+ </sheet>
27
+ </form>
28
+ </field>
29
+ </record>
30
+ <record id="payrolls_management_wizard_action" model="ir.actions.act_window">
31
+ <field name="name">Payrolls Management</field>
32
+ <field name="res_model">payroll.management.wizard</field>
33
+ <field name="view_mode">form</field>
34
+ <field name="target">new</field>
35
+ </record>
36
+
37
+ <menuitem
38
+ id="payrolls_management_wizard_menu_action"
39
+ action="payrolls_management_wizard_action"
40
+ parent="hr.menu_hr_root"
41
+ />
42
+ </odoo>
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.1
2
+ Name: odoo-addon-hr-payroll-document
3
+ Version: 16.0.1.0.0.2
4
+ Summary: Manage payroll for each employee
5
+ Home-page: https://github.com/OCA/payroll
6
+ Author: APSL, Odoo Community Association (OCA)
7
+ Author-email: support@odoo-community.org
8
+ License: AGPL-3
9
+ Platform: UNKNOWN
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Framework :: Odoo
12
+ Classifier: Framework :: Odoo :: 16.0
13
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: odoo <16.1dev,>=16.0a
16
+ Requires-Dist: pypdf
17
+
18
+ =====================
19
+ HR - Payroll Document
20
+ =====================
21
+
22
+ ..
23
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24
+ !! This file is generated by oca-gen-addon-readme !!
25
+ !! changes will be overwritten. !!
26
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27
+ !! source digest: sha256:3698f5f5e529d5d32ae80cdc1ab30660ad4e5d39b6d98f8dace97a0b233743c5
28
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29
+
30
+ .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
31
+ :target: https://odoo-community.org/page/development-status
32
+ :alt: Beta
33
+ .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
34
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
35
+ :alt: License: AGPL-3
36
+ .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github
37
+ :target: https://github.com/OCA/payroll/tree/16.0/hr_payroll_document
38
+ :alt: OCA/payroll
39
+ .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
40
+ :target: https://translation.odoo-community.org/projects/payroll-16-0/payroll-16-0-hr_payroll_document
41
+ :alt: Translate me on Weblate
42
+ .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
43
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/payroll&target_branch=16.0
44
+ :alt: Try me on Runboat
45
+
46
+ |badge1| |badge2| |badge3| |badge4| |badge5|
47
+
48
+ This module have a wizard view to manage the different payrolls of employees which is identified by the identification_id attribute.
49
+
50
+ **Table of contents**
51
+
52
+ .. contents::
53
+ :local:
54
+
55
+ Bug Tracker
56
+ ===========
57
+
58
+ Bugs are tracked on `GitHub Issues <https://github.com/OCA/payroll/issues>`_.
59
+ In case of trouble, please check there if your issue has already been reported.
60
+ If you spotted it first, help us to smash it by providing a detailed and welcomed
61
+ `feedback <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**>`_.
62
+
63
+ Do not contact contributors directly about support or help with technical issues.
64
+
65
+ Credits
66
+ =======
67
+
68
+ Authors
69
+ ~~~~~~~
70
+
71
+ * APSL
72
+
73
+ Contributors
74
+ ~~~~~~~~~~~~
75
+
76
+ * Antoni Marroig Campomar <amarroig@apsl.net>
77
+ * Miquel Alzanillas Monserrat <malzanillas@apsl.net>
78
+
79
+ Maintainers
80
+ ~~~~~~~~~~~
81
+
82
+ This module is maintained by the OCA.
83
+
84
+ .. image:: https://odoo-community.org/logo.png
85
+ :alt: Odoo Community Association
86
+ :target: https://odoo-community.org
87
+
88
+ OCA, or the Odoo Community Association, is a nonprofit organization whose
89
+ mission is to support the collaborative development of Odoo features and
90
+ promote its widespread use.
91
+
92
+ .. |maintainer-peluko00| image:: https://github.com/peluko00.png?size=40px
93
+ :target: https://github.com/peluko00
94
+ :alt: peluko00
95
+
96
+ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
97
+
98
+ |maintainer-peluko00|
99
+
100
+ This module is part of the `OCA/payroll <https://github.com/OCA/payroll/tree/16.0/hr_payroll_document>`_ project on GitHub.
101
+
102
+ You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
103
+
104
+
@@ -0,0 +1,28 @@
1
+ odoo/addons/hr_payroll_document/README.rst,sha256=PhM-J45foAEXvHFSMvqCU9Y6SIFaHzCx3C3UYdFx-F8,3157
2
+ odoo/addons/hr_payroll_document/__init__.py,sha256=4xA2wEP-VC0HAopaFS8ihQ1VjQDTg34AvIvOmq-alrM,42
3
+ odoo/addons/hr_payroll_document/__manifest__.py,sha256=K8DXPp6eBVqQJ0uA1FJVQo8xyBbqUohmG0tyMHcQBVE,551
4
+ odoo/addons/hr_payroll_document/data/email_payroll_employee.xml,sha256=bcbPEqEcHJAQ5gQxWyW_RGkx6XCC8ZHL3lKvSrxHRt8,2584
5
+ odoo/addons/hr_payroll_document/i18n/ca_ES.po,sha256=olTbecysICtoVZ769Z4TALONTid55d0x5oU7Z9L5xA4,12150
6
+ odoo/addons/hr_payroll_document/i18n/es.po,sha256=GvIgFOPvhu-OwUMeyrPLDWNudEoTbT6M2cLJlO2fEG4,12192
7
+ odoo/addons/hr_payroll_document/i18n/hr_payroll_document.pot,sha256=_bCeCiZmaFFc2xI7eh22PCoRDmnIqacyMdp7KKAcr1U,9439
8
+ odoo/addons/hr_payroll_document/models/__init__.py,sha256=Kp5ozXigcN09bmXkIp5PfMLztNQCDw7LthuwqxpS7Fw,97
9
+ odoo/addons/hr_payroll_document/models/hr_employee.py,sha256=rmch_eY4E2t0e1DbySJIPJ1uPrkX7znaP2jGZj_8DL0,466
10
+ odoo/addons/hr_payroll_document/models/ir_attachment.py,sha256=yAWi0rX88nOxa4sePk2iEMtm2hUrolapquA5EAdUd3I,295
11
+ odoo/addons/hr_payroll_document/models/ir_attachment_payroll_custom.py,sha256=Hnqiz3LgzDlnDkjA1u4-gscFuy09m6Jl41WTHUiQUEE,535
12
+ odoo/addons/hr_payroll_document/readme/CONTRIBUTORS.rst,sha256=GxpYRjce-v90SeI02isCyaLa894ju75wrJg_EpCjNNw,99
13
+ odoo/addons/hr_payroll_document/readme/DESCRIPTION.rst,sha256=XGTSCLXP2pGtWapFblcoT8HuggxZF-ya3RryFiMTRkA,133
14
+ odoo/addons/hr_payroll_document/security/ir.model.access.csv,sha256=W64tysGGKd4g_riQcuKJK0j5um9vgyd-xD9WzX5J4WE,310
15
+ odoo/addons/hr_payroll_document/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
16
+ odoo/addons/hr_payroll_document/static/description/index.html,sha256=FHarDhZuhbCxNZpWyil9Sf3theTpv3RYRRclDfpy-L0,12552
17
+ odoo/addons/hr_payroll_document/tests/__init__.py,sha256=qllw2tYyKSOtLtmPAudIhnJTNvqIVcW0P4y39LtWMxE,39
18
+ odoo/addons/hr_payroll_document/tests/common.py,sha256=7K-uOLoyUGnjaafozKiIlWdLwuTfaiucrZUPHvJ70YE,1759
19
+ odoo/addons/hr_payroll_document/tests/test.docx,sha256=Ba_5DoZ5yWG_WvxZlW9kvRU_XgyzK3pbs_OEYyE7P4Q,18655
20
+ odoo/addons/hr_payroll_document/tests/test.pdf,sha256=5I3tdxTT9SpLeyREtjxJErUhrU7VGBhKDN78T-j0r7A,33335
21
+ odoo/addons/hr_payroll_document/tests/test_hr_payroll_document.py,sha256=wvzt90N_TF9LtT98XrjB9hSaI4YtIxwbNfqb_VwR38M,3956
22
+ odoo/addons/hr_payroll_document/wizard/__init__.py,sha256=IkYY2iCn8l-ZaOF5QeQ9HDJl5bzzxCpsfeFvSCcl8x4,40
23
+ odoo/addons/hr_payroll_document/wizard/payroll_management_wizard.py,sha256=l4-98WAhti28jOlY8Klnf5Fqtw5QA8ZiF0WYnQcIGsM,5766
24
+ odoo/addons/hr_payroll_document/wizard/payroll_management_wizard.xml,sha256=7K-cZsZ7tMB-LSobFzI4y9vCB4xVz5m4b0v6XqpZO38,1647
25
+ odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/METADATA,sha256=Cf0CLTrzTnnXTNAnYijGX2343hUf93CHnBhaho9Bbks,3716
26
+ odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
27
+ odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
28
+ odoo_addon_hr_payroll_document-16.0.1.0.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.42.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+