[IMP] Multiple emails can be send, retry and cancel from the tree view

This commit is contained in:
Yusuf 2017-11-01 17:45:17 +05:30 committed by Siddharth Bhalgami
parent d3f4a54f93
commit 3590c60b50
4 changed files with 97 additions and 0 deletions

View File

@ -36,6 +36,7 @@
'views/ir_actions_views.xml',
'views/ir_model_views.xml',
'views/res_partner_views.xml',
'wizard/mass_mail.xml',
],
'demo': [
'data/mail_demo.xml',

View File

@ -5,3 +5,5 @@ from . import invite
from . import mail_compose_message
from . import email_template_preview
from . import base_module_uninstall
from . import mass_mail

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Part of Flectra. See LICENSE file for full copyright and licensing details.
from flectra import api, fields, models
class MassMail(models.TransientModel):
_name = 'mass.mail'
_description = 'Mass Mail Options'
message = fields.Char('Message')
@api.multi
def mass_emails(self):
send_method = self.env.context['mail']
active_ids = self.env.context['active_ids']
lines = self.env['mail.mail'].search([( 'id', 'in', active_ids)])
if send_method == 'mark_outgoing':
lines.mark_outgoing()
elif send_method == 'send':
lines.send()
elif send_method == 'cancel':
lines.cancel()

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<flectra>
<data>
<record id="view_mass_retry_mail_form" model="ir.ui.view">
<field name="name">mass.retry.mail.form</field>
<field name="model">mass.mail</field>
<field name="arch" type="xml">
<form string="Retry">
<h2>Are you sure?</h2>
<footer>
<span groups="base.group_user">
<button string="Yes" type="object"
name="mass_emails" class="oe_highlight"/>
or
<button special="cancel" string="No" type="object" />
</span>
</footer>
</form>
</field>
</record>
<act_window id="action_mass_retry_mail_view" multi="True"
context="{'mail': 'mark_outgoing'}"
name="Retry" res_model="mass.mail" src_model="mail.mail"
view_mode="form" target="new" view_type="form" />
<record id="view_mass_resend_mail_form" model="ir.ui.view">
<field name="name">mass.resend.mail.form</field>
<field name="model">mass.mail</field>
<field name="arch" type="xml">
<form string="Resend">
<h2>Are you sure?</h2>
<footer>
<span groups="base.group_user">
<button string="Yes" type="object"
name="mass_emails" class="oe_highlight"/>
or
<button special="cancel" string="No" type="object" />
</span>
</footer>
</form>
</field>
</record>
<act_window id="action_mass_resend_mail_view" multi="True"
context="{'mail': 'send'}"
name="Resend" res_model="mass.mail" src_model="mail.mail"
view_mode="form" target="new" view_type="form" />
<record id="view_mass_cancel_mail_form" model="ir.ui.view">
<field name="name">mass.cancel.mail.form</field>
<field name="model">mass.mail</field>
<field name="arch" type="xml">
<form string="Cancel">
<h2>Are you sure?</h2>
<footer>
<span groups="base.group_user">
<button string="Yes" type="object"
name="mass_emails" class="oe_highlight"/>
or
<button special="cancel" string="No" type="object" />
</span>
</footer>
</form>
</field>
</record>
<act_window id="action_mass_cancel_mail_view" multi="True"
context="{'mail': 'cancel'}"
name="Cancel" res_model="mass.mail" src_model="mail.mail"
view_mode="form" target="new" view_type="form" />
</data>
</flectra>