diff --git a/l10n_es_vat_prorate/README.rst b/l10n_es_vat_prorate/README.rst index c9f9452d100..ffb37c8f060 100644 --- a/l10n_es_vat_prorate/README.rst +++ b/l10n_es_vat_prorate/README.rst @@ -30,6 +30,8 @@ Prorrata de IVA El módulo nos divide los IVA según la prorrata de la compañía. +Permite recalcular la prórrata del IVA de todas las facturas y reembolsos de proveedores para un periodo determinado. + **Table of contents** .. contents:: @@ -76,6 +78,8 @@ Contributors * Pedro M. Baeza * Carolina Fernandez +* Eduardo de Miguel (`Moduon `__) + Maintainers ~~~~~~~~~~~ diff --git a/l10n_es_vat_prorate/i18n/es.po b/l10n_es_vat_prorate/i18n/es.po index bbe842d2108..4eacc6f20ab 100644 --- a/l10n_es_vat_prorate/i18n/es.po +++ b/l10n_es_vat_prorate/i18n/es.po @@ -6,21 +6,32 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-10-09 05:51+0000\n" -"Last-Translator: Ivorra78 \n" -"Language-Team: none\n" +"POT-Creation-Date: 2025-02-14 09:33+0000\n" +"PO-Revision-Date: 2025-02-14 10:36+0100\n" +"Last-Translator: \n" +"Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.17\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.4.4\n" #. module: l10n_es_vat_prorate #: model:ir.model.fields,help:l10n_es_vat_prorate.field_account_tax__prorate_account_ids msgid "Accounts to apply the recompute" msgstr "Cuentas para aplicar el recálculo" +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_tree_view +msgid "" +"Are you sure you want to recompute prorata in all Bills and Refunds of this " +"period? This action cannot be undone." +msgstr "" +"¿Estás seguro que quieres recomputar la prórrata del IVA en todas las " +"Facturas y Reembolsos de Proveedores para este periodo? Esta acción no se " +"puede deshacer." + #. module: l10n_es_vat_prorate #: model:ir.model,name:l10n_es_vat_prorate.model_res_company msgid "Companies" @@ -64,7 +75,7 @@ msgstr "ID (identificación)" #. module: l10n_es_vat_prorate #: model:ir.model,name:l10n_es_vat_prorate.model_account_move_line msgid "Journal Item" -msgstr "Artículo Diario" +msgstr "Apunte contable" #. module: l10n_es_vat_prorate #: model:ir.model.fields,field_description:l10n_es_vat_prorate.field_res_company_vat_prorate____last_update @@ -101,6 +112,19 @@ msgstr "" msgid "Prorrate Investment Account" msgstr "" +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_form_view +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_tree_view +msgid "Recompute period" +msgstr "Recomputar periodo" + +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_tree_view +msgid "Recompute prorata in all Bills and Refunds of this period" +msgstr "" +"Recomputar la prórrata del IVA en estas Facturas y Reembolsos de este " +"periodo" + #. module: l10n_es_vat_prorate #: model:ir.model,name:l10n_es_vat_prorate.model_account_tax msgid "Tax" @@ -114,7 +138,22 @@ msgstr "Plantilla con prorrateo del IVA" #. module: l10n_es_vat_prorate #: model:ir.model,name:l10n_es_vat_prorate.model_account_tax_template msgid "Templates for Taxes" -msgstr "Plantillas para impuestos" +msgstr "Plantilla de impuestos" + +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_form_view +msgid "This action will recompute Prorata in all Bills of this period" +msgstr "" +"Esta acción recomputará la prórrata del IVA en todas las Facturas y " +"Reembolsos de este periodo" + +#. module: l10n_es_vat_prorate +#. odoo-python +#: code:addons/l10n_es_vat_prorate/models/res_company.py:0 +#, python-format +msgid "Unable to recompute VAT prorate Bills and Refunds" +msgstr "" +"Imposible recomputar la prórrata del IVA en estas Facturas y Reembolsos" #. module: l10n_es_vat_prorate #: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_form_view diff --git a/l10n_es_vat_prorate/i18n/l10n_es_vat_prorate.pot b/l10n_es_vat_prorate/i18n/l10n_es_vat_prorate.pot index 2fc55622688..2f1e655453e 100644 --- a/l10n_es_vat_prorate/i18n/l10n_es_vat_prorate.pot +++ b/l10n_es_vat_prorate/i18n/l10n_es_vat_prorate.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-14 09:33+0000\n" +"PO-Revision-Date: 2025-02-14 09:33+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -18,6 +20,13 @@ msgstr "" msgid "Accounts to apply the recompute" msgstr "" +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_tree_view +msgid "" +"Are you sure you want to recompute prorata in all Bills and Refunds of this " +"period? This action cannot be undone." +msgstr "" + #. module: l10n_es_vat_prorate #: model:ir.model,name:l10n_es_vat_prorate.model_res_company msgid "Companies" @@ -98,6 +107,17 @@ msgstr "" msgid "Prorrate Investment Account" msgstr "" +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_form_view +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_tree_view +msgid "Recompute period" +msgstr "" + +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_tree_view +msgid "Recompute prorata in all Bills and Refunds of this period" +msgstr "" + #. module: l10n_es_vat_prorate #: model:ir.model,name:l10n_es_vat_prorate.model_account_tax msgid "Tax" @@ -113,6 +133,18 @@ msgstr "" msgid "Templates for Taxes" msgstr "" +#. module: l10n_es_vat_prorate +#: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_vat_prorate_form_view +msgid "This action will recompute Prorata in all Bills of this period" +msgstr "" + +#. module: l10n_es_vat_prorate +#. odoo-python +#: code:addons/l10n_es_vat_prorate/models/res_company.py:0 +#, python-format +msgid "Unable to recompute VAT prorate Bills and Refunds" +msgstr "" + #. module: l10n_es_vat_prorate #: model_terms:ir.ui.view,arch_db:l10n_es_vat_prorate.res_company_form_view msgid "VAT Prorate" diff --git a/l10n_es_vat_prorate/models/res_company.py b/l10n_es_vat_prorate/models/res_company.py index a7f433403ab..9b9919df47f 100644 --- a/l10n_es_vat_prorate/models/res_company.py +++ b/l10n_es_vat_prorate/models/res_company.py @@ -1,10 +1,15 @@ # Copyright 2022 Creu Blanca # Copyright 2023 Tecnativa Carolina Fernandez +# Copyright 2025 Moduon Team # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging + from odoo import _, api, fields, models, tools from odoo.exceptions import ValidationError +_logger = logging.getLogger(__name__) + class ResCompany(models.Model): _inherit = "res.company" @@ -85,6 +90,52 @@ class ResCompanyVatProrate(models.Model): date = fields.Date(required=True, default=fields.Date.today()) vat_prorate = fields.Float() + def action_recompute_period(self): + self.ensure_one() + next_vat_prorate_period = self.search( + [ + ("company_id", "=", self.company_id.id), + ("date", ">", self.date), + ], + limit=1, + order="date ASC", + ) + move_domain = [ + ("move_type", "in", ["in_invoice", "in_refund"]), + ("state", "=", "posted"), + ("date", ">=", self.date), + ] + if next_vat_prorate_period: + move_domain.append(("date", "<", next_vat_prorate_period.date)) + + unable_to_recompute_moves = self.env["account.move"].browse() + for move in self.env["account.move"].search(move_domain): + all_reconciled_lines = move.line_ids._all_reconciled_lines() + # Reset to draft + try: + move.button_draft() + except Exception as ex: + _logger.warning("Unable to re-prorate %s", move, exc_info=ex) + unable_to_recompute_moves |= move + continue + # Clear and Set taxes + inv_line_map = { + inv_line: inv_line.tax_ids.ids for inv_line in move.invoice_line_ids + } + move.invoice_line_ids.write({"tax_ids": [(6, 0, [])]}) + for inv_line, tax_ids in inv_line_map.items(): + inv_line.write({"tax_ids": [(6, 0, tax_ids)]}) + move.action_post() + all_reconciled_lines.reconcile() + + if not unable_to_recompute_moves: + return True + + action = self.env.ref("account.action_move_in_invoice_type").read()[0] + action["display_name"] = _("Unable to recompute VAT prorate Bills and Refunds") + action["domain"] = [("id", "in", unable_to_recompute_moves.ids)] + return action + _sql_constraints = [ ( "vat_prorate_percent_amount", diff --git a/l10n_es_vat_prorate/readme/CONTRIBUTORS.rst b/l10n_es_vat_prorate/readme/CONTRIBUTORS.rst index f9b34a172a3..8c420407ec9 100644 --- a/l10n_es_vat_prorate/readme/CONTRIBUTORS.rst +++ b/l10n_es_vat_prorate/readme/CONTRIBUTORS.rst @@ -3,3 +3,5 @@ * Pedro M. Baeza * Carolina Fernandez + +* Eduardo de Miguel (`Moduon `__) diff --git a/l10n_es_vat_prorate/readme/DESCRIPTION.rst b/l10n_es_vat_prorate/readme/DESCRIPTION.rst index 932b7999819..49624d94cf8 100644 --- a/l10n_es_vat_prorate/readme/DESCRIPTION.rst +++ b/l10n_es_vat_prorate/readme/DESCRIPTION.rst @@ -1 +1,3 @@ El módulo nos divide los IVA según la prorrata de la compañía. + +Permite recalcular la prórrata del IVA de todas las facturas y reembolsos de proveedores para un periodo determinado. diff --git a/l10n_es_vat_prorate/static/description/index.html b/l10n_es_vat_prorate/static/description/index.html index 14d1bd46d3d..55ed9ae49d5 100644 --- a/l10n_es_vat_prorate/static/description/index.html +++ b/l10n_es_vat_prorate/static/description/index.html @@ -371,6 +371,7 @@

