[IMP] (mass_mailing_)event(_sms): adds send invitation button on event form
PURPOSE Integrate the mass_mailing feature to event in order to send an invitation to the event you organized. Task ID : 2093336 PR : #43420
This commit is contained in:
@@ -220,7 +220,7 @@ class EventEvent(models.Model):
|
||||
@api.depends('date_end', 'seats_available', 'seats_availability', 'event_ticket_ids.sale_available')
|
||||
def _compute_event_registrations_open(self):
|
||||
for event in self:
|
||||
event.event_registrations_open = (event.date_end > fields.Datetime.now()) and \
|
||||
event.event_registrations_open = event.date_end and (event.date_end > fields.Datetime.now()) and \
|
||||
(event.seats_available or event.seats_availability == 'unlimited') and \
|
||||
(not event.event_ticket_ids or any(ticket.sale_available for ticket in event.event_ticket_ids))
|
||||
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo import models, _
|
||||
|
||||
|
||||
class Event(models.Model):
|
||||
_inherit = "event.event"
|
||||
|
||||
def action_mass_mailing_attendees(self):
|
||||
mass_mailing_action = dict(
|
||||
name='Mass Mail Attendees',
|
||||
type='ir.actions.act_window',
|
||||
res_model='mailing.mailing',
|
||||
view_mode='form',
|
||||
target='current',
|
||||
context=dict(
|
||||
default_mailing_model_id=self.env.ref('event.model_event_registration').id,
|
||||
default_mailing_domain=repr([('event_id', 'in', self.ids)])
|
||||
),
|
||||
)
|
||||
return mass_mailing_action
|
||||
return {
|
||||
'name': 'Mass Mail Attendees',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'mailing.mailing',
|
||||
'view_mode': 'form',
|
||||
'target': 'current',
|
||||
'context': {
|
||||
'default_mailing_model_id': self.env.ref('event.model_event_registration').id,
|
||||
'default_mailing_domain': repr([('event_id', 'in', self.ids)])
|
||||
},
|
||||
}
|
||||
|
||||
def action_invite_contacts(self):
|
||||
return {
|
||||
'name': 'Mass Mail Invitation',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'mailing.mailing',
|
||||
'view_mode': 'form',
|
||||
'target': 'current',
|
||||
'context': {'default_mailing_model_id': self.env.ref('base.model_res_partner').id},
|
||||
}
|
||||
|
||||
@@ -3,10 +3,15 @@
|
||||
<record id="event_event_view_form_inherit_mass_mailing" model="ir.ui.view">
|
||||
<field name="name">event.event.view.form.inherit.mass.mailing</field>
|
||||
<field name="model">event.event</field>
|
||||
<field name="priority" eval="15"/>
|
||||
<field name="priority" eval="4"/>
|
||||
<field name="inherit_id" ref="event.view_event_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='stage_id']" position="before">
|
||||
<field name="event_registrations_open" invisible="1"/>
|
||||
<button name="action_invite_contacts" type="object" string="Invite"
|
||||
class="btn btn-primary" attrs="{'invisible': [('event_registrations_open', '=', False)]}"/>
|
||||
<button name="action_invite_contacts" type="object" string="Invite"
|
||||
class="btn btn-secondary" attrs="{'invisible': [('event_registrations_open', '=', True)]}"/>
|
||||
<button name="action_mass_mailing_attendees" string="Contact Attendees" type="object" attrs="{'invisible': [('seats_expected', '=', 0)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -12,3 +12,9 @@ class Event(models.Model):
|
||||
action = super(Event, self).action_mass_mailing_attendees()
|
||||
action['view_id'] = self.env.ref('mass_mailing_sms.mailing_mailing_view_form_mixed').id
|
||||
return action
|
||||
|
||||
def action_invite_contacts(self):
|
||||
# Minimal override: set form view being the one mixing sms and mail (not prioritized one)
|
||||
action = super(Event, self).action_invite_contacts()
|
||||
action['view_id'] = self.env.ref('mass_mailing_sms.mailing_mailing_view_form_mixed').id
|
||||
return action
|
||||
|
||||
Reference in New Issue
Block a user