[REF] mail, sms: perform some guidelining (file move) and rename SMS composer model
Purpose is to prepare future improvements in mail and SMS module. In this
commit we apply some guidelines on XML Ids and file naming.
In mail cancel wizard code is separated from the resend one as they have
nothing in common.
More importantly ``sms.send_sms`` model is renamed to ``sms.composer`` to
avoid underscores (which is really really bad, take a look at
ir.config_parameter) and have a meaningful name.
Related to task 1922163
Linked to PR #34516
Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
This commit is contained in:
co-authored by
Pierre Rousseau
parent
657adbe482
commit
566244b47b
@@ -5,7 +5,7 @@
|
||||
<act_window id="sms_message_send_action_mutli"
|
||||
name="Send SMS to attendees"
|
||||
binding_model="calendar.event"
|
||||
res_model="sms.send_sms"
|
||||
res_model="sms.composer"
|
||||
view_mode="form"
|
||||
target="new"/>
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ Please, take appropriate measures in order to carry out this work absence.
|
||||
Do not hesitate to contact your manager or the human resource department.""")
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "sms.send_sms",
|
||||
"res_model": "sms.composer",
|
||||
"view_mode": 'form',
|
||||
"context": {
|
||||
'active_id': self.id,
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
'data': [
|
||||
'wizard/invite_view.xml',
|
||||
'wizard/mail_compose_message_view.xml',
|
||||
'wizard/mail_resend_cancel_views.xml',
|
||||
'wizard/mail_resend_message_views.xml',
|
||||
'views/mail_message_subtype_views.xml',
|
||||
'views/mail_tracking_views.xml',
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
from . import invite
|
||||
from . import mail_compose_message
|
||||
from . import mail_resend_cancel
|
||||
from . import mail_resend_message
|
||||
from . import email_template_preview
|
||||
from . import base_module_uninstall
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class MailCancelResend(models.TransientModel):
|
||||
_name = 'mail.resend.cancel'
|
||||
_description = 'Dismiss notification for resend by model'
|
||||
|
||||
model = fields.Char(string='Model')
|
||||
help_message = fields.Char(string='Help message', compute='_compute_help_message')
|
||||
|
||||
@api.multi
|
||||
@api.depends('model')
|
||||
def _compute_help_message(self):
|
||||
for wizard in self:
|
||||
wizard.help_message = _("Are you sure you want to discard %s mail delivery failures. You won't be able to re-send these mails later!") % (wizard._context.get('unread_counter'))
|
||||
|
||||
@api.multi
|
||||
def cancel_resend_action(self):
|
||||
author_id = self.env.user.partner_id.id
|
||||
for wizard in self:
|
||||
self._cr.execute("""
|
||||
SELECT notif.id, mes.id
|
||||
FROM mail_message_res_partner_needaction_rel notif
|
||||
JOIN mail_message mes
|
||||
ON notif.mail_message_id = mes.id
|
||||
WHERE notif.email_status IN ('bounce', 'exception')
|
||||
AND mes.model = %s
|
||||
AND mes.author_id = %s
|
||||
""", (wizard.model, author_id))
|
||||
res = self._cr.fetchall()
|
||||
notif_ids = [row[0] for row in res]
|
||||
messages_ids = list(set([row[1] for row in res]))
|
||||
if notif_ids:
|
||||
self.env["mail.notification"].browse(notif_ids).sudo().write({'email_status': 'canceled'})
|
||||
self.env["mail.message"].browse(messages_ids)._notify_failure_update()
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo><data>
|
||||
<record id="mail_resend_cancel_view_form" model="ir.ui.view">
|
||||
<field name="name">mail.resend.cancel.view.form</field>
|
||||
<field name="model">mail.resend.cancel</field>
|
||||
<field name="groups_id" eval="[(4,ref('base.group_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cancel notification in failure">
|
||||
<field name="model" invisible='1'/>
|
||||
<field name="help_message"/>
|
||||
<p>If you want to re-send them, click Cancel now, then click on the notification and review them one by one by clicking on the red envelope next to each message.</p>
|
||||
<img src="/mail/static/img/red_envelope.png" alt="Envelope Example"/>
|
||||
<footer>
|
||||
<button string="Discard delivery failures" name="cancel_resend_action" type="object" class="btn-primary" />
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="mail_resend_cancel_action" model="ir.actions.act_window">
|
||||
<field name="name">Discard mail delivery failures</field>
|
||||
<field name="res_model">mail.resend.cancel</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</data></odoo>
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from ast import literal_eval
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class MailResendMessage(models.TransientModel):
|
||||
_name = 'mail.resend.message'
|
||||
_description = 'Email resend wizard'
|
||||
@@ -100,38 +100,3 @@ class PartnerResend(models.TransientModel):
|
||||
resend = fields.Boolean(string="Send Again", default=True)
|
||||
resend_wizard_id = fields.Many2one('mail.resend.message', string="Resend wizard")
|
||||
message = fields.Char(string="Help message")
|
||||
|
||||
|
||||
class MailCancelResend(models.TransientModel):
|
||||
_name = 'mail.resend.cancel'
|
||||
_description = 'Dismiss notification for resend by model'
|
||||
|
||||
model = fields.Char(string='Model')
|
||||
help_message = fields.Char(string='Help message', compute='_compute_help_message')
|
||||
|
||||
@api.multi
|
||||
@api.depends('model')
|
||||
def _compute_help_message(self):
|
||||
for wizard in self:
|
||||
wizard.help_message = _("Are you sure you want to discard %s mail delivery failures. You won't be able to re-send these mails later!") % (wizard._context.get('unread_counter'))
|
||||
|
||||
@api.multi
|
||||
def cancel_resend_action(self):
|
||||
author_id = self.env.user.partner_id.id
|
||||
for wizard in self:
|
||||
self._cr.execute("""
|
||||
SELECT notif.id, mes.id
|
||||
FROM mail_message_res_partner_needaction_rel notif
|
||||
JOIN mail_message mes
|
||||
ON notif.mail_message_id = mes.id
|
||||
WHERE notif.email_status IN ('bounce', 'exception')
|
||||
AND mes.model = %s
|
||||
AND mes.author_id = %s
|
||||
""", (wizard.model, author_id))
|
||||
res = self._cr.fetchall()
|
||||
notif_ids = [row[0] for row in res]
|
||||
messages_ids = list(set([row[1] for row in res]))
|
||||
if notif_ids:
|
||||
self.env["mail.notification"].browse(notif_ids).sudo().write({'email_status': 'canceled'})
|
||||
self.env["mail.message"].browse(messages_ids)._notify_failure_update()
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="mail_resend_message_view_form" model="ir.ui.view">
|
||||
<field name="name">mail.resend.message.form</field>
|
||||
<field name="name">mail.resend.message.view.form</field>
|
||||
<field name="model">mail.resend.message</field>
|
||||
<field name="groups_id" eval="[(4,ref('base.group_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
@@ -31,23 +31,6 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="mail_resend_cancel_view_form" model="ir.ui.view">
|
||||
<field name="name">mail.resend.cancel.form</field>
|
||||
<field name="model">mail.resend.cancel</field>
|
||||
<field name="groups_id" eval="[(4,ref('base.group_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cancel notification in failure">
|
||||
<field name="model" invisible='1'/>
|
||||
<field name="help_message"/>
|
||||
<p>If you want to re-send them, click Cancel now, then click on the notification and review them one by one by clicking on the red envelope next to each message.</p>
|
||||
<img src="/mail/static/img/red_envelope.png" alt="Envelope Example"/>
|
||||
<footer>
|
||||
<button string="Discard delivery failures" name="cancel_resend_action" type="object" class="btn-primary" />
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="mail_resend_message_action" model="ir.actions.act_window">
|
||||
<field name="name">Resend mail</field>
|
||||
<field name="res_model">mail.resend.message</field>
|
||||
@@ -55,13 +38,5 @@
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<record id="mail_resend_cancel_action" model="ir.actions.act_window">
|
||||
<field name="name">Discard mail delivery failures</field>
|
||||
<field name="res_model">mail.resend.cancel</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -12,10 +12,10 @@ The service is provided by the In App Purchase Odoo platform.
|
||||
""",
|
||||
'depends': ['base', 'iap', 'mail'],
|
||||
'data': [
|
||||
'wizard/send_sms_views.xml',
|
||||
'wizard/sms_composer_views.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'views/templates.xml',
|
||||
'views/assets.xml',
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/sms_widget.xml',
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<odoo>
|
||||
|
||||
<!-- Add action entry in the Action Menu for Partners -->
|
||||
<record id="partner_form_send_sms_form_view" model="ir.ui.view">
|
||||
<field name="name">res.partner.form.send.sms</field>
|
||||
<record id="res_partner_view_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.view.form.inherit.sms</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="priority">10</field>
|
||||
@@ -14,7 +14,7 @@
|
||||
<field name="phone" widget="phone"/>
|
||||
<button
|
||||
type="action"
|
||||
name="%(sms.send_sms_form_action)d"
|
||||
name="%(sms.sms_composer_action_form)d"
|
||||
class="btn-sm btn-link mb4 fa fa-envelope-o"
|
||||
aria-label="Send SMS"
|
||||
title="Send SMS"
|
||||
@@ -29,7 +29,7 @@
|
||||
<field name="mobile" widget="phone"/>
|
||||
<button
|
||||
type="action"
|
||||
name="%(sms.send_sms_form_action)d"
|
||||
name="%(sms.sms_composer_action_form)d"
|
||||
class="btn-sm btn-link mb4 fa fa-envelope-o"
|
||||
aria-label="Send SMS"
|
||||
title="Send SMS"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import send_sms
|
||||
from . import sms_composer
|
||||
|
||||
@@ -23,7 +23,7 @@ except ImportError:
|
||||
|
||||
|
||||
class SendSMS(models.TransientModel):
|
||||
_name = 'sms.send_sms'
|
||||
_name = 'sms.composer'
|
||||
_description = 'Send SMS'
|
||||
|
||||
recipients = fields.Char('Recipients', required=True)
|
||||
@@ -1,9 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="send_sms_view_form" model="ir.ui.view">
|
||||
<field name="name">sms_send_sms.form</field>
|
||||
<field name="model">sms.send_sms</field>
|
||||
<record id="sms_composer_view_form" model="ir.ui.view">
|
||||
<field name="name">sms.composer.view.form</field>
|
||||
<field name="model">sms.composer</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send an SMS">
|
||||
<sheet>
|
||||
@@ -23,18 +22,18 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="send_sms_form_action" model="ir.actions.act_window">
|
||||
<record id="sms_composer_action_form" model="ir.actions.act_window">
|
||||
<field name="name">Send SMS</field>
|
||||
<field name="res_model">sms.send_sms</field>
|
||||
<field name="res_model">sms.composer</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- Add action entry in the Action Menu for Partners -->
|
||||
<act_window id="send_sms_action"
|
||||
<act_window id="sms_composer_act_window"
|
||||
name="Send SMS"
|
||||
binding_model="res.partner"
|
||||
res_model="sms.send_sms"
|
||||
res_model="sms.composer"
|
||||
view_mode="form"
|
||||
target="new"/>
|
||||
|
||||
Reference in New Issue
Block a user