From aa4d32018b6dccd4719f2d69cb9e52f3baf356d6 Mon Sep 17 00:00:00 2001 From: Antoni Marroig Campomar Date: Tue, 21 May 2024 17:19:18 +0200 Subject: [PATCH] [MIG] hr_payroll_document : Migration to 17.0 --- hr_payroll_document/README.rst | 6 +- hr_payroll_document/__manifest__.py | 3 +- hr_payroll_document/i18n/es.po | 115 +++++++----------- hr_payroll_document/models/__init__.py | 1 + hr_payroll_document/models/hr_employee.py | 32 ++++- hr_payroll_document/models/ir_attachment.py | 2 +- .../models/ir_attachment_payroll_custom.py | 7 +- hr_payroll_document/models/res_users.py | 20 +++ hr_payroll_document/readme/CONTRIBUTORS.md | 5 +- hr_payroll_document/readme/DESCRIPTION.md | 3 +- .../static/description/index.html | 18 ++- hr_payroll_document/tests/common.py | 51 -------- .../tests/test_hr_payroll_document.py | 108 ++++++++-------- .../views/hr_employee_views.xml | 107 ++++++++++++++++ .../wizard/payroll_management_wizard.py | 43 +++---- .../wizard/payroll_management_wizard.xml | 3 +- payroll/README.rst | 20 +-- payroll/readme/CONTRIBUTORS.md | 5 + payroll/readme/CONTRIBUTORS.rst | 5 - payroll/readme/DESCRIPTION.md | 5 + payroll/readme/DESCRIPTION.rst | 3 - payroll/static/description/index.html | 15 ++- 22 files changed, 336 insertions(+), 241 deletions(-) create mode 100644 hr_payroll_document/models/res_users.py delete mode 100644 hr_payroll_document/tests/common.py create mode 100644 hr_payroll_document/views/hr_employee_views.xml create mode 100644 payroll/readme/CONTRIBUTORS.md delete mode 100644 payroll/readme/CONTRIBUTORS.rst create mode 100644 payroll/readme/DESCRIPTION.md delete mode 100644 payroll/readme/DESCRIPTION.rst diff --git a/hr_payroll_document/README.rst b/hr_payroll_document/README.rst index f72573f0..86c136c1 100644 --- a/hr_payroll_document/README.rst +++ b/hr_payroll_document/README.rst @@ -57,8 +57,10 @@ Authors Contributors ------------ -- Antoni Marroig Campomar -- Miquel Alzanillas Monserrat +- `APSL-Nagarro `__: + + - Antoni Marroig + - Miquel Alzanillas Maintainers ----------- diff --git a/hr_payroll_document/__manifest__.py b/hr_payroll_document/__manifest__.py index 62648d12..10be31f8 100644 --- a/hr_payroll_document/__manifest__.py +++ b/hr_payroll_document/__manifest__.py @@ -5,7 +5,7 @@ "website": "https://github.com/OCA/payroll", "license": "AGPL-3", "category": "Payrolls", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "depends": ["hr", "base_vat"], "maintainers": ["peluko00"], "external_dependencies": {"python": ["pypdf"]}, @@ -13,5 +13,6 @@ "wizard/payroll_management_wizard.xml", "security/ir.model.access.csv", "data/email_payroll_employee.xml", + "views/hr_employee_views.xml", ], } diff --git a/hr_payroll_document/i18n/es.po b/hr_payroll_document/i18n/es.po index 9a0ac376..7820196c 100644 --- a/hr_payroll_document/i18n/es.po +++ b/hr_payroll_document/i18n/es.po @@ -4,13 +4,12 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-12-14 10:28+0000\n" -"PO-Revision-Date: 2023-12-14 10:28+0000\n" +"POT-Creation-Date: 2024-05-21 15:13+0000\n" +"PO-Revision-Date: 2024-05-21 15:13+0000\n" "Last-Translator: \n" "Language-Team: \n" -"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" @@ -23,34 +22,7 @@ msgid "" " \n" " \n" " \n" -"
\"{{object.company_id.name}}\"

Payroll

