From e4c583fcc8f85a90236d2d2bcd57ba0b845ce3ad Mon Sep 17 00:00:00 2001 From: Julien Banken Date: Wed, 29 Sep 2021 08:22:14 +0000 Subject: [PATCH] [IMP] mail,sms: revamp the resend modals The error messages of the resend modals can be partially hidden in the table. The user can therefore have difficulty to understand what went wrong when the server failed to send an email or an sms. To avoid that, we will ensure that the error messages will be fully visible in the table. To improve the interface, we will also update the label of a some fields and we will automatically hide the 'Send & Close' buttons from the resend modals when the user did not select at least one recipient from the list. task-2523036 Part-of: odoo/odoo#71413 --- addons/mail/wizard/mail_resend_message.py | 19 +++++++++++------- .../mail/wizard/mail_resend_message_views.xml | 20 +++++++++---------- addons/sms/wizard/sms_resend.py | 19 +++++++++++------- addons/sms/wizard/sms_resend_views.xml | 17 ++++++++-------- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/addons/mail/wizard/mail_resend_message.py b/addons/mail/wizard/mail_resend_message.py index c54e91a01b6..411126f1362 100644 --- a/addons/mail/wizard/mail_resend_message.py +++ b/addons/mail/wizard/mail_resend_message.py @@ -12,12 +12,17 @@ class MailResendMessage(models.TransientModel): mail_message_id = fields.Many2one('mail.message', 'Message', readonly=True) partner_ids = fields.One2many('mail.resend.partner', 'resend_wizard_id', string='Recipients') notification_ids = fields.Many2many('mail.notification', string='Notifications', readonly=True) - has_cancel = fields.Boolean(compute='_compute_has_cancel') + can_cancel = fields.Boolean(compute='_compute_can_cancel') + can_resend = fields.Boolean(compute='_compute_can_resend') partner_readonly = fields.Boolean(compute='_compute_partner_readonly') @api.depends("partner_ids") - def _compute_has_cancel(self): - self.has_cancel = self.partner_ids.filtered(lambda p: not p.resend) + def _compute_can_cancel(self): + self.can_cancel = self.partner_ids.filtered(lambda p: not p.resend) + + @api.depends('partner_ids.resend') + def _compute_can_resend(self): + self.can_resend = any([partner.resend for partner in self.partner_ids]) def _compute_partner_readonly(self): self.partner_readonly = not self.env['res.partner'].check_access_rights('write', raise_exception=False) @@ -91,8 +96,8 @@ class PartnerResend(models.TransientModel): _description = 'Partner with additional information for mail resend' partner_id = fields.Many2one('res.partner', string='Partner', required=True, ondelete='cascade') - name = fields.Char(related="partner_id.name", related_sudo=False, readonly=False) - email = fields.Char(related="partner_id.email", related_sudo=False, readonly=False) - resend = fields.Boolean(string="Send Again", default=True) + name = fields.Char(related='partner_id.name', string='Recipient Name', related_sudo=False, readonly=False) + email = fields.Char(related='partner_id.email', string='Email Address', related_sudo=False, readonly=False) + resend = fields.Boolean(string='Try Again', default=True) resend_wizard_id = fields.Many2one('mail.resend.message', string="Resend wizard") - message = fields.Char(string="Help message") + message = fields.Char(string='Error message') diff --git a/addons/mail/wizard/mail_resend_message_views.xml b/addons/mail/wizard/mail_resend_message_views.xml index a6b2f41cd9f..6d8b884e8ca 100644 --- a/addons/mail/wizard/mail_resend_message_views.xml +++ b/addons/mail/wizard/mail_resend_message_views.xml @@ -9,31 +9,31 @@
- + -

Select the action to do on each mail and correct the email address if needed. The modified address will be saved on the corresponding contact.

- + -
-
- Resend mail + Sending Failures mail.resend.message ir.actions.act_window form diff --git a/addons/sms/wizard/sms_resend.py b/addons/sms/wizard/sms_resend.py index 804c3d19ba3..25882a91871 100644 --- a/addons/sms/wizard/sms_resend.py +++ b/addons/sms/wizard/sms_resend.py @@ -11,12 +11,12 @@ class SMSRecipient(models.TransientModel): sms_resend_id = fields.Many2one('sms.resend', required=True) notification_id = fields.Many2one('mail.notification', required=True, ondelete='cascade') - resend = fields.Boolean(string="Resend", default=True) + resend = fields.Boolean(string='Try Again', default=True) failure_type = fields.Selection( - related='notification_id.failure_type', related_sudo=True, readonly=True) + related='notification_id.failure_type', string='Error Message', related_sudo=True, readonly=True) partner_id = fields.Many2one('res.partner', 'Partner', related='notification_id.res_partner_id', readonly=True) - partner_name = fields.Char('Recipient', readonly='True') - sms_number = fields.Char('Number') + partner_name = fields.Char(string='Recipient Name', readonly='True') + sms_number = fields.Char(string='Phone Number') class SMSResend(models.TransientModel): @@ -40,7 +40,8 @@ class SMSResend(models.TransientModel): mail_message_id = fields.Many2one('mail.message', 'Message', readonly=True, required=True) recipient_ids = fields.One2many('sms.resend.recipient', 'sms_resend_id', string='Recipients') - has_cancel = fields.Boolean(compute='_compute_has_cancel') + can_cancel = fields.Boolean(compute='_compute_can_cancel') + can_resend = fields.Boolean(compute='_compute_can_resend') has_insufficient_credit = fields.Boolean(compute='_compute_has_insufficient_credit') has_unregistered_account = fields.Boolean(compute='_compute_has_unregistered_account') @@ -53,8 +54,12 @@ class SMSResend(models.TransientModel): self.has_insufficient_credit = self.recipient_ids.filtered(lambda p: p.failure_type == 'sms_credit') @api.depends("recipient_ids.resend") - def _compute_has_cancel(self): - self.has_cancel = self.recipient_ids.filtered(lambda p: not p.resend) + def _compute_can_cancel(self): + self.can_cancel = self.recipient_ids.filtered(lambda p: not p.resend) + + @api.depends('recipient_ids.resend') + def _compute_can_resend(self): + self.can_resend = any([recipient.resend for recipient in self.recipient_ids]) def _check_access(self): if not self.mail_message_id or not self.mail_message_id.model or not self.mail_message_id.res_id: diff --git a/addons/sms/wizard/sms_resend_views.xml b/addons/sms/wizard/sms_resend_views.xml index f9ce259bbec..3c70c37c4d4 100644 --- a/addons/sms/wizard/sms_resend_views.xml +++ b/addons/sms/wizard/sms_resend_views.xml @@ -7,29 +7,30 @@
- + - + -