Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -442,6 +437,5 @@ diff --git a/hr_payroll_document/README.rst b/hr_payroll_document/README.rst index f07323c9a..794ad66fc 100644 --- a/hr_payroll_document/README.rst +++ b/hr_payroll_document/README.rst @@ -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 ===================== @@ -17,7 +13,7 @@ HR - Payroll Document .. |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 diff --git a/hr_payroll_document/__manifest__.py b/hr_payroll_document/__manifest__.py index 0d0d87da7..4310ae11c 100644 --- a/hr_payroll_document/__manifest__.py +++ b/hr_payroll_document/__manifest__.py @@ -8,7 +8,11 @@ "version": "17.0.1.1.2", "depends": ["hr", "base_vat"], "maintainers": ["peluko00"], - "external_dependencies": {"python": ["pypdf"]}, + "external_dependencies": { + "python": [ + "pypdf", + ], + }, "data": [ "wizard/payroll_management_wizard.xml", "security/ir.model.access.csv", diff --git a/hr_payroll_document/models/hr_employee.py b/hr_payroll_document/models/hr_employee.py index 1609f8f4e..545d19c6d 100644 --- a/hr_payroll_document/models/hr_employee.py +++ b/hr_payroll_document/models/hr_employee.py @@ -1,4 +1,7 @@ -from odoo import _, fields, models +# Copyright 2025 Simone Rubino - PyTech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models from odoo.exceptions import ValidationError @@ -44,10 +47,19 @@ def action_get_payroll_tree_view(self): ) return action - def write(self, vals): - res = super().write(vals) - if "identification_id" in vals and not self.env["res.partner"].simple_vat_check( - self.env.company.country_id.code, vals["identification_id"] - ): - raise ValidationError(_("The field identification ID is not valid")) - return res + def _validate_payroll_identification(self, code=None): + # Override if the identification should be validated in another way + if code is None and len(self) == 1: + code = self.identification_id + if country_code := self.env.company.country_id.code: + is_valid = self.env["res.partner"].simple_vat_check(country_code, code) + else: + is_valid = True + return is_valid + + @api.constrains("identification_id") + def _constrain_payroll_identification(self): + # Only check the employees that have an `identification_id` + for employee in self.filtered("identification_id"): + if not employee._validate_payroll_identification(): + raise ValidationError(_("The field identification ID is not valid")) diff --git a/hr_payroll_document/static/description/index.html b/hr_payroll_document/static/description/index.html index baa080cea..16495fcaf 100644 --- a/hr_payroll_document/static/description/index.html +++ b/hr_payroll_document/static/description/index.html @@ -3,7 +3,7 @@
-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 @@ -393,7 +388,7 @@
Bugs are tracked on GitHub Issues. 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 @@ -401,15 +396,15 @@
Do not contact contributors directly about support or help with technical issues.