Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPD] account_invoice_auto_send_by_email: set is_mail always to True #1

Open
wants to merge 1 commit into
base: account-invoice-auto-send
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion account_invoice_auto_send_by_email/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import account_move
from . import account_invoice_send
15 changes: 0 additions & 15 deletions account_invoice_auto_send_by_email/models/account_invoice_send.py

This file was deleted.

11 changes: 9 additions & 2 deletions account_invoice_auto_send_by_email/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2023 Camptocamp SA
# Copyright 2023 Michael Tietz (MT Software) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import _, api, models
Expand All @@ -12,17 +13,23 @@ def cron_send_email_invoice(self):
for invoice in invoices:
description = "Send invoice {} by email".format(invoice.name)
invoice.with_delay(description=description)._execute_invoice_sent_wizard()

def _prepare_invoice_sent_wizard_vals(self):
return {"is_email": True, "composition_mode": "mass_mail"}

def _execute_invoice_sent_wizard(self, options=None):
self.ensure_one()
if self.is_move_sent:
return _("This invoice has already been sent.")
if self.transmit_method_code != "mail":
return _("This invoice should not send by mail")
res = self.action_invoice_sent()
wiz_ctx = res["context"] or {}
wiz_ctx["active_model"] = self._name
wiz_ctx["active_ids"] = self.ids
wiz = self.env["account.invoice.send"].with_context(**wiz_ctx).create({})
wiz.write(wiz._get_ui_options())
wiz = self.env["account.invoice.send"].with_context(**wiz_ctx).create(
self._prepare_invoice_sent_wizard_vals()
)
return wiz.send_and_print_action()

@api.model
Expand Down