diff --git a/l10n_es_aeat_prorate_asset/README.rst b/l10n_es_aeat_prorate_asset/README.rst new file mode 100644 index 000000000..28ec957f5 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/README.rst @@ -0,0 +1,64 @@ +============= +Prorate Asset +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5c25a72d8e2dc152891aedd340e057909faddbde004d6ef957e252c1ea5cf730 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github + :target: https://github.com/NuoBiT/odoo-addons/tree/18.0/l10n_es_aeat_prorate_asset + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + + + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* NuoBiT Solutions SL + +Contributors +------------ + +- `NuoBiT `__: + + - Kilian Niubo kniubo@nuobit.com + - Eric Antones eantones@nuobit.com + - Deniz Gallo dgallo@nuobit.com + +Maintainers +----------- + +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/l10n_es_aeat_prorate_asset/__init__.py b/l10n_es_aeat_prorate_asset/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_es_aeat_prorate_asset/__manifest__.py b/l10n_es_aeat_prorate_asset/__manifest__.py new file mode 100644 index 000000000..a81245c4d --- /dev/null +++ b/l10n_es_aeat_prorate_asset/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright NuoBiT Solutions SL - Kilian Niubo +# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Prorate Asset", + "summary": "This module add prorate fields on asset", + "version": "18.0.1.0.0", + "category": "Accounting", + "author": "NuoBiT Solutions SL", + "website": "https://github.com/NuoBiT/odoo-addons", + "license": "AGPL-3", + "depends": [ + "account_asset_management_extension", + "l10n_es_aeat_vat_special_prorrate", + "l10n_es_asset_extension", + ], + "data": ["views/account_asset.xml"], +} diff --git a/l10n_es_aeat_prorate_asset/i18n/es.po b/l10n_es_aeat_prorate_asset/i18n/es.po new file mode 100644 index 000000000..d5e5cf312 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/i18n/es.po @@ -0,0 +1,88 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_aeat_prorate_asset +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-09-29 12:06+0000\n" +"PO-Revision-Date: 2022-09-29 12:06+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model,name:l10n_es_aeat_prorate_asset.model_account_asset +msgid "Asset" +msgstr "Activo" + +#. module: l10n_es_aeat_prorate_asset +#: code:addons/l10n_es_aeat_prorate_asset/models/account_asset.py:0 +#, python-format +msgid "Asset has more than 1 Prorate tax. Please, review the invoice" +msgstr "El activo tiene mas de un impuesto de prorata. Por favor, revise la factura" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__display_name +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_move__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__final_deductible_tax_amount +msgid "Final Deductible VAT Amount" +msgstr "Cuota IVA deducible definitiva" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__final_non_deductible_tax_amount +msgid "Final Non-Deductible VAT Amount" +msgstr "Cuota IVA no deducible definitiva" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__final_prorate_percent +msgid "Final Prorate (%)" +msgstr "Prorrata definitiva (%)" + +#. module: l10n_es_aeat_prorate_asset +#: code:addons/l10n_es_aeat_prorate_asset/models/account_asset.py:0 +#, python-format +msgid "" +"It's not possible to modify the temporary or final prorate if already exists" +" value in this years. Temp: %s, Final: %s" +msgstr "No es posible modificar la prorrata temporal o definitiva si ya existe " +"prorrata definida para el año de adquisición del activo. Temp: %s, Definitiva %s" + +#. module: l10n_es_aeat_prorate_asset +#: model_terms:ir.ui.view,arch_db:l10n_es_aeat_prorate_asset.account_asset_view_form +msgid "Prorate" +msgstr "Prorrata" + +#. module: l10n_es_aeat_prorate_asset +#: code:addons/l10n_es_aeat_prorate_asset/models/account_move.py:0 +#, python-format +msgid "Prorate not found in company %s in the year %s" +msgstr "Prorrata no encontrada para la compañia %s en el año %s" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__prorate_tax_id +msgid "Prorate tax" +msgstr "Impuesto de prorata" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__temp_deductible_tax_amount +msgid "Temporal Deductible VAT Amount" +msgstr "Cuota IVA deducible provisional" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__temp_non_deductible_tax_amount +msgid "Temporal Non-Deductible VAT Amount" +msgstr "Cuota IVA no deducible provisional" + +#. module: l10n_es_aeat_prorate_asset +#: model:ir.model.fields,field_description:l10n_es_aeat_prorate_asset.field_account_asset__temp_prorate_percent +msgid "Temporary prorate (%)" +msgstr "Prorrata provisional (%)" diff --git a/l10n_es_aeat_prorate_asset/models/__init__.py b/l10n_es_aeat_prorate_asset/models/__init__.py new file mode 100644 index 000000000..02a692c62 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/models/__init__.py @@ -0,0 +1 @@ +from . import account_asset diff --git a/l10n_es_aeat_prorate_asset/models/account_asset.py b/l10n_es_aeat_prorate_asset/models/account_asset.py new file mode 100644 index 000000000..e122a7182 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/models/account_asset.py @@ -0,0 +1,174 @@ +# Copyright NuoBiT Solutions SL - Kilian Niubo +# Copyright NuoBiT Solutions SL - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class AccountAsset(models.Model): + _inherit = "account.asset" + + map_special_prorate_year_id = fields.Many2one( + comodel_name="aeat.map.special.prorrate.year", + compute="_compute_map_special_prorate_year_id", + store=True, + ) + + @api.depends("date_start") + def _compute_map_special_prorate_year_id(self): + for rec in self: + if rec.date_start: + rec.map_special_prorate_year_id = rec.env[ + "aeat.map.special.prorrate.year" + ].get_by_ukey(rec.company_id.id, rec.date_start.year) + else: + rec.map_special_prorate_year_id = False + + def _compute_prorate_amounts(self, percent, is_deductible=True): + self.ensure_one() + ratio = percent / 100 + if not is_deductible: + ratio = 1 - ratio + return self.vat_tax_amount * ratio + + temp_deductible_tax_amount = fields.Float( + string="Temporal Deductible VAT Amount", + compute="_compute_temp_deductible_tax_amount", + store=True, + ) + + @api.depends("prorate_tax_id", "tax_base_amount", "temp_prorate_percent") + def _compute_temp_deductible_tax_amount(self): + for rec in self: + if rec.map_special_prorate_year_id: + rec.temp_deductible_tax_amount = rec._compute_prorate_amounts( + rec.map_special_prorate_year_id.tax_percentage + ) + + temp_non_deductible_tax_amount = fields.Float( + string="Temporal Non-Deductible VAT Amount", + compute="_compute_temp_non_deductible_tax_amount", + store=True, + ) + + @api.depends("prorate_tax_id", "tax_base_amount", "temp_prorate_percent") + def _compute_temp_non_deductible_tax_amount(self): + for rec in self: + if rec.map_special_prorate_year_id: + rec.temp_non_deductible_tax_amount = rec._compute_prorate_amounts( + rec.map_special_prorate_year_id.tax_percentage, is_deductible=False + ) + + final_deductible_tax_amount = fields.Float( + string="Final Deductible VAT Amount", + compute="_compute_final_deductible_tax_amount", + store=True, + ) + + @api.depends("prorate_tax_id", "tax_base_amount", "final_prorate_percent") + def _compute_final_deductible_tax_amount(self): + for rec in self: + if rec.map_special_prorate_year_id: + rec.final_deductible_tax_amount = rec._compute_prorate_amounts( + rec.map_special_prorate_year_id.tax_final_percentage + ) + + final_non_deductible_tax_amount = fields.Float( + string="Final Non-Deductible VAT Amount", + compute="_compute_final_non_deductible_tax_amount", + store=True, + ) + + @api.depends("prorate_tax_id", "tax_base_amount", "final_prorate_percent") + def _compute_final_non_deductible_tax_amount(self): + for rec in self: + if rec.map_special_prorate_year_id: + rec.final_non_deductible_tax_amount = rec._compute_prorate_amounts( + rec.map_special_prorate_year_id.tax_final_percentage, + is_deductible=False, + ) + + temp_prorate_percent = fields.Float( + string="Temporary prorate (%)", + compute="_compute_temp_prorate_percent", + store=True, + readonly=False, + ) + + @api.depends("map_special_prorate_year_id.tax_percentage") + def _compute_temp_prorate_percent(self): + for rec in self: + if rec.map_special_prorate_year_id: + if ( + rec.temp_prorate_percent + != rec.map_special_prorate_year_id.tax_percentage + ): + rec.temp_prorate_percent = ( + rec.map_special_prorate_year_id.tax_percentage + ) + + final_prorate_percent = fields.Float( + string="Final Prorate (%)", + compute="_compute_final_prorate_percent", + store=True, + readonly=False, + ) + + @api.depends("map_special_prorate_year_id.tax_final_percentage") + def _compute_final_prorate_percent(self): + for rec in self: + if rec.map_special_prorate_year_id: + if ( + rec.final_prorate_percent + != rec.map_special_prorate_year_id.tax_final_percentage + ): + rec.final_prorate_percent = ( + rec.map_special_prorate_year_id.tax_final_percentage + ) + + prorate_tax_id = fields.Many2one( + string="Prorate Tax", + comodel_name="account.tax", + compute="_compute_prorate_tax_id", + store=True, + ) + + @api.depends("vat_tax_id", "vat_tax_id.prorate") + def _compute_prorate_tax_id(self): + for rec in self: + taxes = rec.vat_tax_id.filtered(lambda x: x.prorate) + if len(taxes) > 1: + raise ValidationError( + _("Asset has more than 1 Prorate tax. Please, review the taxes") + ) + rec.prorate_tax_id = taxes._origin + + @api.constrains( + "temp_prorate_percent", + "final_prorate_percent", + ) + def _check_prorate_percent(self): + for rec in self: + if rec.prorate_tax_id and rec.date_start: + percentage_line = rec.env["aeat.map.special.prorrate.year"].get_by_ukey( + rec.company_id.id, rec.date_start.year + ) + if percentage_line and ( + percentage_line.tax_final_percentage != rec.final_prorate_percent + or percentage_line.tax_percentage != rec.temp_prorate_percent + ): + raise ValidationError( + _( + "It's not possible to modify the temporary or" + " final prorate if already exists value in " + "this years. " + "Temp: %(tax_percentage)s " + "Final: %(tax_final)s" + ) + % { + "tax_percentage": percentage_line.tax_percentage, + "tax_final": percentage_line.tax_final_percentage, + } + ) diff --git a/l10n_es_aeat_prorate_asset/pyproject.toml b/l10n_es_aeat_prorate_asset/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/l10n_es_aeat_prorate_asset/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_es_aeat_prorate_asset/readme/CONTRIBUTORS.md b/l10n_es_aeat_prorate_asset/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..0355cecbc --- /dev/null +++ b/l10n_es_aeat_prorate_asset/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [NuoBiT](https://www.nuobit.com): + - Kilian Niubo + - Eric Antones + - Deniz Gallo diff --git a/l10n_es_aeat_prorate_asset/readme/DESCRIPTION.md b/l10n_es_aeat_prorate_asset/readme/DESCRIPTION.md new file mode 100644 index 000000000..e69de29bb diff --git a/l10n_es_aeat_prorate_asset/static/description/icon.png b/l10n_es_aeat_prorate_asset/static/description/icon.png new file mode 100644 index 000000000..1cd641e79 Binary files /dev/null and b/l10n_es_aeat_prorate_asset/static/description/icon.png differ diff --git a/l10n_es_aeat_prorate_asset/static/description/index.html b/l10n_es_aeat_prorate_asset/static/description/index.html new file mode 100644 index 000000000..1e4fc7986 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/static/description/index.html @@ -0,0 +1,420 @@ + + + + + +Prorate Asset + + + +
+