Hello ,

We send you the payroll with the subject .



\"{{object.company_id.name}}\"

Payroll

Hello ,


We send you the payroll with the subject .



\n" "

\n" " \n" " \n" @@ -60,34 +32,7 @@ msgstr "" " \n" " \n" " \n" -" \n" +"
\"{{object.company_id.name}}\"

Nómina

Hola ,


Te enviamos " -"la nómina del mes de .



\"{{object.company_id.name}}\"

Nómina

Hola ,


Te enviamos la nómina con el asunto .



\n" "

\n" " \n" " \n" @@ -96,8 +41,9 @@ msgstr "" #. module: hr_payroll_document #: model:ir.model,name:hr_payroll_document.model_ir_attachment #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment__payrol_rel +#: model:ir.model.fields,field_description:hr_payroll_document.field_product_document__payrol_rel msgid "Attachment" -msgstr "Adjunto" +msgstr "Archivo adjunto" #. module: hr_payroll_document #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom__attachment_id @@ -131,9 +77,21 @@ msgstr "Creado el" msgid "Display Name" msgstr "Nombre para mostrar" +#. module: hr_payroll_document +#: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment__document_type +#: model:ir.model.fields,field_description:hr_payroll_document.field_product_document__document_type +msgid "Document Type" +msgstr "Tipo de documento" + +#. module: hr_payroll_document +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_tree +msgid "Download" +msgstr "Descargar" + #. module: hr_payroll_document #: model:ir.model,name:hr_payroll_document.model_hr_employee #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom__employee +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_filter msgid "Employee" msgstr "Empleado" @@ -147,9 +105,15 @@ msgstr "Empleados no encontrados" #. module: hr_payroll_document #: model:ir.model.fields,help:hr_payroll_document.field_payroll_management_wizard__subject -msgid "Enter the title of the payroll whether it is the month, week, day, etc." +msgid "" +"Enter the title of the payroll whether it is the month, week, day, etc." msgstr "Introduzca el título de la nómina ya sea el mes, semana, día , etc.." +#. module: hr_payroll_document +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_filter +msgid "Group By" +msgstr "" + #. module: hr_payroll_document #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom__id #: model:ir.model.fields,field_description:hr_payroll_document.field_payroll_management_wizard__id @@ -166,15 +130,10 @@ msgstr "IDs de los empleados que no se han encontrado: " #. module: hr_payroll_document #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom__identification_id +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_filter msgid "Identification ID" msgstr "Identificación ID" -#. module: hr_payroll_document -#: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom____last_update -#: model:ir.model.fields,field_description:hr_payroll_document.field_payroll_management_wizard____last_update -msgid "Last Modified on" -msgstr "Última modificación el" - #. module: hr_payroll_document #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom__write_uid #: model:ir.model.fields,field_description:hr_payroll_document.field_payroll_management_wizard__write_uid @@ -197,6 +156,7 @@ msgstr "Los archivos tienen que ser de tipo pdf" #. module: hr_payroll_document #. odoo-python #: code:addons/hr_payroll_document/wizard/payroll_management_wizard.py:0 +#: model:ir.model.fields.selection,name:hr_payroll_document.selection__ir_attachment__document_type__payroll #, python-format msgid "Payroll" msgstr "Nómina" @@ -208,6 +168,11 @@ msgstr "Nómina" msgid "Payroll " msgstr "Nómina " +#. module: hr_payroll_document +#: model:ir.model.fields,field_description:hr_payroll_document.field_hr_employee__payroll_count +msgid "Payroll Count" +msgstr "Recuento de Nóminas" + #. module: hr_payroll_document #: model:mail.template,name:hr_payroll_document.payroll_employee_email_template msgid "Payroll Employee" @@ -226,10 +191,16 @@ msgstr "Adjunto Nómina" #. module: hr_payroll_document #: model:mail.template,subject:hr_payroll_document.payroll_employee_email_template msgid "Payroll {{ctx.get('subject')}}" -msgstr "Nómina {{ctx.get('month')}}" +msgstr "Nómina {{ctx.get('subject')}}" #. module: hr_payroll_document +#: model:ir.actions.act_window,name:hr_payroll_document.payrolls_view_action #: model:ir.model.fields,field_description:hr_payroll_document.field_payroll_management_wizard__payrolls +#: model:ir.ui.menu,name:hr_payroll_document.payrolls_menu_action +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.hr_employee_view_tree_payroll +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.res_users_view_form_profile_inherit +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_filter +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_tree msgid "Payrolls" msgstr "Nóminas" @@ -263,6 +234,7 @@ msgstr "Enviar" #. module: hr_payroll_document #: model:ir.model.fields,field_description:hr_payroll_document.field_ir_attachment_payroll_custom__subject #: model:ir.model.fields,field_description:hr_payroll_document.field_payroll_management_wizard__subject +#: model_terms:ir.ui.view,arch_db:hr_payroll_document.view_payroll_filter msgid "Subject" msgstr "Asunto" @@ -273,6 +245,11 @@ msgstr "Asunto" msgid "The field identification ID is not valid" msgstr "El campo identificativo ID no es válido" +#. module: hr_payroll_document +#: model:ir.model,name:hr_payroll_document.model_res_users +msgid "User" +msgstr "Usuario" + #. module: hr_payroll_document #. odoo-python #: code:addons/hr_payroll_document/wizard/payroll_management_wizard.py:0 diff --git a/hr_payroll_document/models/__init__.py b/hr_payroll_document/models/__init__.py index 9fa86bfb..b4048b8c 100644 --- a/hr_payroll_document/models/__init__.py +++ b/hr_payroll_document/models/__init__.py @@ -1,3 +1,4 @@ from . import ir_attachment_payroll_custom from . import ir_attachment from . import hr_employee +from . import res_users diff --git a/hr_payroll_document/models/hr_employee.py b/hr_payroll_document/models/hr_employee.py index 8d9e3889..74c9cdc6 100644 --- a/hr_payroll_document/models/hr_employee.py +++ b/hr_payroll_document/models/hr_employee.py @@ -1,10 +1,40 @@ -from odoo import _, models +from odoo import _, fields, models from odoo.exceptions import ValidationError class Employee(models.Model): _inherit = "hr.employee" + payroll_count = fields.Integer( + compute="_compute_payroll_count", + ) + + def _compute_payroll_count(self): + self.payroll_count = len( + self.env["ir.attachment"].search( + [ + ("document_type", "=", "payroll"), + ("res_model", "=", self._name), + ("res_id", "in", self.ids), + ] + ) + ) + + def action_get_payroll_tree_view(self): + action = self.env.ref("base.action_attachment").sudo().read()[0] + action["context"] = { + "default_res_model": self._name, + "default_res_id": self.ids[0], + } + action["domain"] = str( + [ + ("document_type", "=", "payroll"), + ("res_model", "=", self._name), + ("res_id", "in", self.ids), + ] + ) + return action + def write(self, vals): res = super().write(vals) if "identification_id" in vals and not self.env["res.partner"].simple_vat_check( diff --git a/hr_payroll_document/models/ir_attachment.py b/hr_payroll_document/models/ir_attachment.py index c5bac752..d5173677 100644 --- a/hr_payroll_document/models/ir_attachment.py +++ b/hr_payroll_document/models/ir_attachment.py @@ -10,5 +10,5 @@ class Attachment(models.Model): "attachment_id3", "document_id", string="Attachment", - invisible=1, ) + document_type = fields.Selection([("payroll", "Payroll")]) diff --git a/hr_payroll_document/models/ir_attachment_payroll_custom.py b/hr_payroll_document/models/ir_attachment_payroll_custom.py index 96c20004..1a75d7b3 100644 --- a/hr_payroll_document/models/ir_attachment_payroll_custom.py +++ b/hr_payroll_document/models/ir_attachment_payroll_custom.py @@ -9,10 +9,15 @@ class IRAttachmentPayrollCustom(models.Model): comodel_name="ir.attachment", string="Attachment File", prefetch=False, - invisible=True, ondelete="cascade", ) employee = fields.Char() identification_id = fields.Char("Identification ID") create_date = fields.Date(default=fields.Date.context_today) subject = fields.Char() + + def download(self): + return { + "type": "ir.actions.act_url", + "url": "web/content/" + str(self.attachment_id.id) + "/?download=True", + } diff --git a/hr_payroll_document/models/res_users.py b/hr_payroll_document/models/res_users.py new file mode 100644 index 00000000..f85626c4 --- /dev/null +++ b/hr_payroll_document/models/res_users.py @@ -0,0 +1,20 @@ +from odoo import models + + +class ResUsers(models.Model): + _inherit = "res.users" + + def action_get_attachment_tree_view(self): + action = self.env.ref("base.action_attachment").sudo().read()[0] + action["context"] = { + "default_res_model": self._name, + "default_res_id": self.employee_id.id, + } + action["domain"] = str( + [ + ("document_type", "=", "payroll"), + ("res_model", "=", self.employee_id._name), + ("res_id", "in", [self.employee_id.id]), + ] + ) + return action diff --git a/hr_payroll_document/readme/CONTRIBUTORS.md b/hr_payroll_document/readme/CONTRIBUTORS.md index 619e6b25..4098d204 100644 --- a/hr_payroll_document/readme/CONTRIBUTORS.md +++ b/hr_payroll_document/readme/CONTRIBUTORS.md @@ -1,2 +1,3 @@ -- Antoni Marroig Campomar \<\> -- Miquel Alzanillas Monserrat \<\> +- [APSL-Nagarro](https://www.apsl.tech): + - Antoni Marroig \<\> + - Miquel Alzanillas \<\> diff --git a/hr_payroll_document/readme/DESCRIPTION.md b/hr_payroll_document/readme/DESCRIPTION.md index fb12e7d4..a4011cb5 100644 --- a/hr_payroll_document/readme/DESCRIPTION.md +++ b/hr_payroll_document/readme/DESCRIPTION.md @@ -1,2 +1 @@ -This module have a wizard view to manage the different payrolls of -employees which is identified by the identification_id attribute. +This module have a wizard view to manage the different payrolls of employees which is identified by the identification_id attribute. diff --git a/hr_payroll_document/static/description/index.html b/hr_payroll_document/static/description/index.html index 42b68336..b8f972c4 100644 --- a/hr_payroll_document/static/description/index.html +++ b/hr_payroll_document/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -402,14 +403,19 @@

