diff options
| author | Thibault Delavallée <tde@odoo.com> | 2018-05-25 17:03:18 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-05-25 17:03:18 +0200 |
| commit | caa1ead00a2913c8e3010a8203b79189ed18259f (patch) | |
| tree | 56aa793f07d8547425b8ca81e067f00eb17f3c65 /addons/mass_mailing/wizard | |
| parent | 98fa196e00565ad211f63c4a10419027035d50b0 (diff) | |
| parent | bd4daccb9b42518c28bece8ee8e3000011de8568 (diff) | |
[MERGE] mass_mailing: improve action buttons and ease mass mailing scheduling
Purpose of this merge is to clearly distinguish sending a mass mailing from
scheduling it to a future date. Currently both options are a bit mixed and
not obvious. Now buttons are separated. Scheduling opens a small wizard
allowing to choose the date.
Some computation of sent and scheduled date are also fixed to be cleaner.
This merge is related to task ID 46932. Closes #24465.
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> |
