diff options
| author | dip-odoo <dip@odoo.com> | 2018-03-14 18:59:14 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-05-25 16:23:48 +0200 |
| commit | bbda48231cdfcb0a24af4febc7162fc57a1fc3b0 (patch) | |
| tree | cfe08f807f96a9510551a9e1691f1dfbda882b68 /addons/mass_mailing/wizard | |
| parent | 8db7869f4dddf899a0910c4509072efeb8b29563 (diff) | |
[IMP] mass_mailing: add schedule button that opens a wizard for scheduling date
Purpose of this commit is to re-arrange mass mailing buttons and to add
a button for scheduling mass mailing in future :
* add schedule date in debug mode;
* re-arrange all button;
* add schedule in future button and on click open wizard to schedule future
date;
* on 'send now' button remove the useless '|' in domain;
* add a small wizard to select the send date;
This commit is related to task ID 46932
Diffstat (limited to 'addons/mass_mailing/wizard')
| -rw-r--r-- | addons/mass_mailing/wizard/__init__.py | 1 | ||||
| -rw-r--r-- | addons/mass_mailing/wizard/mass_mailing_schedule_date.py | 22 | ||||
| -rw-r--r-- | addons/mass_mailing/wizard/mass_mailing_schedule_date_views.xml | 28 |
3 files changed, 51 insertions, 0 deletions
diff --git a/addons/mass_mailing/wizard/__init__.py b/addons/mass_mailing/wizard/__init__.py index 41ed9cc32f3..d501dfb411a 100644 --- a/addons/mass_mailing/wizard/__init__.py +++ b/addons/mass_mailing/wizard/__init__.py @@ -4,3 +4,4 @@ from . import test_mailing from . import mail_compose_message from . import mass_mailing_list_merge +from . import mass_mailing_schedule_date diff --git a/addons/mass_mailing/wizard/mass_mailing_schedule_date.py b/addons/mass_mailing/wizard/mass_mailing_schedule_date.py new file mode 100644 index 00000000000..428ee9c54e5 --- /dev/null +++ b/addons/mass_mailing/wizard/mass_mailing_schedule_date.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + + +class MassMailingScheduleDate(models.TransientModel): + _name = 'mass.mailing.schedule.date' + _description = 'Schedule in the Future' + + schedule_date = fields.Datetime(string='Schedule in the Future') + mass_mailing_id = fields.Many2one('mail.mass_mailing', required=True) + + @api.constrains('schedule_date') + def _check_schedule_date(self): + for scheduler in self: + if scheduler.schedule_date < fields.Datetime.now(): + raise ValidationError(_('Please select a date equal/or greater than the current date.')) + + def set_schedule_date(self): + self.mass_mailing_id.write({'schedule_date': self.schedule_date, 'state': 'in_queue'}) diff --git a/addons/mass_mailing/wizard/mass_mailing_schedule_date_views.xml b/addons/mass_mailing/wizard/mass_mailing_schedule_date_views.xml new file mode 100644 index 00000000000..b0e1aabe884 --- /dev/null +++ b/addons/mass_mailing/wizard/mass_mailing_schedule_date_views.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<odoo> + <record id="mass_mailing_schedule_date_view_form" model="ir.ui.view"> + <field name="name">mass.mailing.schedule.date.view.form</field> + <field name="model">mass.mailing.schedule.date</field> + <field name="arch" type="xml"> + <form string="Take Future Schedule Date"> + <group> + <group> + <field name="schedule_date" required="1"/> + </group> + </group> + <footer> + <button string="Schedule" name="set_schedule_date" type="object" class="btn-primary"/> + <button string="Discard " class="btn-default" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="mass_mailing_schedule_date_action" model="ir.actions.act_window"> + <field name="name">When do you want to send your mailing?</field> + <field name="res_model">mass.mailing.schedule.date</field> + <field name="type">ir.actions.act_window</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> +</odoo> |
