[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) <jpp@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<field name="is_email" />
|
||||
<b><label for="is_email"/></b>
|
||||
</div>
|
||||
<div class="text-left d-inline-block mr8" attrs="{'invisible': ['|', ('is_email','=', False), ('invoice_without_email', '=', False)]}">
|
||||
<field name="invoice_without_email" class="mr4"/>
|
||||
</div>
|
||||
<div name="mail_form" attrs="{'invisible': [('is_email', '=', False)]}">
|
||||
<!-- visible wizard -->
|
||||
<div attrs="{'invisible': [('composition_mode', '=', 'mass_mail')]}">
|
||||
|
||||
Reference in New Issue
Block a user