Authors

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/hr_payroll_document/tests/common.py b/hr_payroll_document/tests/common.py deleted file mode 100644 index f9cab755..00000000 --- a/hr_payroll_document/tests/common.py +++ /dev/null @@ -1,51 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. -import base64 - -from odoo.modules.module import get_module_resource -from odoo.tests import common - -from odoo.addons.mail.tests.common import mail_new_test_user - - -class TestHrPayrollDocument(common.TransactionCase): - def setUp(self): - super().setUp() - self.env.user.tz = "Europe/Brussels" - self.user_admin = self.env.ref("base.user_admin") - - # Fix Company without country - self.env.company.country_id = False - - # Test users to use through the various tests - self.user_employee = mail_new_test_user( - self.env, login="david", groups="base.group_user" - ) - self.user_employee_id = self.user_employee.id - - # Hr Data - self.employee_emp = self.env["hr.employee"].create( - { - "name": "David Employee", - "user_id": self.user_employee_id, - "company_id": 1, - "identification_id": "30831011V", - } - ) - - with open( - get_module_resource("hr_payroll_document", "tests", "test.pdf"), "rb" - ) as pdf_file: - encoded_string = base64.b64encode(pdf_file.read()) - ir_values = { - "name": "test", - "type": "binary", - "datas": encoded_string, - "store_fname": encoded_string, - "res_model": "payroll.management.wizard", - "res_id": 1, - } - self.attachment = self.env["ir.attachment"].create(ir_values) - self.subject = "January" - self.wizard = self.env["payroll.management.wizard"].create( - {"payrolls": [self.attachment.id], "subject": self.subject} - ) diff --git a/hr_payroll_document/tests/test_hr_payroll_document.py b/hr_payroll_document/tests/test_hr_payroll_document.py index 1259a74a..0d92c00d 100644 --- a/hr_payroll_document/tests/test_hr_payroll_document.py +++ b/hr_payroll_document/tests/test_hr_payroll_document.py @@ -2,14 +2,53 @@ from odoo import _ from odoo.exceptions import UserError, ValidationError -from odoo.modules.module import get_module_resource +from odoo.tests import common +from odoo.tools.misc import file_path -from odoo.addons.hr_payroll_document.tests.common import TestHrPayrollDocument +from odoo.addons.mail.tests.common import mail_new_test_user -class TestHRPayrollDocument(TestHrPayrollDocument): - def setUp(self, *args, **kwargs): - super().setUp(*args, **kwargs) +class TestHRPayrollDocument(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env.user.tz = "Europe/Brussels" + cls.user_admin = cls.env.ref("base.user_admin") + + # Fix Company without country + cls.env.company.country_id = False + + # Test users to use through the various tests + cls.user_employee = mail_new_test_user( + cls.env, login="david", groups="base.group_user" + ) + cls.user_employee_id = cls.user_employee.id + + # Hr Data + cls.employee_emp = cls.env["hr.employee"].create( + { + "name": "David Employee", + "user_id": cls.user_employee_id, + "company_id": 1, + "identification_id": "30831011V", + } + ) + + with open(file_path("hr_payroll_document/tests/test.pdf"), "rb") as pdf_file: + encoded_string = base64.b64encode(pdf_file.read()) + ir_values = { + "name": "test", + "type": "binary", + "datas": encoded_string, + "store_fname": encoded_string, + "res_model": "payroll.management.wizard", + "res_id": 1, + } + cls.attachment = cls.env["ir.attachment"].create(ir_values) + cls.subject = "January" + cls.wizard = cls.env["payroll.management.wizard"].create( + {"payrolls": [cls.attachment.id], "subject": cls.subject} + ) def fill_company_id(self): self.env.company.country_id = self.env["res.country"].search( @@ -17,9 +56,7 @@ def fill_company_id(self): ) def test_extension_error(self): - with open( - get_module_resource("hr_payroll_document", "tests", "test.docx"), "rb" - ) as pdf_file: + with open(file_path("hr_payroll_document/tests/test.docx"), "rb") as pdf_file: encoded_string = base64.b64encode(pdf_file.read()) ir_values = { "name": "test", @@ -53,55 +90,20 @@ def test_one_employee_not_found(self): self.fill_company_id() self.env["hr.employee"].search([("id", "=", 1)]).identification_id = "37936636E" self.assertEqual( - self.wizard.send_payrolls(), - { - "type": "ir.actions.client", - "tag": "display_notification", - "params": { - "title": _("Employees not found"), - "message": _("IDs whose employee has not been found: ") - + "51000278D", - "sticky": True, - "type": "warning", - "next": { - "name": _("Payrolls sent"), - "type": "ir.actions.act_window", - "res_model": "hr.employee", - "views": [ - ( - self.env.ref("hr.hr_employee_public_view_kanban").id, - "list", - ) - ], - }, - }, - }, + self.wizard.send_payrolls()["params"]["title"], _("Employees not found") + ) + self.assertEqual( + self.wizard.send_payrolls()["params"]["message"], + _("IDs whose employee has not been found: ") + "51000278D", ) def test_send_payrolls_correctly(self): self.fill_company_id() self.env["hr.employee"].search([("id", "=", 1)]).identification_id = "51000278D" self.assertEqual( - self.wizard.send_payrolls(), - { - "type": "ir.actions.client", - "tag": "display_notification", - "params": { - "title": _("Payrolls sent"), - "message": _("Payrolls sent to employees correctly"), - "sticky": False, - "type": "success", - "next": { - "name": _("Payrolls sent"), - "type": "ir.actions.act_window", - "res_model": "hr.employee", - "views": [ - ( - self.env.ref("hr.hr_employee_public_view_kanban").id, - "list", - ) - ], - }, - }, - }, + self.wizard.send_payrolls()["params"]["title"], _("Payrolls sent") + ) + self.assertEqual( + self.wizard.send_payrolls()["params"]["message"], + _("Payrolls sent to employees correctly"), ) diff --git a/hr_payroll_document/views/hr_employee_views.xml b/hr_payroll_document/views/hr_employee_views.xml new file mode 100644 index 00000000..ee687b3c --- /dev/null +++ b/hr_payroll_document/views/hr_employee_views.xml @@ -0,0 +1,107 @@ + + + + payroll.view.tree + ir.attachment.payroll.custom + + + + + + + + + + + + + + hr.res_user.view.form.inherit.document + res.users + + +
+ +
+
+
+
diff --git a/hr_payroll_document/wizard/payroll_management_wizard.py b/hr_payroll_document/wizard/payroll_management_wizard.py index fcb7fd8e..585584fa 100644 --- a/hr_payroll_document/wizard/payroll_management_wizard.py +++ b/hr_payroll_document/wizard/payroll_management_wizard.py @@ -12,14 +12,11 @@ class PayrollManagamentWizard(models.TransientModel): _description = "Payroll Management" subject = fields.Char( - help="Enter the title of the payroll whether it is the month, week, day, etc." + help="Enter the title of the payroll whether it is the month, week, day, etc.", + required=True, ) payrolls = fields.Many2many( - "ir.attachment", - "payrol_rel", - "doc_id", - "attach_id3", - copy=False, + "ir.attachment", "payrol_rel", "doc_id", "attach_id3", copy=False, required=True ) def send_payrolls(self): @@ -43,7 +40,6 @@ def send_payrolls(self): employees.add(employee) else: not_found.add(value) - break for employee in list(employees): pdfWriter = PdfWriter() @@ -54,9 +50,8 @@ def send_payrolls(self): path = "/tmp/" + _("Payroll ") + employee.name + ".pdf" - """ - Encrypt the payroll file with the identification identifier of the employee - """ + # Encrypt the payroll file with the identification identifier + # of the employee pdfWriter.encrypt(employee.identification_id, algorithm="AES-256") f = open(path, "wb") @@ -66,6 +61,12 @@ def send_payrolls(self): # Send payroll to the employee self.send_mail(employee, path) + action = self.env["ir.actions.actions"]._for_xml_id( + "hr_payroll_document.payrolls_view_action" + ) + action["views"] = [ + [self.env.ref("hr_payroll_document.view_payroll_tree").id, "list"] + ] if not_found: return { "type": "ir.actions.client", @@ -76,17 +77,7 @@ def send_payrolls(self): + ", ".join(list(not_found)), "sticky": True, "type": "warning", - "next": { - "name": _("Payrolls sent"), - "type": "ir.actions.act_window", - "res_model": "hr.employee", - "views": [ - ( - self.env.ref("hr.hr_employee_public_view_kanban").id, - "list", - ) - ], - }, + "next": action, }, } @@ -98,14 +89,7 @@ def send_payrolls(self): "message": _("Payrolls sent to employees correctly"), "sticky": False, "type": "success", - "next": { - "name": _("Payrolls sent"), - "type": "ir.actions.act_window", - "res_model": "hr.employee", - "views": [ - (self.env.ref("hr.hr_employee_public_view_kanban").id, "list") - ], - }, + "next": action, }, } @@ -143,6 +127,7 @@ def send_mail(self, employee, path): "store_fname": encoded_string, "res_model": "hr.employee", "res_id": employee.id, + "document_type": "payroll", } # Save payroll attachment to all employee payrolls attachments diff --git a/hr_payroll_document/wizard/payroll_management_wizard.xml b/hr_payroll_document/wizard/payroll_management_wizard.xml index 7a21b7bf..6a42e383 100644 --- a/hr_payroll_document/wizard/payroll_management_wizard.xml +++ b/hr_payroll_document/wizard/payroll_management_wizard.xml @@ -7,7 +7,7 @@
- +