From 15216a42393ff080dc65a05bad0f6b083869d8ac Mon Sep 17 00:00:00 2001 From: KNVx Date: Tue, 27 Sep 2022 09:45:32 +0200 Subject: [PATCH 01/13] [ADD] l10n_es_account_capital_asset: New Module --- l10n_es_account_capital_asset/README.rst | 28 +++ l10n_es_account_capital_asset/__init__.py | 1 + l10n_es_account_capital_asset/__manifest__.py | 27 +++ .../data/account_capital_asset_type_data.xml | 19 ++ .../data/ir_config_parameter.xml | 11 + l10n_es_account_capital_asset/i18n/es.po | 191 ++++++++++++++++++ .../models/__init__.py | 15 ++ .../models/account_asset.py | 78 +++++++ .../models/account_asset_profile.py | 16 ++ .../models/account_capital_asset_map_tax.py | 50 +++++ .../models/account_capital_asset_type.py | 38 ++++ .../models/account_move.py | 20 ++ .../models/account_move_line.py | 53 +++++ .../models/account_tax.py | 35 ++++ .../models/res_company.py | 12 ++ .../models/res_config_settings.py | 14 ++ .../security/ir.model.access.csv | 5 + .../static/description/icon.png | Bin 0 -> 6342 bytes .../views/account_asset.xml | 20 ++ .../views/account_asset_profile_views.xml | 22 ++ .../account_capital_asset_map_tax_views.xml | 26 +++ .../views/account_capital_asset_type_view.xml | 56 +++++ .../views/res_company_view.xml | 22 ++ .../views/res_config_settings_views.xml | 30 +++ 24 files changed, 789 insertions(+) create mode 100644 l10n_es_account_capital_asset/README.rst create mode 100644 l10n_es_account_capital_asset/__init__.py create mode 100644 l10n_es_account_capital_asset/__manifest__.py create mode 100644 l10n_es_account_capital_asset/data/account_capital_asset_type_data.xml create mode 100644 l10n_es_account_capital_asset/data/ir_config_parameter.xml create mode 100644 l10n_es_account_capital_asset/i18n/es.po create mode 100644 l10n_es_account_capital_asset/models/__init__.py create mode 100644 l10n_es_account_capital_asset/models/account_asset.py create mode 100644 l10n_es_account_capital_asset/models/account_asset_profile.py create mode 100644 l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py create mode 100644 l10n_es_account_capital_asset/models/account_capital_asset_type.py create mode 100644 l10n_es_account_capital_asset/models/account_move.py create mode 100644 l10n_es_account_capital_asset/models/account_move_line.py create mode 100644 l10n_es_account_capital_asset/models/account_tax.py create mode 100644 l10n_es_account_capital_asset/models/res_company.py create mode 100644 l10n_es_account_capital_asset/models/res_config_settings.py create mode 100644 l10n_es_account_capital_asset/security/ir.model.access.csv create mode 100644 l10n_es_account_capital_asset/static/description/icon.png create mode 100644 l10n_es_account_capital_asset/views/account_asset.xml create mode 100644 l10n_es_account_capital_asset/views/account_asset_profile_views.xml create mode 100644 l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml create mode 100644 l10n_es_account_capital_asset/views/account_capital_asset_type_view.xml create mode 100644 l10n_es_account_capital_asset/views/res_company_view.xml create mode 100644 l10n_es_account_capital_asset/views/res_config_settings_views.xml diff --git a/l10n_es_account_capital_asset/README.rst b/l10n_es_account_capital_asset/README.rst new file mode 100644 index 000000000..a3740e5c7 --- /dev/null +++ b/l10n_es_account_capital_asset/README.rst @@ -0,0 +1,28 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +===================== +Account Capital Asset +===================== + +* This module adds mapping for capital assets taxes, capital assets category + types and threshold amount on res_config. + +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 smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Kilian Niubo +* Eric Antones + diff --git a/l10n_es_account_capital_asset/__init__.py b/l10n_es_account_capital_asset/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_es_account_capital_asset/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py new file mode 100644 index 000000000..6b4b7c743 --- /dev/null +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -0,0 +1,27 @@ +# Copyright NuoBiT - Kilian Niubo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Account Capital Asset", + "summary": "This module adds mapping for capital assets taxes, capital assets" + " category types and threshold amount on res_config", + "version": "14.0.1.0.0", + "category": "Accounting", + "author": "NuoBiT Solutions, S.L.", + "website": "https://github.com/nuobit/odoo-addons", + "license": "AGPL-3", + "depends": [ + "l10n_es_asset_extension", + ], + "data": [ + "security/ir.model.access.csv", + "data/account_capital_asset_type_data.xml", + "data/ir_config_parameter.xml", + "views/account_asset.xml", + "views/account_asset_profile_views.xml", + "views/account_capital_asset_map_tax_views.xml", + "views/account_capital_asset_type_view.xml", + "views/res_company_view.xml", + "views/res_config_settings_views.xml", + ], +} diff --git a/l10n_es_account_capital_asset/data/account_capital_asset_type_data.xml b/l10n_es_account_capital_asset/data/account_capital_asset_type_data.xml new file mode 100644 index 000000000..ce0675083 --- /dev/null +++ b/l10n_es_account_capital_asset/data/account_capital_asset_type_data.xml @@ -0,0 +1,19 @@ + + + + + Normal + 5 + + + Terrenos o Edificaciones + 10 + + diff --git a/l10n_es_account_capital_asset/data/ir_config_parameter.xml b/l10n_es_account_capital_asset/data/ir_config_parameter.xml new file mode 100644 index 000000000..53d54def8 --- /dev/null +++ b/l10n_es_account_capital_asset/data/ir_config_parameter.xml @@ -0,0 +1,11 @@ + + + + + l10n_es_account_capital_asset.capital_asset_threshold_amount + 3005.06 + + diff --git a/l10n_es_account_capital_asset/i18n/es.po b/l10n_es_account_capital_asset/i18n/es.po new file mode 100644 index 000000000..35ca0b222 --- /dev/null +++ b/l10n_es_account_capital_asset/i18n/es.po @@ -0,0 +1,191 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_account_capital_asset +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-09-29 15:59+0000\n" +"PO-Revision-Date: 2022-09-29 15:59+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_account_capital_asset +#: model:ir.actions.act_window,name:l10n_es_account_capital_asset.account_capital_asset_action +#: model:ir.ui.menu,name:l10n_es_account_capital_asset.account_tax_map_amount +msgid "Account Capital Asset Tax Map" +msgstr "Bienes de inversión - Mapeo de impuestos" + + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 +#, python-format +msgid "Asset have Capital Asset tax. Please, review the taxes" +msgstr "El activo tiene impuestos de bien de inversión. Por favor, revise los impuestos" + +#. module: l10n_es_account_capital_asset +#: model_terms:ir.ui.view,arch_db:l10n_es_account_capital_asset.view_company_aeat_form +msgid "Capital Asset" +msgstr "Bien de inversión" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_res_company__l10n_es_capital_asset_enabled +msgid "L10n ES - Capital Asset Enabled" +msgstr "L10n ES - Bienes de inversión activados" + +#. module: l10n_es_account_capital_asset +#: model:ir.actions.act_window,name:l10n_es_account_capital_asset.capital_asset_type_action +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__capital_asset_type_id +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_type_id +#: model:ir.ui.menu,name:l10n_es_account_capital_asset.aeat_vat_special_prorrate_capital_asset_type_menu +msgid "Capital Asset Type" +msgstr "Tipo de bien de inversión" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__profile_capital_asset_type_id +msgid "Capital Asset Profile Type" +msgstr "Tipo de bien de inversión de la categoria" + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 +#, python-format +msgid "Capital Asset don't have Capital Asset tax. Please, review the taxes" +msgstr "El bien de inversión no tiene impuestos de bien de inversión. Por favor, revise los impuestos" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.constraint,message:l10n_es_account_capital_asset.constraint_l10n_es_account_capital_asset_type_unique_name +msgid "Capital Asset Type name must be unique" +msgstr "El nombre del tipo de bien de inversión debe ser único" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.constraint,message:l10n_es_account_capital_asset.constraint_l10n_es_account_capital_asset_type_unique_name +msgid "Capital Asset Type period must be unique" +msgstr "El periodo del tipo de bien de inversión debe ser único" + +#. module: l10n_es_account_capital_asset +#: model_terms:ir.ui.view,arch_db:l10n_es_account_capital_asset.res_config_settings_view_form +msgid "Capital Assets" +msgstr "Bienes de inversión" + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 +#, python-format +msgid "" +"Capital asset type must be the same as the one defined in the asset " +"category." +msgstr "El tipo de bien de inversion debe ser el mismo que el definido en la categoria de activo" + +#. module: l10n_es_account_capital_asset +#: model:ir.model,name:l10n_es_account_capital_asset.model_res_company +msgid "Companies" +msgstr "Compañías" + +#. module: l10n_es_account_capital_asset +#: model:ir.model,name:l10n_es_account_capital_asset.model_res_config_settings +msgid "Config Settings" +msgstr "Opciones de configuración" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__create_uid +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__create_date +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__display_name +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__id +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__id +msgid "ID" +msgstr "ID" + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 +#, python-format +msgid "" +"If Tax Base Amount is greater than %s, capital asset type must be defined." +msgstr "Si el Importe de la Base Imponible es mayor que %s, el tipo de bien de inversión debe ser definido" + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 +#, python-format +msgid "" +"If Tax Base Amount is less than %s, this asset is not considered as a " +"capital asset so capital asset type mustn't be defined" +msgstr "Si el Importe de la Base Imponible es menor que %s, este activo no es considerado " + "como un bien de inversión, por lo que el tipo de bien de inversión no debería estar definido" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_move____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_move_line____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_res_company____last_update +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_res_config_settings____last_update +msgid "Last Modified on" +msgstr "Última modificación" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__write_uid +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__write_uid +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__write_date +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,help:l10n_es_account_capital_asset.field_res_config_settings__capital_asset_threshold_amount +msgid "Minimum amount to consider the asset as a capital asset" +msgstr "Mínimo importe para considerar el activo como bien de inversión" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__name +msgid "Name" +msgstr "Nombre" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_type__period +msgid "Period (years)" +msgstr "Periodo (años)" + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_capital_asset_type.py:0 +#, python-format +msgid "Period must be greater than 0." +msgstr "El periodo debe ser mayor que 0" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__tax_dest_id +msgid "Replacement Tax" +msgstr "Impuesto de reemplazo" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_l10n_es_account_capital_asset_map_tax__tax_src_id +msgid "Tax Source" +msgstr "Impuesto original" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_res_config_settings__capital_asset_threshold_amount +msgid "Threshold Amount" +msgstr "Umbral de importe" diff --git a/l10n_es_account_capital_asset/models/__init__.py b/l10n_es_account_capital_asset/models/__init__.py new file mode 100644 index 000000000..b7c306b76 --- /dev/null +++ b/l10n_es_account_capital_asset/models/__init__.py @@ -0,0 +1,15 @@ +from . import account_asset +from . import account_asset_profile +from . import account_capital_asset_map_tax +from . import account_move +from . import account_move_line +from . import account_capital_asset_type +from . import res_company +from . import res_config_settings +from . import account_tax + +# TODO: 30-11 +# probar despues: +# check_tax_base_amount +# check_amount_type +# get unit price --> get unit amount diff --git a/l10n_es_account_capital_asset/models/account_asset.py b/l10n_es_account_capital_asset/models/account_asset.py new file mode 100644 index 000000000..dbb858fa7 --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_asset.py @@ -0,0 +1,78 @@ +# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT - 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 + +from odoo.addons.account_asset_management.models.account_asset import READONLY_STATES + + +class AccountAsset(models.Model): + _inherit = "account.asset" + + profile_capital_asset_type_id = fields.Many2one( + string="Capital Asset Profile Type", + related="profile_id.capital_asset_type_id", + ) + capital_asset_type_id = fields.Many2one( + comodel_name="l10n.es.account.capital.asset.type", + ondelete="restrict", + states=READONLY_STATES, + domain="[('id', '=', profile_capital_asset_type_id)]", + ) + + @api.constrains("tax_base_amount_unit", "capital_asset_type_id", "company_id") + def _check_amount_type(self): + threshold_capital_asset_amount = float( + self.env["ir.config_parameter"].get_param( + "l10n_es_account_capital_asset.capital_asset_threshold_amount" + ) + ) + for rec in self: + if rec.company_id.l10n_es_capital_asset_enabled: + if ( + rec.tax_base_amount_unit >= threshold_capital_asset_amount + and not rec.capital_asset_type_id + ): + raise ValidationError( + _( + "If Tax Base Amount is greater than %s, " + "capital asset type must be defined." + ) + % threshold_capital_asset_amount + ) + if ( + rec.tax_base_amount_unit < threshold_capital_asset_amount + and rec.capital_asset_type_id + ): + raise ValidationError( + _( + "If Tax Base Amount is less than %s, this asset " + "is not considered as a " + "capital asset so capital asset type mustn't be defined" + ) + % threshold_capital_asset_amount + ) + + @api.constrains("tax_base_amount_unit", "tax_ids") + def _check_tax_base_amount(self): + if not self.mapped("tax_ids") and self.env.context.get( + "allow_empty_taxes", False + ): + return + for rec in self: + self.tax_ids.check_tax_base_amount(rec.tax_base_amount_unit) + + @api.constrains("profile_id", "capital_asset_type_id") + def _check_capital_asset_type_integrity(self): + if ( + self.capital_asset_type_id + and self.profile_id.capital_asset_type_id != self.capital_asset_type_id + ): + raise ValidationError( + _( + "Capital asset type must be the same as " + "the one defined in the asset category." + ) + ) diff --git a/l10n_es_account_capital_asset/models/account_asset_profile.py b/l10n_es_account_capital_asset/models/account_asset_profile.py new file mode 100644 index 000000000..bf248f170 --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_asset_profile.py @@ -0,0 +1,16 @@ +# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class AccountAssetProfile(models.Model): + _inherit = "account.asset.profile" + + capital_asset_type_id = fields.Many2one( + string="Capital Asset Type", + comodel_name="l10n.es.account.capital.asset.type", + ondelete="restrict", + required=True, + ) diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py new file mode 100644 index 000000000..4cd8e5ecb --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py @@ -0,0 +1,50 @@ +# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import api, fields, models + + +class AccountCapitalAssetMapTax(models.Model): + _name = "l10n.es.account.capital.asset.map.tax" + + tax_src_id = fields.Many2one( + "account.tax.template", string="Tax Source", required=True + ) + tax_dest_id = fields.Many2one( + "account.tax.template", string="Replacement Tax", required=True + ) + + # TODO: Refactor to do this function more efficient or do it with ormcache + # @ormcache("tax_template", "company","tax_src_id","tax_dest_id") + def _get_taxes_mapping_from_tax_templates(self, company): + return { + company.get_taxes_from_templates( + x.tax_src_id + ): company.get_taxes_from_templates(x.tax_dest_id) + for x in self.search([]) + } + + @api.model + def map_tax(self, taxes, company, amount, quantity): + if any( + [ + not taxes, + not company, + not company.l10n_es_capital_asset_enabled, + not amount, + not quantity, + ] + ): + return taxes + threshold_capital_asset_amount = self.env["ir.config_parameter"].get_param( + "l10n_es_account_capital_asset.capital_asset_threshold_amount" + ) + asset_price = self.env["account.asset"]._get_asset_unit_price(amount, quantity) + result = taxes + if asset_price >= float(threshold_capital_asset_amount): + tax_map = self._get_taxes_mapping_from_tax_templates(company) + result = self.env["account.tax"] + for tax in taxes: + result |= tax_map[tax._origin] if tax._origin in tax_map else tax + return result diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_type.py b/l10n_es_account_capital_asset/models/account_capital_asset_type.py new file mode 100644 index 000000000..fdfe6a5ac --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_capital_asset_type.py @@ -0,0 +1,38 @@ +# Copyright NuoBiT - 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 CapitalAssetType(models.Model): + _name = "l10n.es.account.capital.asset.type" + + name = fields.Char(string="Name", required=True, translate=True) + period = fields.Integer(string="Period (years)", required=True) + + _sql_constraints = [ + ( + "unique_name", + "unique(name)", + "Capital Asset Type name must be unique", + ), + ( + "unique_period", + "unique(period)", + "Capital Asset Type period must be unique", + ), + ] + + def name_get(self): + return [(rec.id, "%s (%i years)" % (rec.name, rec.period)) for rec in self] + + @api.constrains("period") + def _check_period(self): + for rec in self: + if rec.period <= 0: + raise ValidationError(_("Period must be greater than 0.")) + + @api.model + def _get_max_period(self): + return max(self.search([]).mapped("period")) diff --git a/l10n_es_account_capital_asset/models/account_move.py b/l10n_es_account_capital_asset/models/account_move.py new file mode 100644 index 000000000..f32c8ea67 --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_move.py @@ -0,0 +1,20 @@ +# Copyright NuoBiT - Kilian Niubo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _prepare_asset_vals(self, aml): + vals = super()._prepare_asset_vals(aml) + threshold_amount = float( + self.env["ir.config_parameter"].get_param( + "l10n_es_account_capital_asset.capital_asset_threshold_amount" + ) + ) + if aml.balance >= threshold_amount: + vals["capital_asset_type_id"] = aml.asset_profile_id.capital_asset_type_id + return vals diff --git a/l10n_es_account_capital_asset/models/account_move_line.py b/l10n_es_account_capital_asset/models/account_move_line.py new file mode 100644 index 000000000..fad6ed9fa --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_move_line.py @@ -0,0 +1,53 @@ +# Copyright NuoBiT - Kilian Niubo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + + +from odoo import api, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + @api.onchange("product_id") + def _onchange_product_id(self): + super()._onchange_product_id() + if self.tax_ids: + self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( + self.tax_ids, self.company_id, self.balance, self.quantity + ) + + @api.onchange("product_uom_id") + def _onchange_uom_id(self): + super()._onchange_uom_id() + if self.tax_ids: + self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( + self.tax_ids, self.company_id, self.balance, self.quantity + ) + + @api.onchange("account_id") + def _onchange_account_id(self): + super()._onchange_uom_id() + if self.tax_ids: + self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( + self.tax_ids, self.company_id, self.balance, self.quantity + ) + + @api.onchange("price_subtotal", "quantity") + def _onchange_subtotal_quantity_id(self): + taxes = self._get_computed_taxes() + if taxes and self.move_id.fiscal_position_id: + taxes = self.move_id.fiscal_position_id.map_tax( + taxes, partner=self.partner_id + ) + if taxes: + taxes = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( + taxes, self.company_id, self.balance, self.quantity + ) + self.tax_ids = taxes + + @api.onchange("tax_ids") + def _onchange_tax_ids(self): + if self.tax_ids: + self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( + self.tax_ids, self.company_id, self.balance, self.quantity + ) diff --git a/l10n_es_account_capital_asset/models/account_tax.py b/l10n_es_account_capital_asset/models/account_tax.py new file mode 100644 index 000000000..a30741361 --- /dev/null +++ b/l10n_es_account_capital_asset/models/account_tax.py @@ -0,0 +1,35 @@ +# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import _, models +from odoo.exceptions import ValidationError + + +class AccountTax(models.Model): + _inherit = "account.tax" + + def check_tax_base_amount(self, tax_base_amount): + threshold_amount = float( + self.env["ir.config_parameter"].get_param( + "l10n_es_account_capital_asset.capital_asset_threshold_amount" + ) + ) + bi_tax_templates = self.env["l10n.es.account.capital.asset.map.tax"].search([]) + for rec in self: + bi_dest_taxes = rec.company_id.get_taxes_from_templates( + bi_tax_templates.tax_dest_id + ) + taxes = rec.filtered(lambda x: x in bi_dest_taxes) + if rec.company_id.l10n_es_capital_asset_enabled: + if tax_base_amount >= threshold_amount and not taxes: + raise ValidationError( + _( + "Capital Asset don't have Capital Asset tax." + " Please, review the taxes." + ) + ) + if tax_base_amount < threshold_amount and taxes: + raise ValidationError( + _("Asset have Capital Asset tax. Please, review the taxes") + ) diff --git a/l10n_es_account_capital_asset/models/res_company.py b/l10n_es_account_capital_asset/models/res_company.py new file mode 100644 index 000000000..34c1c2caf --- /dev/null +++ b/l10n_es_account_capital_asset/models/res_company.py @@ -0,0 +1,12 @@ +# Copyright NuoBiT - Kilian Niubo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + l10n_es_capital_asset_enabled = fields.Boolean( + string="L10n ES Capital Asset Enabled" + ) diff --git a/l10n_es_account_capital_asset/models/res_config_settings.py b/l10n_es_account_capital_asset/models/res_config_settings.py new file mode 100644 index 000000000..b77cb6d15 --- /dev/null +++ b/l10n_es_account_capital_asset/models/res_config_settings.py @@ -0,0 +1,14 @@ +# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + capital_asset_threshold_amount = fields.Float( + string="Capital Asset Threshold Amount", + config_parameter="l10n_es_account_capital_asset.capital_asset_threshold_amount", + help="Minimum amount to consider the asset as a capital asset", + ) diff --git a/l10n_es_account_capital_asset/security/ir.model.access.csv b/l10n_es_account_capital_asset/security/ir.model.access.csv new file mode 100644 index 000000000..338efa391 --- /dev/null +++ b/l10n_es_account_capital_asset/security/ir.model.access.csv @@ -0,0 +1,5 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_l10n_es_account_capital_asset_type_user","Account capital asset type - Account User","model_l10n_es_account_capital_asset_type","account.group_account_invoice",1,0,0,0 +"access_l10n_es_account_capital_asset_type_manager","Account capital asset type - Account Manager","model_l10n_es_account_capital_asset_type","account.group_account_manager",1,1,1,1 +"access_l10n_es_account_capital_asset_map_tax_user","Account capital asset - Account User","model_l10n_es_account_capital_asset_map_tax","account.group_account_invoice",1,0,0,0 +"access_l10n_es_account_capital_asset_map_tax_manager","Account capital asset - Account Manager","model_l10n_es_account_capital_asset_map_tax","account.group_account_manager",1,1,1,1 diff --git a/l10n_es_account_capital_asset/static/description/icon.png b/l10n_es_account_capital_asset/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1cd641e792c30455187ca30940bc0f329ce8bbb0 GIT binary patch literal 6342 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 literal 0 HcmV?d00001 diff --git a/l10n_es_account_capital_asset/views/account_asset.xml b/l10n_es_account_capital_asset/views/account_asset.xml new file mode 100644 index 000000000..ae1636f43 --- /dev/null +++ b/l10n_es_account_capital_asset/views/account_asset.xml @@ -0,0 +1,20 @@ + + + + + account.asset + + +
+ + + + + + +
+
diff --git a/l10n_es_account_capital_asset/views/account_asset_profile_views.xml b/l10n_es_account_capital_asset/views/account_asset_profile_views.xml new file mode 100644 index 000000000..e7d752ab4 --- /dev/null +++ b/l10n_es_account_capital_asset/views/account_asset_profile_views.xml @@ -0,0 +1,22 @@ + + + + + account.asset.profile + + + + + + + + + diff --git a/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml b/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml new file mode 100644 index 000000000..6d87999dd --- /dev/null +++ b/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml @@ -0,0 +1,26 @@ + + + + + account.capital.asset.tree + l10n.es.account.capital.asset.map.tax + + + + + + + + + Account Capital Asset Tax Map + l10n.es.account.capital.asset.map.tax + tree + + + diff --git a/l10n_es_account_capital_asset/views/account_capital_asset_type_view.xml b/l10n_es_account_capital_asset/views/account_capital_asset_type_view.xml new file mode 100644 index 000000000..3fa677b44 --- /dev/null +++ b/l10n_es_account_capital_asset/views/account_capital_asset_type_view.xml @@ -0,0 +1,56 @@ + + + + + aeat.vat.special.prorrate.capital.asset.type.view.form + l10n.es.account.capital.asset.type + +
+ + + + + + + + +
+
+
+ + + aeat.vat.special.prorrate.capital.asset.type.view.tree + l10n.es.account.capital.asset.type + + + + + + + + + + Capital Asset Type + l10n.es.account.capital.asset.type + tree,form + + + +
diff --git a/l10n_es_account_capital_asset/views/res_company_view.xml b/l10n_es_account_capital_asset/views/res_company_view.xml new file mode 100644 index 000000000..6c4451f70 --- /dev/null +++ b/l10n_es_account_capital_asset/views/res_company_view.xml @@ -0,0 +1,22 @@ + + + + + res.company.aeat.form + res.company + + + + + + + + + + + + + + diff --git a/l10n_es_account_capital_asset/views/res_config_settings_views.xml b/l10n_es_account_capital_asset/views/res_config_settings_views.xml new file mode 100644 index 000000000..42f4c05ff --- /dev/null +++ b/l10n_es_account_capital_asset/views/res_config_settings_views.xml @@ -0,0 +1,30 @@ + + + + + res.config.settings + + +
+

