diff --git a/l10n_br_fiscal/__manifest__.py b/l10n_br_fiscal/__manifest__.py index 998e94370538..5c216a2071b3 100644 --- a/l10n_br_fiscal/__manifest__.py +++ b/l10n_br_fiscal/__manifest__.py @@ -21,7 +21,6 @@ "security/ir.model.access.csv", # Data # Some data is being loaded via post_init_hook in hook file - "data/l10n_br_fiscal_email_template.xml", "data/l10n_br_fiscal_data.xml", "data/uom_data.xml", "data/uom_alternative_data.xml", @@ -62,7 +61,6 @@ "views/product_genre_view.xml", "views/document_type_view.xml", "views/document_serie_view.xml", - "views/document_email_view.xml", "views/simplified_tax_view.xml", "views/simplified_tax_range_view.xml", "views/operation_view.xml", diff --git a/l10n_br_fiscal/hooks.py b/l10n_br_fiscal/hooks.py index c1b0ae474d87..5ba390c0b053 100644 --- a/l10n_br_fiscal/hooks.py +++ b/l10n_br_fiscal/hooks.py @@ -55,7 +55,6 @@ def post_init_hook(cr, registry): "demo/fiscal_document_nfse_demo.xml", "demo/fiscal_operation_demo.xml", "demo/subsequent_operation_demo.xml", - "demo/l10n_br_fiscal_document_email.xml", "demo/res_users_demo.xml", "demo/icms_tax_definition_demo.xml", ] diff --git a/l10n_br_fiscal/models/document.py b/l10n_br_fiscal/models/document.py index 58e72ef08323..51935ba8f3c5 100644 --- a/l10n_br_fiscal/models/document.py +++ b/l10n_br_fiscal/models/document.py @@ -404,36 +404,6 @@ def action_create_return(self): return action - def _get_email_template(self, state): - self.ensure_one() - return self.document_type_id.document_email_ids.search( - [ - "|", - ("state_edoc", "=", False), - ("state_edoc", "=", state), - ("issuer", "=", self.issuer), - "|", - ("document_type_id", "=", False), - ("document_type_id", "=", self.document_type_id.id), - ], - limit=1, - order="state_edoc, document_type_id", - ).mapped("email_template_id") - - def send_email(self, state): - self.ensure_one() - email_template = self._get_email_template(state) - if email_template: - email_template.with_context( - default_attachment_ids=self._get_mail_attachment() - ).send_mail(self.id) - - def _after_change_state(self, old_state, new_state): - self.ensure_one() - result = super()._after_change_state(old_state, new_state) - self.send_email(new_state) - return result - @api.onchange("fiscal_operation_id") def _onchange_fiscal_operation_id(self): result = super()._onchange_fiscal_operation_id() @@ -510,46 +480,3 @@ def cancel_edoc(self): "associated documents have already been authorized." ) raise UserWarning(message) - - def _get_mail_attachment(self): - self.ensure_one() - attachment_ids = [] - if self.state_edoc == SITUACAO_EDOC_AUTORIZADA: - if self.file_report_id: - attachment_ids.append(self.file_report_id.id) - if self.authorization_file_id: - attachment_ids.append(self.authorization_file_id.id) - return attachment_ids - - def action_send_email(self): - """Open a window to compose an email, with the fiscal document_type - template message loaded by default - """ - self.ensure_one() - template = self._get_email_template(self.state) - compose_form = self.env.ref("mail.email_compose_message_wizard_form", False) - lang = self.env.context.get("lang") - if template and template.lang: - lang = template._render_template(template.lang, self._name, [self.id]) - self = self.with_context(lang=lang) - ctx = dict( - default_model="l10n_br_fiscal.document", - default_res_id=self.id, - default_use_template=bool(template), - default_attachment_ids=self._get_mail_attachment(), - default_template_id=template and template.id or False, - default_composition_mode="comment", - model_description=self.document_type_id.name or self._name, - force_email=True, - ) - return { - "name": _("Send Fiscal Document Email Notification"), - "type": "ir.actions.act_window", - "view_type": "form", - "view_mode": "form", - "res_model": "mail.compose.message", - "views": [(compose_form.id, "form")], - "view_id": compose_form.id, - "target": "new", - "context": ctx, - } diff --git a/l10n_br_fiscal/views/document_view.xml b/l10n_br_fiscal/views/document_view.xml index b18079200a01..5ac1ffe7f087 100644 --- a/l10n_br_fiscal/views/document_view.xml +++ b/l10n_br_fiscal/views/document_view.xml @@ -171,13 +171,13 @@ groups="l10n_br_fiscal.group_user" attrs="{'invisible': [('state_edoc', '!=', 'autorizada')]}" /> -