From 51d6247023afa7c9c87df5244296cf14e04b2a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20L=C3=B3pez?= Date: Mon, 14 Aug 2023 11:51:37 -0400 Subject: [PATCH] [IMP] l10n_do_accounting: don't allow to cancel fiscal document if not posted before (#1081) --- l10n_do_accounting/__manifest__.py | 2 +- l10n_do_accounting/i18n/es_DO.po | 6 ++++++ l10n_do_accounting/models/account_move.py | 3 +++ l10n_do_accounting/views/account_move_views.xml | 10 ---------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/l10n_do_accounting/__manifest__.py b/l10n_do_accounting/__manifest__.py index 9bd095678..e699c2b91 100644 --- a/l10n_do_accounting/__manifest__.py +++ b/l10n_do_accounting/__manifest__.py @@ -8,7 +8,7 @@ "category": "Localization", "license": "LGPL-3", "website": "https://github.com/odoo-dominicana", - "version": "15.0.0.11.0", + "version": "15.0.0.11.1", # any module necessary for this one to work correctly "depends": ["l10n_latam_invoice_document", "l10n_do"], # always loaded diff --git a/l10n_do_accounting/i18n/es_DO.po b/l10n_do_accounting/i18n/es_DO.po index 05ea0fdbe..c347e3e80 100644 --- a/l10n_do_accounting/i18n/es_DO.po +++ b/l10n_do_accounting/i18n/es_DO.po @@ -1247,3 +1247,9 @@ msgstr "" #, python-format msgid "special from Tax Paying" msgstr "Exento" + +#. module: l10n_do_accounting +#: code:addons/l10n_do_accounting/models/account_move.py:0 +#, python-format +msgid "You cannot cancel a fiscal document that has not been posted before." +msgstr "No puede cancelar un documento fiscal que no haya sido posteado anteriormente." \ No newline at end of file diff --git a/l10n_do_accounting/models/account_move.py b/l10n_do_accounting/models/account_move.py index 07fe7eb55..5caa52223 100644 --- a/l10n_do_accounting/models/account_move.py +++ b/l10n_do_accounting/models/account_move.py @@ -479,6 +479,9 @@ def button_cancel(self): ): raise AccessError(_("You are not allowed to cancel Fiscal Invoices")) + if fiscal_invoice and not fiscal_invoice.posted_before: + raise ValidationError(_("You cannot cancel a fiscal document that has not been posted before.")) + if fiscal_invoice and not self.env.context.get("skip_cancel_wizard", False): action = self.env.ref( "l10n_do_accounting.action_account_move_cancel" diff --git a/l10n_do_accounting/views/account_move_views.xml b/l10n_do_accounting/views/account_move_views.xml index ac0fbbe1d..388d838f0 100644 --- a/l10n_do_accounting/views/account_move_views.xml +++ b/l10n_do_accounting/views/account_move_views.xml @@ -21,16 +21,6 @@ Notice. This company is in a transient state of contingency for Electronic Invoice issuing. NCF issuing has been enabled. - - { - 'invisible': ['|', '|', - ('id', '=', False), - '&', ('state', '!=', 'draft'), - ('country_code', '!=', 'DO'), - '&', ('state', 'in', ('draft', 'cancel')), - ('country_code', '=', 'DO')] - } - { 'invisible': ['|', '|',