Capital Assets

+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 6e31283236e24313036f0119f05a7fe3e49f375e Mon Sep 17 00:00:00 2001 From: KNVx Date: Thu, 12 Jan 2023 08:25:04 +0100 Subject: [PATCH 02/13] [FIX] l10n_es_account_capital_asset: readonly computed fields on constrains throws warnings --- l10n_es_account_capital_asset/__manifest__.py | 2 +- l10n_es_account_capital_asset/models/account_asset.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index 6b4b7c743..b00e81e1c 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.0", + "version": "14.0.1.0.1", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", "website": "https://github.com/nuobit/odoo-addons", diff --git a/l10n_es_account_capital_asset/models/account_asset.py b/l10n_es_account_capital_asset/models/account_asset.py index dbb858fa7..fc0e9c9e7 100644 --- a/l10n_es_account_capital_asset/models/account_asset.py +++ b/l10n_es_account_capital_asset/models/account_asset.py @@ -22,7 +22,7 @@ class AccountAsset(models.Model): domain="[('id', '=', profile_capital_asset_type_id)]", ) - @api.constrains("tax_base_amount_unit", "capital_asset_type_id", "company_id") + @api.constrains("capital_asset_type_id", "company_id") def _check_amount_type(self): threshold_capital_asset_amount = float( self.env["ir.config_parameter"].get_param( @@ -55,7 +55,7 @@ def _check_amount_type(self): % threshold_capital_asset_amount ) - @api.constrains("tax_base_amount_unit", "tax_ids") + @api.constrains("tax_ids") def _check_tax_base_amount(self): if not self.mapped("tax_ids") and self.env.context.get( "allow_empty_taxes", False From d331380cef624e65817816b390b27498297dbb48 Mon Sep 17 00:00:00 2001 From: KNVx Date: Thu, 12 Jan 2023 08:27:57 +0100 Subject: [PATCH 03/13] [FIX] l10n_es_account_capital_asset: _description on new models are not set --- l10n_es_account_capital_asset/__manifest__.py | 2 +- .../models/account_capital_asset_map_tax.py | 1 + .../models/account_capital_asset_type.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index b00e81e1c..5a4c96a7c 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.1", + "version": "14.0.1.0.2", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", "website": "https://github.com/nuobit/odoo-addons", diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py index 4cd8e5ecb..8fded501b 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py @@ -7,6 +7,7 @@ class AccountCapitalAssetMapTax(models.Model): _name = "l10n.es.account.capital.asset.map.tax" + _description = "Capital Asset Map Tax" tax_src_id = fields.Many2one( "account.tax.template", string="Tax Source", required=True diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_type.py b/l10n_es_account_capital_asset/models/account_capital_asset_type.py index fdfe6a5ac..3e6bd0159 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_type.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_type.py @@ -7,6 +7,7 @@ class CapitalAssetType(models.Model): _name = "l10n.es.account.capital.asset.type" + _description = "Capital Asset Type" name = fields.Char(string="Name", required=True, translate=True) period = fields.Integer(string="Period (years)", required=True) From 8a9c16340c430c6ce2408ec2ba41d714f8e414b0 Mon Sep 17 00:00:00 2001 From: KNVx Date: Thu, 12 Jan 2023 13:02:58 +0100 Subject: [PATCH 04/13] [FIX] l10n_es_account_capital_asset: Onchange error - get_param throws an error if user has no rights. --- l10n_es_account_capital_asset/__manifest__.py | 2 +- l10n_es_account_capital_asset/models/account_asset.py | 6 +++--- .../models/account_capital_asset_map_tax.py | 6 ++++-- l10n_es_account_capital_asset/models/account_move.py | 6 +++--- l10n_es_account_capital_asset/models/account_tax.py | 6 +++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index 5a4c96a7c..59a64d32e 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.2", + "version": "14.0.1.0.3", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", "website": "https://github.com/nuobit/odoo-addons", diff --git a/l10n_es_account_capital_asset/models/account_asset.py b/l10n_es_account_capital_asset/models/account_asset.py index fc0e9c9e7..5eb60a520 100644 --- a/l10n_es_account_capital_asset/models/account_asset.py +++ b/l10n_es_account_capital_asset/models/account_asset.py @@ -25,9 +25,9 @@ class AccountAsset(models.Model): @api.constrains("capital_asset_type_id", "company_id") def _check_amount_type(self): threshold_capital_asset_amount = float( - self.env["ir.config_parameter"].get_param( - "l10n_es_account_capital_asset.capital_asset_threshold_amount" - ) + self.env["ir.config_parameter"] + .sudo() + .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) for rec in self: if rec.company_id.l10n_es_capital_asset_enabled: diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py index 8fded501b..b0a6c6100 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py @@ -38,8 +38,10 @@ def map_tax(self, taxes, company, amount, quantity): ] ): return taxes - threshold_capital_asset_amount = self.env["ir.config_parameter"].get_param( - "l10n_es_account_capital_asset.capital_asset_threshold_amount" + threshold_capital_asset_amount = ( + self.env["ir.config_parameter"] + .sudo() + .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) asset_price = self.env["account.asset"]._get_asset_unit_price(amount, quantity) result = taxes diff --git a/l10n_es_account_capital_asset/models/account_move.py b/l10n_es_account_capital_asset/models/account_move.py index f32c8ea67..e5857387d 100644 --- a/l10n_es_account_capital_asset/models/account_move.py +++ b/l10n_es_account_capital_asset/models/account_move.py @@ -11,9 +11,9 @@ class AccountMove(models.Model): def _prepare_asset_vals(self, aml): vals = super()._prepare_asset_vals(aml) threshold_amount = float( - self.env["ir.config_parameter"].get_param( - "l10n_es_account_capital_asset.capital_asset_threshold_amount" - ) + self.env["ir.config_parameter"] + .sudo() + .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) if aml.balance >= threshold_amount: vals["capital_asset_type_id"] = aml.asset_profile_id.capital_asset_type_id diff --git a/l10n_es_account_capital_asset/models/account_tax.py b/l10n_es_account_capital_asset/models/account_tax.py index a30741361..a84b24ae6 100644 --- a/l10n_es_account_capital_asset/models/account_tax.py +++ b/l10n_es_account_capital_asset/models/account_tax.py @@ -11,9 +11,9 @@ class AccountTax(models.Model): def check_tax_base_amount(self, tax_base_amount): threshold_amount = float( - self.env["ir.config_parameter"].get_param( - "l10n_es_account_capital_asset.capital_asset_threshold_amount" - ) + self.env["ir.config_parameter"] + .sudo() + .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) bi_tax_templates = self.env["l10n.es.account.capital.asset.map.tax"].search([]) for rec in self: From ae0510fedd51368d8845b1e1ee837ce656384d27 Mon Sep 17 00:00:00 2001 From: KNVx Date: Wed, 18 Jan 2023 08:44:30 +0100 Subject: [PATCH 05/13] [FIX] l10n_es_account_capital_asset: capital asset type is set on assets with tax base amount unit < threshold --- l10n_es_account_capital_asset/__manifest__.py | 2 +- l10n_es_account_capital_asset/models/__init__.py | 6 ------ l10n_es_account_capital_asset/models/account_move.py | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index 59a64d32e..13f668382 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.3", + "version": "14.0.1.0.4", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", "website": "https://github.com/nuobit/odoo-addons", diff --git a/l10n_es_account_capital_asset/models/__init__.py b/l10n_es_account_capital_asset/models/__init__.py index b7c306b76..8b218f273 100644 --- a/l10n_es_account_capital_asset/models/__init__.py +++ b/l10n_es_account_capital_asset/models/__init__.py @@ -7,9 +7,3 @@ from . import res_company from . import res_config_settings from . import account_tax - -# TODO: 30-11 -# probar despues: -# check_tax_base_amount -# check_amount_type -# get unit price --> get unit amount diff --git a/l10n_es_account_capital_asset/models/account_move.py b/l10n_es_account_capital_asset/models/account_move.py index e5857387d..ff1143303 100644 --- a/l10n_es_account_capital_asset/models/account_move.py +++ b/l10n_es_account_capital_asset/models/account_move.py @@ -15,6 +15,6 @@ def _prepare_asset_vals(self, aml): .sudo() .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) - if aml.balance >= threshold_amount: + if aml.balance / aml.quantity >= threshold_amount: vals["capital_asset_type_id"] = aml.asset_profile_id.capital_asset_type_id return vals From 18926fe5291d70fa21c884e734e4b0e2da41b05d Mon Sep 17 00:00:00 2001 From: KNVx Date: Wed, 18 Jan 2023 15:25:53 +0100 Subject: [PATCH 06/13] [IMP] l10n_es_account_capital_asset: onchange asset profile on move lines and refactor of onchanges --- l10n_es_account_capital_asset/__manifest__.py | 2 +- .../models/account_capital_asset_map_tax.py | 3 +- .../models/account_move_line.py | 48 ++++++++++--------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index 13f668382..59f586025 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.4", + "version": "14.0.1.0.5", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", "website": "https://github.com/nuobit/odoo-addons", diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py index b0a6c6100..90458cc0b 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py @@ -27,12 +27,13 @@ def _get_taxes_mapping_from_tax_templates(self, company): } @api.model - def map_tax(self, taxes, company, amount, quantity): + def map_tax(self, taxes, company, asset_profile, amount, quantity): if any( [ not taxes, not company, not company.l10n_es_capital_asset_enabled, + not asset_profile, not amount, not quantity, ] diff --git a/l10n_es_account_capital_asset/models/account_move_line.py b/l10n_es_account_capital_asset/models/account_move_line.py index fad6ed9fa..83548cd24 100644 --- a/l10n_es_account_capital_asset/models/account_move_line.py +++ b/l10n_es_account_capital_asset/models/account_move_line.py @@ -11,43 +11,47 @@ class AccountMoveLine(models.Model): @api.onchange("product_id") def _onchange_product_id(self): super()._onchange_product_id() - if self.tax_ids: - self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( - self.tax_ids, self.company_id, self.balance, self.quantity - ) + self.compute_mapped_taxes() @api.onchange("product_uom_id") def _onchange_uom_id(self): super()._onchange_uom_id() - if self.tax_ids: - self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( - self.tax_ids, self.company_id, self.balance, self.quantity - ) + self.compute_mapped_taxes() @api.onchange("account_id") def _onchange_account_id(self): super()._onchange_uom_id() + self.compute_mapped_taxes() + + @api.onchange("tax_ids") + def _onchange_tax_ids(self): + self.compute_mapped_taxes() + + @api.onchange("asset_profile_id") + def _onchange_asset_profile_id(self): + super()._onchange_asset_profile_id() + self.compute_taxes_fiscal_position() + self.compute_mapped_taxes() + + @api.onchange("price_subtotal", "quantity") + def _onchange_subtotal_quantity_id(self): + self.compute_taxes_fiscal_position() + self.compute_mapped_taxes() + + def compute_mapped_taxes(self): if self.tax_ids: self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( - self.tax_ids, self.company_id, self.balance, self.quantity + self.tax_ids, + self.company_id, + self.asset_profile_id, + self.balance, + self.quantity, ) - @api.onchange("price_subtotal", "quantity") - def _onchange_subtotal_quantity_id(self): + def compute_taxes_fiscal_position(self): taxes = self._get_computed_taxes() if taxes and self.move_id.fiscal_position_id: taxes = self.move_id.fiscal_position_id.map_tax( taxes, partner=self.partner_id ) - if taxes: - taxes = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( - taxes, self.company_id, self.balance, self.quantity - ) self.tax_ids = taxes - - @api.onchange("tax_ids") - def _onchange_tax_ids(self): - if self.tax_ids: - self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( - self.tax_ids, self.company_id, self.balance, self.quantity - ) From 2c99e5f04fe0bf71d7019cb7fea2aeb714f7ca14 Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Wed, 22 Mar 2023 23:57:45 +0100 Subject: [PATCH 07/13] [FIX] l10n_es_account_capital_asset: Invoice taxes updated always when quantity or subtotal change --- l10n_es_account_capital_asset/__manifest__.py | 2 +- .../models/account_move_line.py | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index 59f586025..f110acbf6 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.5", + "version": "14.0.1.0.6", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", "website": "https://github.com/nuobit/odoo-addons", diff --git a/l10n_es_account_capital_asset/models/account_move_line.py b/l10n_es_account_capital_asset/models/account_move_line.py index 83548cd24..32bdc035f 100644 --- a/l10n_es_account_capital_asset/models/account_move_line.py +++ b/l10n_es_account_capital_asset/models/account_move_line.py @@ -1,4 +1,5 @@ # Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT - Eric Antones # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) @@ -30,12 +31,10 @@ def _onchange_tax_ids(self): @api.onchange("asset_profile_id") def _onchange_asset_profile_id(self): super()._onchange_asset_profile_id() - self.compute_taxes_fiscal_position() self.compute_mapped_taxes() @api.onchange("price_subtotal", "quantity") def _onchange_subtotal_quantity_id(self): - self.compute_taxes_fiscal_position() self.compute_mapped_taxes() def compute_mapped_taxes(self): @@ -47,11 +46,3 @@ def compute_mapped_taxes(self): self.balance, self.quantity, ) - - def compute_taxes_fiscal_position(self): - taxes = self._get_computed_taxes() - if taxes and self.move_id.fiscal_position_id: - taxes = self.move_id.fiscal_position_id.map_tax( - taxes, partner=self.partner_id - ) - self.tax_ids = taxes From 15390376c1f9da1367eb9a019edc991629202413 Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Fri, 29 Aug 2025 13:44:16 +0200 Subject: [PATCH 08/13] [FIX] l10n_es_account_capital_asset: duplicated translation key --- l10n_es_account_capital_asset/i18n/es.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_es_account_capital_asset/i18n/es.po b/l10n_es_account_capital_asset/i18n/es.po index 35ca0b222..280edf3f2 100644 --- a/l10n_es_account_capital_asset/i18n/es.po +++ b/l10n_es_account_capital_asset/i18n/es.po @@ -63,7 +63,7 @@ msgid "Capital Asset Type name must be unique" msgstr "El nombre del tipo de bien de inversión debe ser único" #. module: l10n_es_account_capital_asset -#: model:ir.model.constraint,message:l10n_es_account_capital_asset.constraint_l10n_es_account_capital_asset_type_unique_name +#: model:ir.model.constraint,message:l10n_es_account_capital_asset.constraint_l10n_es_account_capital_asset_type_unique_period msgid "Capital Asset Type period must be unique" msgstr "El periodo del tipo de bien de inversión debe ser único" From 76c0b3075e8fad941b825a59caa29d3ba04212fb Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Wed, 8 Oct 2025 19:12:07 +0200 Subject: [PATCH 09/13] [FIX] l10n_es_account_capital_asset: asset value computed with unit price instead of total price of the asset --- l10n_es_account_capital_asset/i18n/es.po | 6 +++--- .../models/account_asset.py | 9 +++++---- .../models/account_asset_profile.py | 3 ++- .../models/account_capital_asset_map_tax.py | 2 +- .../models/account_move.py | 19 ++++++++++++------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/l10n_es_account_capital_asset/i18n/es.po b/l10n_es_account_capital_asset/i18n/es.po index 280edf3f2..cbdb05dd5 100644 --- a/l10n_es_account_capital_asset/i18n/es.po +++ b/l10n_es_account_capital_asset/i18n/es.po @@ -41,15 +41,15 @@ msgstr "L10n ES - Bienes de inversión activados" #. module: l10n_es_account_capital_asset #: model:ir.actions.act_window,name:l10n_es_account_capital_asset.capital_asset_type_action #: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__capital_asset_type_id -#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_type_id #: model:ir.ui.menu,name:l10n_es_account_capital_asset.aeat_vat_special_prorrate_capital_asset_type_menu msgid "Capital Asset Type" msgstr "Tipo de bien de inversión" #. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_type_id #: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__profile_capital_asset_type_id -msgid "Capital Asset Profile Type" -msgstr "Tipo de bien de inversión de la categoria" +msgid "Default Capital Asset Type" +msgstr "Tipo de bien de inversión por defecto" #. module: l10n_es_account_capital_asset #: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 diff --git a/l10n_es_account_capital_asset/models/account_asset.py b/l10n_es_account_capital_asset/models/account_asset.py index 5eb60a520..a4ec14faf 100644 --- a/l10n_es_account_capital_asset/models/account_asset.py +++ b/l10n_es_account_capital_asset/models/account_asset.py @@ -11,8 +11,9 @@ class AccountAsset(models.Model): _inherit = "account.asset" + # TODO: rename to default_capital_asset_type_id profile_capital_asset_type_id = fields.Many2one( - string="Capital Asset Profile Type", + string="Default Capital Asset Type", related="profile_id.capital_asset_type_id", ) capital_asset_type_id = fields.Many2one( @@ -32,7 +33,7 @@ def _check_amount_type(self): for rec in self: if rec.company_id.l10n_es_capital_asset_enabled: if ( - rec.tax_base_amount_unit >= threshold_capital_asset_amount + rec.tax_base_amount >= threshold_capital_asset_amount and not rec.capital_asset_type_id ): raise ValidationError( @@ -43,7 +44,7 @@ def _check_amount_type(self): % threshold_capital_asset_amount ) if ( - rec.tax_base_amount_unit < threshold_capital_asset_amount + rec.tax_base_amount < threshold_capital_asset_amount and rec.capital_asset_type_id ): raise ValidationError( @@ -62,7 +63,7 @@ def _check_tax_base_amount(self): ): return for rec in self: - self.tax_ids.check_tax_base_amount(rec.tax_base_amount_unit) + self.tax_ids.check_tax_base_amount(rec.tax_base_amount) @api.constrains("profile_id", "capital_asset_type_id") def _check_capital_asset_type_integrity(self): diff --git a/l10n_es_account_capital_asset/models/account_asset_profile.py b/l10n_es_account_capital_asset/models/account_asset_profile.py index bf248f170..d2b2be950 100644 --- a/l10n_es_account_capital_asset/models/account_asset_profile.py +++ b/l10n_es_account_capital_asset/models/account_asset_profile.py @@ -8,8 +8,9 @@ class AccountAssetProfile(models.Model): _inherit = "account.asset.profile" + # TODO: rename to default_capital_asset_type_id capital_asset_type_id = fields.Many2one( - string="Capital Asset Type", + string="Default Capital Asset Type", comodel_name="l10n.es.account.capital.asset.type", ondelete="restrict", required=True, diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py index 90458cc0b..7d0822325 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py @@ -44,7 +44,7 @@ def map_tax(self, taxes, company, asset_profile, amount, quantity): .sudo() .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) - asset_price = self.env["account.asset"]._get_asset_unit_price(amount, quantity) + asset_price = amount result = taxes if asset_price >= float(threshold_capital_asset_amount): tax_map = self._get_taxes_mapping_from_tax_templates(company) diff --git a/l10n_es_account_capital_asset/models/account_move.py b/l10n_es_account_capital_asset/models/account_move.py index ff1143303..ea3116947 100644 --- a/l10n_es_account_capital_asset/models/account_move.py +++ b/l10n_es_account_capital_asset/models/account_move.py @@ -10,11 +10,16 @@ class AccountMove(models.Model): def _prepare_asset_vals(self, aml): vals = super()._prepare_asset_vals(aml) - threshold_amount = float( - self.env["ir.config_parameter"] - .sudo() - .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") - ) - if aml.balance / aml.quantity >= threshold_amount: - vals["capital_asset_type_id"] = aml.asset_profile_id.capital_asset_type_id + if aml.company_id.l10n_es_capital_asset_enabled: + threshold_amount = float( + self.env["ir.config_parameter"] + .sudo() + .get_param( + "l10n_es_account_capital_asset.capital_asset_threshold_amount" + ) + ) + if aml.balance >= threshold_amount: + vals[ + "capital_asset_type_id" + ] = aml.asset_profile_id.capital_asset_type_id return vals From 308ef33c926dba6eaaf2c76606efafe98b2275eb Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Sun, 14 Dec 2025 13:30:06 +0100 Subject: [PATCH 10/13] [FIX+IMP] l10n_es_account_capital_asset: allow having aggregated assets --- l10n_es_account_capital_asset/i18n/es.po | 50 +++++++++++++++---- .../models/account_asset.py | 2 +- .../models/account_asset_profile.py | 20 +++++++- .../models/account_tax.py | 36 ++++++++++--- .../views/account_asset_profile_views.xml | 4 +- 5 files changed, 94 insertions(+), 18 deletions(-) diff --git a/l10n_es_account_capital_asset/i18n/es.po b/l10n_es_account_capital_asset/i18n/es.po index cbdb05dd5..eb3159b6e 100644 --- a/l10n_es_account_capital_asset/i18n/es.po +++ b/l10n_es_account_capital_asset/i18n/es.po @@ -21,13 +21,6 @@ msgstr "" msgid "Account Capital Asset Tax Map" msgstr "Bienes de inversión - Mapeo de impuestos" - -#. module: l10n_es_account_capital_asset -#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 -#, python-format -msgid "Asset have Capital Asset tax. Please, review the taxes" -msgstr "El activo tiene impuestos de bien de inversión. Por favor, revise los impuestos" - #. module: l10n_es_account_capital_asset #: model_terms:ir.ui.view,arch_db:l10n_es_account_capital_asset.view_company_aeat_form msgid "Capital Asset" @@ -45,6 +38,27 @@ msgstr "L10n ES - Bienes de inversión activados" msgid "Capital Asset Type" msgstr "Tipo de bien de inversión" +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_set +msgid "Capital Asset Set" +msgstr "Conjunto de bienes de inversión" + +#. module: l10n_es_account_capital_asset +#: model:ir.model.fields,help:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_set +msgid "Indicates that this profile is used for a set of capital assets." +msgstr "Indica que este perfil se utiliza para un conjunto de bienes de inversión." + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset_profile.py:0 +#, python-format +msgid "" +"A profile for a set of capital assets is not compatible with the 'Product " +"per Asset' option. You cannot have both enabled. Please, select only one of " +"them." +msgstr "Un perfil para un conjunto de bienes de inversión no es compatible " +"con la opción 'Producto por activo'. No puede tener ambos habilitados. " +"Por favor, seleccione solo uno de ellos." + #. module: l10n_es_account_capital_asset #: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_type_id #: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__profile_capital_asset_type_id @@ -54,8 +68,26 @@ msgstr "Tipo de bien de inversión por defecto" #. module: l10n_es_account_capital_asset #: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 #, python-format -msgid "Capital Asset don't have Capital Asset tax. Please, review the taxes" -msgstr "El bien de inversión no tiene impuestos de bien de inversión. Por favor, revise los impuestos" +msgid "The asset of type ‘%s’ has an unit amount %.2f€ greater than %.2f€, " +"so it is considered a capital asset, but the selected taxes " +"are not of a capital asset type. Please update the taxes " +"accordingly or define the asset type as a set of assets." +msgstr "El activo de tipo ‘%s’ tiene un importe unitario %.2f€ mayor que %.2f€, " +"por lo que se considera un bien de inversión, pero los impuestos seleccionados " +"no son de tipo bien de inversión. Por favor, actualice los impuestos " +"o defina el tipo de activo como un conjunto de activos." + +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_asset.py:0 +#, python-format +msgid "The asset of type ‘%s’ has a unit amount %.2f€ lower than %.2f€, " +"so it is not considered a capital asset, " +"but capital asset taxes are selected. Please update the taxes " +"accordingly or define the asset type as a set of assets." +msgstr "El activo de tipo ‘%s’ tiene un importe unitario %.2f€ menor que %.2f€, " +"por lo que no se considera un bien de inversión, " +"pero se han seleccionado impuestos de bienes de inversión. Por favor, actualice los impuestos " +"o defina el tipo de activo como un conjunto de activos." #. module: l10n_es_account_capital_asset #: model:ir.model.constraint,message:l10n_es_account_capital_asset.constraint_l10n_es_account_capital_asset_type_unique_name diff --git a/l10n_es_account_capital_asset/models/account_asset.py b/l10n_es_account_capital_asset/models/account_asset.py index a4ec14faf..57c9ddcd0 100644 --- a/l10n_es_account_capital_asset/models/account_asset.py +++ b/l10n_es_account_capital_asset/models/account_asset.py @@ -63,7 +63,7 @@ def _check_tax_base_amount(self): ): return for rec in self: - self.tax_ids.check_tax_base_amount(rec.tax_base_amount) + self.tax_ids.check_tax_base_amount(rec) @api.constrains("profile_id", "capital_asset_type_id") def _check_capital_asset_type_integrity(self): diff --git a/l10n_es_account_capital_asset/models/account_asset_profile.py b/l10n_es_account_capital_asset/models/account_asset_profile.py index d2b2be950..12e25632f 100644 --- a/l10n_es_account_capital_asset/models/account_asset_profile.py +++ b/l10n_es_account_capital_asset/models/account_asset_profile.py @@ -2,7 +2,8 @@ # Copyright NuoBiT - Eric Antones # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from odoo import fields, models +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError class AccountAssetProfile(models.Model): @@ -15,3 +16,20 @@ class AccountAssetProfile(models.Model): ondelete="restrict", required=True, ) + + capital_asset_set = fields.Boolean( + string="Capital asset set", + help="Indicates that this profile is used for a set of capital assets.", + ) + + @api.constrains("capital_asset_set", "asset_product_item") + def _check_capital_asset_set(self): + for rec in self: + if rec.capital_asset_set and rec.asset_product_item: + raise ValidationError( + _( + "A profile for a set of capital assets is not compatible with " + "the 'Product per Asset' option. You cannot have both enabled. " + "Please, select only one of them." + ) + ) diff --git a/l10n_es_account_capital_asset/models/account_tax.py b/l10n_es_account_capital_asset/models/account_tax.py index a84b24ae6..3044fdc9b 100644 --- a/l10n_es_account_capital_asset/models/account_tax.py +++ b/l10n_es_account_capital_asset/models/account_tax.py @@ -9,7 +9,7 @@ class AccountTax(models.Model): _inherit = "account.tax" - def check_tax_base_amount(self, tax_base_amount): + def check_tax_base_amount(self, asset): threshold_amount = float( self.env["ir.config_parameter"] .sudo() @@ -22,14 +22,38 @@ def check_tax_base_amount(self, tax_base_amount): ) taxes = rec.filtered(lambda x: x in bi_dest_taxes) if rec.company_id.l10n_es_capital_asset_enabled: - if tax_base_amount >= threshold_amount and not taxes: + if ( + not asset.profile_id.asset_product_item + and asset.profile_id.capital_asset_set + ): + tax_base_amount_unit = asset.tax_base_amount_unit + else: + tax_base_amount_unit = asset.tax_base_amount + if tax_base_amount_unit >= threshold_amount and not taxes: raise ValidationError( _( - "Capital Asset don't have Capital Asset tax." - " Please, review the taxes." + "The asset of type ‘%s’ has an unit amount %.2f€ greater than " + "%.2f€, so it is considered a capital asset, but the selected " + "taxes are not of a capital asset type. Please update the taxes " + "accordingly or define the asset type as a set of assets." + ) + % ( + asset.profile_id.name, + tax_base_amount_unit, + threshold_amount, ) ) - if tax_base_amount < threshold_amount and taxes: + elif tax_base_amount_unit < threshold_amount and taxes: raise ValidationError( - _("Asset have Capital Asset tax. Please, review the taxes") + _( + "The asset of type ‘%s’ has a unit amount %.2f€ lower than %.2f€, " + "so it is not considered a capital asset, " + "but capital asset taxes are selected. Please update the taxes " + "accordingly or define the asset type as a set of assets." + ) + % ( + asset.profile_id.name, + tax_base_amount_unit, + threshold_amount, + ) ) diff --git a/l10n_es_account_capital_asset/views/account_asset_profile_views.xml b/l10n_es_account_capital_asset/views/account_asset_profile_views.xml index e7d752ab4..521922c8e 100644 --- a/l10n_es_account_capital_asset/views/account_asset_profile_views.xml +++ b/l10n_es_account_capital_asset/views/account_asset_profile_views.xml @@ -9,8 +9,10 @@ ref="account_asset_management.account_asset_profile_view_form" /> + + + - Date: Fri, 7 Nov 2025 08:11:19 +0100 Subject: [PATCH 11/13] [IMP] l10n_es_account_capital_asset: pre-commit auto fixes --- l10n_es_account_capital_asset/__manifest__.py | 2 +- l10n_es_account_capital_asset/models/account_move.py | 6 +++--- l10n_es_account_capital_asset/pyproject.toml | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 l10n_es_account_capital_asset/pyproject.toml diff --git a/l10n_es_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index f110acbf6..d2d786328 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -8,7 +8,7 @@ "version": "14.0.1.0.6", "category": "Accounting", "author": "NuoBiT Solutions, S.L.", - "website": "https://github.com/nuobit/odoo-addons", + "website": "https://github.com/NuoBiT/odoo-addons", "license": "AGPL-3", "depends": [ "l10n_es_asset_extension", diff --git a/l10n_es_account_capital_asset/models/account_move.py b/l10n_es_account_capital_asset/models/account_move.py index ea3116947..927131aad 100644 --- a/l10n_es_account_capital_asset/models/account_move.py +++ b/l10n_es_account_capital_asset/models/account_move.py @@ -19,7 +19,7 @@ def _prepare_asset_vals(self, aml): ) ) if aml.balance >= threshold_amount: - vals[ - "capital_asset_type_id" - ] = aml.asset_profile_id.capital_asset_type_id + vals["capital_asset_type_id"] = ( + aml.asset_profile_id.capital_asset_type_id + ) return vals diff --git a/l10n_es_account_capital_asset/pyproject.toml b/l10n_es_account_capital_asset/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/l10n_es_account_capital_asset/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" From c00a51d26ce6665732d6c619f2ad293b218d6686 Mon Sep 17 00:00:00 2001 From: ??? Date: Wed, 18 Mar 2026 11:07:13 +0100 Subject: [PATCH 12/13] [MIG] l10n_es_account_capital_asset: Migration to 18.0 --- l10n_es_account_capital_asset/README.rst | 61 ++- l10n_es_account_capital_asset/__manifest__.py | 8 +- l10n_es_account_capital_asset/i18n/es.po | 16 +- .../migrations/18.0.1.0.1/pre-migration.py | 18 + .../models/account_asset.py | 20 +- .../models/account_asset_profile.py | 8 +- .../models/account_capital_asset_map_tax.py | 35 +- .../models/account_capital_asset_type.py | 11 +- .../models/account_move.py | 5 +- .../models/account_move_line.py | 63 ++- .../models/account_tax.py | 61 +-- .../models/res_company.py | 3 +- .../models/res_config_settings.py | 6 +- .../readme/CONTRIBUTORS.md | 4 + .../readme/DESCRIPTION.md | 1 + ...account_capital_asset_map_tax_security.xml | 12 + .../static/description/index.html | 422 ++++++++++++++++++ .../views/account_asset.xml | 7 +- .../views/account_asset_profile_views.xml | 5 +- .../account_capital_asset_map_tax_views.xml | 12 +- .../views/account_capital_asset_type_view.xml | 11 +- .../views/res_company_view.xml | 2 +- .../views/res_config_settings_views.xml | 31 +- 23 files changed, 665 insertions(+), 157 deletions(-) create mode 100644 l10n_es_account_capital_asset/migrations/18.0.1.0.1/pre-migration.py create mode 100644 l10n_es_account_capital_asset/readme/CONTRIBUTORS.md create mode 100644 l10n_es_account_capital_asset/readme/DESCRIPTION.md create mode 100644 l10n_es_account_capital_asset/security/l10n_es_account_capital_asset_map_tax_security.xml create mode 100644 l10n_es_account_capital_asset/static/description/index.html diff --git a/l10n_es_account_capital_asset/README.rst b/l10n_es_account_capital_asset/README.rst index a3740e5c7..23d4f9cb7 100644 --- a/l10n_es_account_capital_asset/README.rst +++ b/l10n_es_account_capital_asset/README.rst @@ -1,28 +1,65 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - ===================== Account Capital Asset ===================== -* This module adds mapping for capital assets taxes, capital assets category - types and threshold amount on res_config. +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3ac43149bebc77803d9f32dceaf33197a6fdb57d043b1fcc50ecb717542f48aa + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_account_capital_asset + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + +This module adds mapping for capital assets taxes, capital assets +category types and threshold amount on res_config + +**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 smashing it by providing a detailed and welcomed feedback. +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 ------------ -* Kilian Niubo -* Eric Antones +- `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_account_capital_asset/__manifest__.py b/l10n_es_account_capital_asset/__manifest__.py index d2d786328..0d55b2156 100644 --- a/l10n_es_account_capital_asset/__manifest__.py +++ b/l10n_es_account_capital_asset/__manifest__.py @@ -1,13 +1,14 @@ -# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) { "name": "Account Capital Asset", "summary": "This module adds mapping for capital assets taxes, capital assets" " category types and threshold amount on res_config", - "version": "14.0.1.0.6", + "version": "18.0.1.0.1", "category": "Accounting", - "author": "NuoBiT Solutions, S.L.", + "author": "NuoBiT Solutions SL", "website": "https://github.com/NuoBiT/odoo-addons", "license": "AGPL-3", "depends": [ @@ -15,6 +16,7 @@ ], "data": [ "security/ir.model.access.csv", + "security/l10n_es_account_capital_asset_map_tax_security.xml", "data/account_capital_asset_type_data.xml", "data/ir_config_parameter.xml", "views/account_asset.xml", diff --git a/l10n_es_account_capital_asset/i18n/es.po b/l10n_es_account_capital_asset/i18n/es.po index eb3159b6e..e3699d126 100644 --- a/l10n_es_account_capital_asset/i18n/es.po +++ b/l10n_es_account_capital_asset/i18n/es.po @@ -16,8 +16,8 @@ msgstr "" "Plural-Forms: \n" #. module: l10n_es_account_capital_asset -#: model:ir.actions.act_window,name:l10n_es_account_capital_asset.account_capital_asset_action -#: model:ir.ui.menu,name:l10n_es_account_capital_asset.account_tax_map_amount +#: model:ir.actions.act_window,name:l10n_es_account_capital_asset.l10n_es_account_capital_asset_map_tax_action +#: model:ir.ui.menu,name:l10n_es_account_capital_asset.l10n_es_account_capital_asset_map_tax_menu msgid "Account Capital Asset Tax Map" msgstr "Bienes de inversión - Mapeo de impuestos" @@ -28,9 +28,15 @@ msgstr "Bien de inversión" #. module: l10n_es_account_capital_asset #: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_res_company__l10n_es_capital_asset_enabled -msgid "L10n ES - Capital Asset Enabled" +msgid "L10n ES Capital Asset Enabled" msgstr "L10n ES - Bienes de inversión activados" +#. module: l10n_es_account_capital_asset +#: code:addons/l10n_es_account_capital_asset/models/account_capital_asset_type.py:0 +#, python-format +msgid "years" +msgstr "años" + #. module: l10n_es_account_capital_asset #: model:ir.actions.act_window,name:l10n_es_account_capital_asset.capital_asset_type_action #: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__capital_asset_type_id @@ -60,8 +66,8 @@ msgstr "Un perfil para un conjunto de bienes de inversión no es compatible " "Por favor, seleccione solo uno de ellos." #. module: l10n_es_account_capital_asset -#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__capital_asset_type_id -#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__profile_capital_asset_type_id +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset_profile__default_capital_asset_type_id +#: model:ir.model.fields,field_description:l10n_es_account_capital_asset.field_account_asset__default_capital_asset_type_id msgid "Default Capital Asset Type" msgstr "Tipo de bien de inversión por defecto" diff --git a/l10n_es_account_capital_asset/migrations/18.0.1.0.1/pre-migration.py b/l10n_es_account_capital_asset/migrations/18.0.1.0.1/pre-migration.py new file mode 100644 index 000000000..1b53ed4ec --- /dev/null +++ b/l10n_es_account_capital_asset/migrations/18.0.1.0.1/pre-migration.py @@ -0,0 +1,18 @@ +# Copyright 2026 NuoBiT Solutions - Deniz Gallo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from openupgradelib import openupgrade + +from odoo.tools.sql import column_exists + +_column_renames = { + "account_asset_profile": [ + ("capital_asset_type_id", "default_capital_asset_type_id"), + ], +} + + +@openupgrade.migrate() +def migrate(env, version): + if column_exists(env.cr, "account_asset_profile", "capital_asset_type_id"): + openupgrade.rename_columns(env.cr, _column_renames) diff --git a/l10n_es_account_capital_asset/models/account_asset.py b/l10n_es_account_capital_asset/models/account_asset.py index 57c9ddcd0..ea714e8ee 100644 --- a/l10n_es_account_capital_asset/models/account_asset.py +++ b/l10n_es_account_capital_asset/models/account_asset.py @@ -1,26 +1,23 @@ -# Copyright NuoBiT - Kilian Niubo -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright NuoBiT Solutions - Eric Antones +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import _, api, fields, models from odoo.exceptions import ValidationError -from odoo.addons.account_asset_management.models.account_asset import READONLY_STATES - class AccountAsset(models.Model): _inherit = "account.asset" - # TODO: rename to default_capital_asset_type_id - profile_capital_asset_type_id = fields.Many2one( + default_capital_asset_type_id = fields.Many2one( string="Default Capital Asset Type", - related="profile_id.capital_asset_type_id", + related="profile_id.default_capital_asset_type_id", ) capital_asset_type_id = fields.Many2one( comodel_name="l10n.es.account.capital.asset.type", ondelete="restrict", - states=READONLY_STATES, - domain="[('id', '=', profile_capital_asset_type_id)]", + domain="[('id', '=', default_capital_asset_type_id)]", ) @api.constrains("capital_asset_type_id", "company_id") @@ -63,13 +60,14 @@ def _check_tax_base_amount(self): ): return for rec in self: - self.tax_ids.check_tax_base_amount(rec) + rec.tax_ids.check_tax_base_amount(rec) @api.constrains("profile_id", "capital_asset_type_id") def _check_capital_asset_type_integrity(self): if ( self.capital_asset_type_id - and self.profile_id.capital_asset_type_id != self.capital_asset_type_id + and self.profile_id.default_capital_asset_type_id + != self.capital_asset_type_id ): raise ValidationError( _( diff --git a/l10n_es_account_capital_asset/models/account_asset_profile.py b/l10n_es_account_capital_asset/models/account_asset_profile.py index 12e25632f..254b5d1b4 100644 --- a/l10n_es_account_capital_asset/models/account_asset_profile.py +++ b/l10n_es_account_capital_asset/models/account_asset_profile.py @@ -1,5 +1,6 @@ -# Copyright NuoBiT - Kilian Niubo -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright NuoBiT Solutions - Eric Antones +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import _, api, fields, models @@ -9,8 +10,7 @@ class AccountAssetProfile(models.Model): _inherit = "account.asset.profile" - # TODO: rename to default_capital_asset_type_id - capital_asset_type_id = fields.Many2one( + default_capital_asset_type_id = fields.Many2one( string="Default Capital Asset Type", comodel_name="l10n.es.account.capital.asset.type", ondelete="restrict", diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py index 7d0822325..593485530 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_map_tax.py @@ -1,5 +1,6 @@ -# Copyright NuoBiT - Kilian Niubo -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright NuoBiT Solutions - Eric Antones +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import api, fields, models @@ -9,22 +10,26 @@ class AccountCapitalAssetMapTax(models.Model): _name = "l10n.es.account.capital.asset.map.tax" _description = "Capital Asset Map Tax" + company_id = fields.Many2one( + comodel_name="res.company", + required=True, + default=lambda self: self.env.company, + ) tax_src_id = fields.Many2one( - "account.tax.template", string="Tax Source", required=True + comodel_name="account.tax", + string="Tax Source", + required=True, + check_company=True, ) tax_dest_id = fields.Many2one( - "account.tax.template", string="Replacement Tax", required=True + comodel_name="account.tax", + string="Replacement Tax", + required=True, + check_company=True, ) - # TODO: Refactor to do this function more efficient or do it with ormcache - # @ormcache("tax_template", "company","tax_src_id","tax_dest_id") - def _get_taxes_mapping_from_tax_templates(self, company): - return { - company.get_taxes_from_templates( - x.tax_src_id - ): company.get_taxes_from_templates(x.tax_dest_id) - for x in self.search([]) - } + def _get_taxes_mapping(self): + return {mapping.tax_src_id: mapping.tax_dest_id for mapping in self.search([])} @api.model def map_tax(self, taxes, company, asset_profile, amount, quantity): @@ -47,8 +52,8 @@ def map_tax(self, taxes, company, asset_profile, amount, quantity): asset_price = amount result = taxes if asset_price >= float(threshold_capital_asset_amount): - tax_map = self._get_taxes_mapping_from_tax_templates(company) + tax_map = self._get_taxes_mapping() result = self.env["account.tax"] for tax in taxes: - result |= tax_map[tax._origin] if tax._origin in tax_map else tax + result |= tax_map.get(tax._origin, tax) return result diff --git a/l10n_es_account_capital_asset/models/account_capital_asset_type.py b/l10n_es_account_capital_asset/models/account_capital_asset_type.py index 3e6bd0159..273bccbe0 100644 --- a/l10n_es_account_capital_asset/models/account_capital_asset_type.py +++ b/l10n_es_account_capital_asset/models/account_capital_asset_type.py @@ -1,4 +1,5 @@ -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions - Eric Antones +# Copyright 2025 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import _, api, fields, models @@ -9,7 +10,7 @@ class CapitalAssetType(models.Model): _name = "l10n.es.account.capital.asset.type" _description = "Capital Asset Type" - name = fields.Char(string="Name", required=True, translate=True) + name = fields.Char(required=True, translate=True) period = fields.Integer(string="Period (years)", required=True) _sql_constraints = [ @@ -25,8 +26,10 @@ class CapitalAssetType(models.Model): ), ] - def name_get(self): - return [(rec.id, "%s (%i years)" % (rec.name, rec.period)) for rec in self] + @api.depends("name", "period") + def _compute_display_name(self): + for rec in self: + rec.display_name = f"{rec.name} ({rec.period} {_('years')})" @api.constrains("period") def _check_period(self): diff --git a/l10n_es_account_capital_asset/models/account_move.py b/l10n_es_account_capital_asset/models/account_move.py index 927131aad..db9ebe2b5 100644 --- a/l10n_es_account_capital_asset/models/account_move.py +++ b/l10n_es_account_capital_asset/models/account_move.py @@ -1,4 +1,5 @@ -# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) @@ -20,6 +21,6 @@ def _prepare_asset_vals(self, aml): ) if aml.balance >= threshold_amount: vals["capital_asset_type_id"] = ( - aml.asset_profile_id.capital_asset_type_id + aml.asset_profile_id.default_capital_asset_type_id.id ) return vals diff --git a/l10n_es_account_capital_asset/models/account_move_line.py b/l10n_es_account_capital_asset/models/account_move_line.py index 32bdc035f..794ca6bf8 100644 --- a/l10n_es_account_capital_asset/models/account_move_line.py +++ b/l10n_es_account_capital_asset/models/account_move_line.py @@ -1,5 +1,6 @@ -# Copyright NuoBiT - Kilian Niubo -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright NuoBiT Solutions - Eric Antones +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) @@ -9,40 +10,38 @@ class AccountMoveLine(models.Model): _inherit = "account.move.line" - @api.onchange("product_id") - def _onchange_product_id(self): - super()._onchange_product_id() + @api.onchange( + "product_id", + "product_uom_id", + "account_id", + "tax_ids", + "asset_profile_id", + "price_subtotal", + "quantity", + ) + def _onchange_recompute_mapped_taxes(self): self.compute_mapped_taxes() - @api.onchange("product_uom_id") - def _onchange_uom_id(self): - super()._onchange_uom_id() + def _compute_tax_ids(self): + res = super()._compute_tax_ids() self.compute_mapped_taxes() + return res - @api.onchange("account_id") - def _onchange_account_id(self): - super()._onchange_uom_id() - self.compute_mapped_taxes() - - @api.onchange("tax_ids") - def _onchange_tax_ids(self): - self.compute_mapped_taxes() - - @api.onchange("asset_profile_id") - def _onchange_asset_profile_id(self): - super()._onchange_asset_profile_id() - self.compute_mapped_taxes() - - @api.onchange("price_subtotal", "quantity") - def _onchange_subtotal_quantity_id(self): + def _inverse_account_id(self): + res = super()._inverse_account_id() self.compute_mapped_taxes() + return res def compute_mapped_taxes(self): - if self.tax_ids: - self.tax_ids = self.env["l10n.es.account.capital.asset.map.tax"].map_tax( - self.tax_ids, - self.company_id, - self.asset_profile_id, - self.balance, - self.quantity, - ) + for line in self: + if line.tax_ids: + line.tax_ids = line.env[ + "l10n.es.account.capital.asset.map.tax" + ].map_tax( + line.tax_ids, + line.company_id, + line.asset_profile_id, + line.balance, + line.quantity, + ) + return self diff --git a/l10n_es_account_capital_asset/models/account_tax.py b/l10n_es_account_capital_asset/models/account_tax.py index 3044fdc9b..dfa71bcc7 100644 --- a/l10n_es_account_capital_asset/models/account_tax.py +++ b/l10n_es_account_capital_asset/models/account_tax.py @@ -1,5 +1,6 @@ -# Copyright NuoBiT - Kilian Niubo -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions SL - Kilian Niubo +# Copyright NuoBiT Solutions SL - Eric Antones +# Copyright 2025 NuoBiT Solutions SL - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import _, models @@ -15,13 +16,12 @@ def check_tax_base_amount(self, asset): .sudo() .get_param("l10n_es_account_capital_asset.capital_asset_threshold_amount") ) - bi_tax_templates = self.env["l10n.es.account.capital.asset.map.tax"].search([]) + tax_mappings = self.env["l10n.es.account.capital.asset.map.tax"].search([]) + capital_asset_dest_taxes = tax_mappings.mapped("tax_dest_id") + for rec in self: - bi_dest_taxes = rec.company_id.get_taxes_from_templates( - bi_tax_templates.tax_dest_id - ) - taxes = rec.filtered(lambda x: x in bi_dest_taxes) if rec.company_id.l10n_es_capital_asset_enabled: + is_capital_asset_tax = rec in capital_asset_dest_taxes if ( not asset.profile_id.asset_product_item and asset.profile_id.capital_asset_set @@ -29,31 +29,38 @@ def check_tax_base_amount(self, asset): tax_base_amount_unit = asset.tax_base_amount_unit else: tax_base_amount_unit = asset.tax_base_amount - if tax_base_amount_unit >= threshold_amount and not taxes: + if ( + tax_base_amount_unit >= threshold_amount + and not is_capital_asset_tax + ): raise ValidationError( _( - "The asset of type ‘%s’ has an unit amount %.2f€ greater than " - "%.2f€, so it is considered a capital asset, but the selected " - "taxes are not of a capital asset type. Please update the taxes " - "accordingly or define the asset type as a set of assets." - ) - % ( - asset.profile_id.name, - tax_base_amount_unit, - threshold_amount, + "The asset of type '%(asset_type)s' has a unit amount " + "%(unit_amount).2f€ greater than %(threshold).2f€, so " + "it is considered a capital asset, but the selected " + "taxes are not of a capital asset type. Please update " + "the taxes accordingly or define the asset type as" + " a set of assets." ) + % { + "asset_type": asset.profile_id.name, + "unit_amount": tax_base_amount_unit, + "threshold": threshold_amount, + } ) - elif tax_base_amount_unit < threshold_amount and taxes: + elif tax_base_amount_unit < threshold_amount and is_capital_asset_tax: raise ValidationError( _( - "The asset of type ‘%s’ has a unit amount %.2f€ lower than %.2f€, " - "so it is not considered a capital asset, " - "but capital asset taxes are selected. Please update the taxes " - "accordingly or define the asset type as a set of assets." - ) - % ( - asset.profile_id.name, - tax_base_amount_unit, - threshold_amount, + "The asset of type '%(asset_type)s' has a unit amount" + " %(unit_amount).2f€ lower than %(threshold).2f€, so " + "it is not considered a capital asset, but capital " + "asset taxes are selected. Please update the taxes " + "accordingly or define the asset type as a set of " + "assets." ) + % { + "asset_type": asset.profile_id.name, + "unit_amount": tax_base_amount_unit, + "threshold": threshold_amount, + } ) diff --git a/l10n_es_account_capital_asset/models/res_company.py b/l10n_es_account_capital_asset/models/res_company.py index 34c1c2caf..39f290673 100644 --- a/l10n_es_account_capital_asset/models/res_company.py +++ b/l10n_es_account_capital_asset/models/res_company.py @@ -1,4 +1,5 @@ -# Copyright NuoBiT - Kilian Niubo +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright 2025 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import fields, models diff --git a/l10n_es_account_capital_asset/models/res_config_settings.py b/l10n_es_account_capital_asset/models/res_config_settings.py index b77cb6d15..1f3ea9295 100644 --- a/l10n_es_account_capital_asset/models/res_config_settings.py +++ b/l10n_es_account_capital_asset/models/res_config_settings.py @@ -1,5 +1,6 @@ -# Copyright NuoBiT - Kilian Niubo -# Copyright NuoBiT - Eric Antones +# Copyright NuoBiT Solutions - Kilian Niubo +# Copyright NuoBiT Solutions - Eric Antones +# Copyright 2025 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import fields, models @@ -8,7 +9,6 @@ class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" capital_asset_threshold_amount = fields.Float( - string="Capital Asset Threshold Amount", config_parameter="l10n_es_account_capital_asset.capital_asset_threshold_amount", help="Minimum amount to consider the asset as a capital asset", ) diff --git a/l10n_es_account_capital_asset/readme/CONTRIBUTORS.md b/l10n_es_account_capital_asset/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..8d6d66521 --- /dev/null +++ b/l10n_es_account_capital_asset/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [NuoBiT](): + - Kilian Niubo + - Eric Antones + - Deniz Gallo diff --git a/l10n_es_account_capital_asset/readme/DESCRIPTION.md b/l10n_es_account_capital_asset/readme/DESCRIPTION.md new file mode 100644 index 000000000..e410c924c --- /dev/null +++ b/l10n_es_account_capital_asset/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds mapping for capital assets taxes, capital assets category types and threshold amount on res_config diff --git a/l10n_es_account_capital_asset/security/l10n_es_account_capital_asset_map_tax_security.xml b/l10n_es_account_capital_asset/security/l10n_es_account_capital_asset_map_tax_security.xml new file mode 100644 index 000000000..1e805b6e6 --- /dev/null +++ b/l10n_es_account_capital_asset/security/l10n_es_account_capital_asset_map_tax_security.xml @@ -0,0 +1,12 @@ + + + + + Capital Asset Map Tax: multi-company + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + diff --git a/l10n_es_account_capital_asset/static/description/index.html b/l10n_es_account_capital_asset/static/description/index.html new file mode 100644 index 000000000..1dd4b198b --- /dev/null +++ b/l10n_es_account_capital_asset/static/description/index.html @@ -0,0 +1,422 @@ + + + + + +Account Capital Asset + + + +
+

Account Capital Asset

+ + +

Beta License: AGPL-3 NuoBiT/odoo-addons

+

This module adds mapping for capital assets taxes, capital assets +category types and threshold amount on res_config

+

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_account_capital_asset/views/account_asset.xml b/l10n_es_account_capital_asset/views/account_asset.xml index ae1636f43..73ec9d886 100644 --- a/l10n_es_account_capital_asset/views/account_asset.xml +++ b/l10n_es_account_capital_asset/views/account_asset.xml @@ -1,5 +1,6 @@ - @@ -10,10 +11,10 @@ />
- + - +
diff --git a/l10n_es_account_capital_asset/views/account_asset_profile_views.xml b/l10n_es_account_capital_asset/views/account_asset_profile_views.xml index 521922c8e..b49c5fa48 100644 --- a/l10n_es_account_capital_asset/views/account_asset_profile_views.xml +++ b/l10n_es_account_capital_asset/views/account_asset_profile_views.xml @@ -1,5 +1,6 @@ - @@ -14,7 +15,7 @@
diff --git a/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml b/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml index 6d87999dd..946e23812 100644 --- a/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml +++ b/l10n_es_account_capital_asset/views/account_capital_asset_map_tax_views.xml @@ -1,21 +1,23 @@ - - account.capital.asset.tree + account.capital.asset.list l10n.es.account.capital.asset.map.tax - + + - + Account Capital Asset Tax Map l10n.es.account.capital.asset.map.tax - tree + list - aeat.vat.special.prorrate.capital.asset.type.view.tree + >aeat.vat.special.prorrate.capital.asset.type.view.list l10n.es.account.capital.asset.type - + - + Capital Asset Type l10n.es.account.capital.asset.type - tree,form + list,form - diff --git a/l10n_es_account_capital_asset/views/res_config_settings_views.xml b/l10n_es_account_capital_asset/views/res_config_settings_views.xml index 42f4c05ff..0b642af42 100644 --- a/l10n_es_account_capital_asset/views/res_config_settings_views.xml +++ b/l10n_es_account_capital_asset/views/res_config_settings_views.xml @@ -1,30 +1,19 @@ - + res.config.settings -
-

Capital Assets

-
-
-
-
-
-
-
-
-
-
-
+ + + + + + +
From 9343cb2528a399723907a016c1c6b48cf85e19da Mon Sep 17 00:00:00 2001 From: ??? Date: Mon, 19 Jan 2026 10:36:35 +0100 Subject: [PATCH 13/13] [DO NOT MERGE] test-requirements.txt --- test-requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..0e3aa5a11 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,3 @@ +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