From 313cdd1fa8d1d4776eec2bd9cd12d91db5f9ff52 Mon Sep 17 00:00:00 2001 From: Felipe Motter Pereira Date: Fri, 24 May 2024 08:22:01 -0300 Subject: [PATCH] [FIX] l10n_br_account: account move on fiscal wiz --- l10n_br_account/models/fiscal_document.py | 18 +++++++++++++ l10n_br_account/wizards/__init__.py | 4 --- l10n_br_account/wizards/base_wizard_mixin.py | 26 ------------------- .../wizards/wizard_document_cancel.py | 17 ------------ .../wizards/wizard_document_correction.py | 16 ------------ .../wizards/wizard_document_invalidate.py | 3 +-- 6 files changed, 19 insertions(+), 65 deletions(-) delete mode 100644 l10n_br_account/wizards/base_wizard_mixin.py delete mode 100644 l10n_br_account/wizards/wizard_document_cancel.py delete mode 100644 l10n_br_account/wizards/wizard_document_correction.py diff --git a/l10n_br_account/models/fiscal_document.py b/l10n_br_account/models/fiscal_document.py index 291b6838397c..5492890ef98d 100644 --- a/l10n_br_account/models/fiscal_document.py +++ b/l10n_br_account/models/fiscal_document.py @@ -160,3 +160,21 @@ def message_post(self, **kwargs): """ for doc in self: doc.move_ids.message_post(**kwargs) + + def cancel_move_ids(self): + for record in self: + if record.move_ids: + self.move_ids.button_cancel() + + def _document_cancel(self, justificative): + result = super()._document_cancel(justificative) + msg = "Cancelamento: {}".format(justificative) + self.cancel_move_ids() + self.message_post(body=msg) + return result + + def _document_correction(self, justificative): + result = super()._document_correction(justificative) + msg = "Carta de correção: {}".format(justificative) + self.message_post(body=msg) + return result diff --git a/l10n_br_account/wizards/__init__.py b/l10n_br_account/wizards/__init__.py index 95c845c9c39c..99c52aeddda4 100644 --- a/l10n_br_account/wizards/__init__.py +++ b/l10n_br_account/wizards/__init__.py @@ -1,8 +1,4 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from . import base_wizard_mixin - from . import account_move_reversal -from . import wizard_document_cancel -from . import wizard_document_correction from . import wizard_document_invalidate diff --git a/l10n_br_account/wizards/base_wizard_mixin.py b/l10n_br_account/wizards/base_wizard_mixin.py deleted file mode 100644 index 5a3ad00a135a..000000000000 --- a/l10n_br_account/wizards/base_wizard_mixin.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2020 Luis Felipe Mileo -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, fields, models - - -class BaseWizardMixin(models.TransientModel): - _inherit = "l10n_br_fiscal.base.wizard.mixin" - - move_id = fields.Many2one( - comodel_name="account.move", - string="Invoice", - ) - - @api.model - def default_get(self, fields_list): - default_values = super().default_get(fields_list) - if default_values.get("move_id"): - move_id = self.move_id.browse(default_values.get("move_id")) - default_values["document_id"] = move_id.fiscal_document_id.id - return default_values - - def _prepare_key_fields(self): - vals = super()._prepare_key_fields() - vals["account.move"] = "move_id" - return vals diff --git a/l10n_br_account/wizards/wizard_document_cancel.py b/l10n_br_account/wizards/wizard_document_cancel.py deleted file mode 100644 index 837de13bcc4e..000000000000 --- a/l10n_br_account/wizards/wizard_document_cancel.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) 2021 Renato Lima - Akretion -# Copyright (C) 2021 Luis Felipe Mileo - KMEE -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models - - -class DocumentCancelWizard(models.TransientModel): - _inherit = "l10n_br_fiscal.document.cancel.wizard" - - def do_cancel(self): - result = super().do_cancel() - if self.move_id: - self.move_id.button_cancel() - msg = "Cancelamento: {}".format(self.justification) - self.move_id.message_post(body=msg) - return result diff --git a/l10n_br_account/wizards/wizard_document_correction.py b/l10n_br_account/wizards/wizard_document_correction.py deleted file mode 100644 index 3eeb2021798e..000000000000 --- a/l10n_br_account/wizards/wizard_document_correction.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2021 Raphaël Valyi - Akretion -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models - - -class DocumentCorrectionWizard(models.TransientModel): - _inherit = "l10n_br_fiscal.document.correction.wizard" - - def doit(self): - result = super().doit() - for wizard in self: - if wizard.move_id: - msg = "Carta de correção: {}".format(wizard.justification) - self.move_id.message_post(body=msg) - return result diff --git a/l10n_br_account/wizards/wizard_document_invalidate.py b/l10n_br_account/wizards/wizard_document_invalidate.py index 7ce86ad0919c..38b5c57e8d70 100644 --- a/l10n_br_account/wizards/wizard_document_invalidate.py +++ b/l10n_br_account/wizards/wizard_document_invalidate.py @@ -9,6 +9,5 @@ class InvalidateNumberWizard(models.TransientModel): def do_invalidate(self): result = super().do_invalidate() - if self.move_id: - self.move_id.button_cancel() + self.document_id.cancel_move_ids() return result