From d488432af65a0825378d91e7b25d049b8aaad477 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Wed, 29 May 2019 12:34:02 +0000 Subject: [PATCH] [FIX] account: warning when sending invoice by email Before this commit, when sending multiples invoices by email in batch, if one of these invoices was for a customer without an email address, these wasn't sent and the user didn't have any feedback about this. Now, before the user send the emails a warning is shown with the list of invoices that can't be sent by email. opw-2002350 closes odoo/odoo#33753 Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/account/i18n/account.pot | 11 +++++++++++ addons/account/wizard/account_invoice_send.py | 17 +++++++++++++++++ .../wizard/account_invoice_send_views.xml | 3 +++ 3 files changed, 31 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 0bc13348c7e..b84d1711c52 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -9537,6 +9537,12 @@ msgstr "" msgid "The fiscal position determines the taxes/accounts used for this contact." msgstr "" +#. module: account +#: code:addons/account/wizard/account_invoice_send.py:59 +#, python-format +msgid "The following invoice(s) will not be sent by email, because the customers don't have email address." +msgstr "" + #. module: account #: code:addons/account/models/account.py:564 #, python-format @@ -11108,6 +11114,11 @@ msgstr "" msgid "have been reconciled automatically." msgstr "" +#. module: account +#: model:ir.model.fields,field_description:account.field_account_invoice_send__invoice_without_email +msgid "number of invoice(s) that will not be sent" +msgstr "" + #. module: account #. openerp-web #: code:addons/account/static/src/xml/account_reconciliation.xml:44 diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py index 54fbd7ff4be..e65b5f0ee89 100644 --- a/addons/account/wizard/account_invoice_send.py +++ b/addons/account/wizard/account_invoice_send.py @@ -11,6 +11,7 @@ class AccountInvoiceSend(models.TransientModel): _description = 'Account Invoice Send' is_email = fields.Boolean('Email', default=lambda self: self.env.user.company_id.invoice_is_email) + invoice_without_email = fields.Text(compute='_compute_invoice_without_email', string='invoice(s) that will not be sent') is_print = fields.Boolean('Print', default=lambda self: self.env.user.company_id.invoice_is_print) printed = fields.Boolean('Is Printed', default=False) invoice_ids = fields.Many2many('account.invoice', 'account_invoice_account_invoice_send_rel', string='Invoices') @@ -45,6 +46,22 @@ class AccountInvoiceSend(models.TransientModel): self.composer_id.template_id = self.template_id.id self.composer_id.onchange_template_id_wrapper() + @api.onchange('is_email') + def _compute_invoice_without_email(self): + for wizard in self: + if wizard.is_email and len(wizard.invoice_ids) > 1: + invoices = self.env['account.invoice'].search([ + ('id', 'in', self.env.context.get('active_ids')), + ('partner_id.email', '=', False) + ]) + if invoices: + wizard.invoice_without_email = "%s\n%s" % ( + _("The following invoice(s) will not be sent by email, because the customers don't have email address."), + "\n".join([i.reference for i in invoices]) + ) + else: + wizard.invoice_without_email = False + @api.multi def _send_email(self): if self.is_email: diff --git a/addons/account/wizard/account_invoice_send_views.xml b/addons/account/wizard/account_invoice_send_views.xml index 6052c1438d9..648dcdec65d 100644 --- a/addons/account/wizard/account_invoice_send_views.xml +++ b/addons/account/wizard/account_invoice_send_views.xml @@ -23,6 +23,9 @@ +
+ +