Prorrata de IVA

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/l10n-spain Translate me on Weblate Try me on Runboat

El módulo nos divide los IVA según la prorrata de la compañía.

+

Permite recalcular la prórrata del IVA de todas las facturas y reembolsos de proveedores para un periodo determinado.

Table of contents

+
  • Eduardo de Miguel (Moduon)
  • diff --git a/l10n_es_vat_prorate/tests/test_vat_prorate.py b/l10n_es_vat_prorate/tests/test_vat_prorate.py index 2cb5fe69f35..a4ebe278c31 100644 --- a/l10n_es_vat_prorate/tests/test_vat_prorate.py +++ b/l10n_es_vat_prorate/tests/test_vat_prorate.py @@ -1,6 +1,7 @@ # Copyright 2022 Creu Blanca # Copyright 2023 Tecnativa - Pedro M. Baeza # Copyright 2023 Tecnativa - Carolina Fernandez +# Copyright 2025 Moduon Team # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from datetime import date @@ -8,7 +9,7 @@ from psycopg2 import IntegrityError from odoo import exceptions -from odoo.tests.common import tagged +from odoo.tests.common import Form, tagged from odoo.tools import mute_logger from odoo.addons.account.tests.common import AccountTestInvoicingCommon @@ -215,3 +216,32 @@ def test_prorate_make_refund(self): self.assertEqual(len(tax_lines), 2) # One of the tax lines should have expense account and the other the tax account self.assertNotEqual(tax_lines[0].account_id, tax_lines[1].account_id) + + def test_prorate_recompute_period(self): + self.product_b.property_account_expense_id = self.company_data[ + "default_account_assets" + ] + invoice = self.init_invoice("in_invoice", products=[self.product_b], post=True) + initial_prorate_amount = sum( + invoice.line_ids.filtered_domain([("vat_prorate", "=", True)]).mapped( + "balance" + ) + ) + action_data = invoice.action_register_payment() + wizard = Form( + self.env["account.payment.register"].with_context(**action_data["context"]) + ).save() + wizard.action_create_payments() + self.assertIn(invoice.payment_state, ["in_payment", "paid"]) + company_prorate = self.env.company.vat_prorate_ids[0] + company_prorate.vat_prorate += 10 + company_prorate.action_recompute_period() + invoice.invalidate_recordset() + final_prorate_amount = sum( + invoice.line_ids.filtered_domain([("vat_prorate", "=", True)]).mapped( + "balance" + ) + ) + self.assertNotEqual(initial_prorate_amount, final_prorate_amount) + self.assertEqual(invoice.state, "posted") + self.assertIn(invoice.payment_state, ["in_payment", "paid"]) diff --git a/l10n_es_vat_prorate/views/res_company_prorate_views.xml b/l10n_es_vat_prorate/views/res_company_prorate_views.xml index c66a28b98ab..8a78bff10bb 100644 --- a/l10n_es_vat_prorate/views/res_company_prorate_views.xml +++ b/l10n_es_vat_prorate/views/res_company_prorate_views.xml @@ -7,7 +7,15 @@ res.company.vat.prorate
    -
    +
    +
    @@ -25,6 +33,16 @@ +