Prorate Asset

+ + +

Beta License: AGPL-3 NuoBiT/odoo-addons

+

Table of contents

+ +
+

Bug Tracker

+

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 +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • NuoBiT Solutions SL
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/l10n_es_aeat_prorate_asset/views/account_asset.xml b/l10n_es_aeat_prorate_asset/views/account_asset.xml new file mode 100644 index 000000000..f9e906392 --- /dev/null +++ b/l10n_es_aeat_prorate_asset/views/account_asset.xml @@ -0,0 +1,64 @@ + + + + + account.asset + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..4e6969f45 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +odoo-addon-l10n_es_extension@git+https://github.com/nuobit/odoo-addons.git@refs/pull/769/head#subdirectory=l10n_es_extension +odoo-addon-account_asset_management_extension@git+https://github.com/nuobit/odoo-addons.git@refs/pull/754/head#subdirectory=account_asset_management_extension +odoo-addon-l10n_es_asset_extension@git+https://github.com/nuobit/odoo-addons.git@refs/pull/780/head#subdirectory=l10n_es_asset_extension +odoo-addon-l10n_es_special_prorate@git+https://github.com/nuobit/odoo-addons.git@refs/pull/800/head#subdirectory=l10n_es_special_prorate +odoo-addon-l10n_es_aeat_vat_special_prorrate@git+https://github.com/nuobit/odoo-addons.git@refs/pull/835/head#subdirectory=l10n_es_aeat_vat_special_prorrate