From 718a4e439881edfad8ba1aed59e3215c98aaaec2 Mon Sep 17 00:00:00 2001 From: Bruno Date: Mon, 29 Jul 2024 19:08:16 -0300 Subject: [PATCH] [ADD] edoc send email in move mixin --- l10n_br_account/models/document.py | 5 +++++ l10n_br_fiscal/models/document.py | 7 +------ l10n_br_fiscal/models/document_move_mixin.py | 7 +++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/l10n_br_account/models/document.py b/l10n_br_account/models/document.py index cdb14065c74a..d68b3f5c72f0 100644 --- a/l10n_br_account/models/document.py +++ b/l10n_br_account/models/document.py @@ -193,6 +193,11 @@ def action_document_back2draft(self): self.move_ids.button_draft() return result + def _edoc_subscribe(self): + if self.move_ids: + self.move_ids._edoc_subscribe() + return + def exec_after_SITUACAO_EDOC_DENEGADA(self, old_state, new_state): self.ensure_one() models_cancel_on_deny = [MODELO_FISCAL_NFE, MODELO_FISCAL_CTE] diff --git a/l10n_br_fiscal/models/document.py b/l10n_br_fiscal/models/document.py index f2957971ecf1..a2038460f4a0 100644 --- a/l10n_br_fiscal/models/document.py +++ b/l10n_br_fiscal/models/document.py @@ -505,12 +505,7 @@ def send_email(self): email_template_id = self._get_email_template() if email_template_id: - partner_ids = self.partner_id.filtered("edoc_send_email") - partner_child_ids = self.partner_id.child_ids.filtered("edoc_send_email") - all_partner_ids = partner_ids | partner_child_ids - - self.message_subscribe(partner_ids=all_partner_ids.ids) - + self._edoc_subscribe() attachment_ids = [] if self.authorization_file_id: attachment_ids.append(self.authorization_file_id.id) diff --git a/l10n_br_fiscal/models/document_move_mixin.py b/l10n_br_fiscal/models/document_move_mixin.py index 3b2daed1ef51..cc8c3d5d8188 100644 --- a/l10n_br_fiscal/models/document_move_mixin.py +++ b/l10n_br_fiscal/models/document_move_mixin.py @@ -259,3 +259,10 @@ def _onchange_fiscal_operation_id(self): ) self.document_subsequent_ids = subsequent_documents return result + + def _edoc_subscribe(self): + partner_ids = self.partner_id.filtered("edoc_send_email") + partner_child_ids = self.partner_id.child_ids.filtered("edoc_send_email") + all_partner_ids = partner_ids | partner_child_ids + + self.message_subscribe(partner_ids=all_partner_ids.ids)