[REF] event: allow to use UTMs directly in event
PURPOSE Allow to use UTMs directly in event, notably to be able to sort or make statistics on registrations. SPECIFICATIONS Move all UTMs fields definition to event. In base event module they are set by hand or through links (when using mass mailing for example).Shared links with utm bits defined in it allows to track marketing statistics on registrations. In event_sale registrations can be linked to a sale order. UTM information are copied from the sale order to the registration itself. Order defined utm always erase default one coming from event. LINKS Task ID 2212297 Community PR odoo/odoo#47229 Related: odoo/upgrade#913 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -17,7 +17,7 @@ Key Features
|
||||
* Manage your Events and Registrations
|
||||
* Use emails to automatically confirm and send acknowledgments for any event registration
|
||||
""",
|
||||
'depends': ['base_setup', 'mail', 'portal'],
|
||||
'depends': ['base_setup', 'mail', 'portal', 'utm'],
|
||||
'data': [
|
||||
'security/event_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
|
||||
@@ -22,6 +22,10 @@ class EventRegistration(models.Model):
|
||||
event_ticket_id = fields.Many2one(
|
||||
'event.event.ticket', string='Event Ticket', readonly=True,
|
||||
states={'draft': [('readonly', False)]})
|
||||
# utm informations
|
||||
utm_campaign_id = fields.Many2one('utm.campaign', 'Campaign', index=True, ondelete='set null')
|
||||
utm_source_id = fields.Many2one('utm.source', 'Source', index=True, ondelete='set null')
|
||||
utm_medium_id = fields.Many2one('utm.medium', 'Medium', index=True, ondelete='set null')
|
||||
# attendee
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner', string='Contact',
|
||||
|
||||
@@ -563,6 +563,11 @@
|
||||
<field name="date_open" groups="base.group_no_one"/>
|
||||
<field name="date_closed" groups="base.group_no_one"/>
|
||||
</group>
|
||||
<group string="Marketing" name="utm_link" groups="base.group_no_one">
|
||||
<field name="utm_campaign_id"/>
|
||||
<field name="utm_medium_id"/>
|
||||
<field name="utm_source_id"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
|
||||
@@ -12,9 +12,27 @@ class EventRegistration(models.Model):
|
||||
# TDE FIXME: maybe add an onchange on sale_order_id
|
||||
sale_order_id = fields.Many2one('sale.order', string='Source Sales Order', ondelete='cascade')
|
||||
sale_order_line_id = fields.Many2one('sale.order.line', string='Sales Order Line', ondelete='cascade')
|
||||
campaign_id = fields.Many2one('utm.campaign', 'Campaign', related="sale_order_id.campaign_id", store=True)
|
||||
source_id = fields.Many2one('utm.source', 'Source', related="sale_order_id.source_id", store=True)
|
||||
medium_id = fields.Many2one('utm.medium', 'Medium', related="sale_order_id.medium_id", store=True)
|
||||
utm_campaign_id = fields.Many2one(compute='_compute_utm_campaign_id', copy=True, readonly=False, store=True)
|
||||
utm_source_id = fields.Many2one(compute='_compute_utm_source_id', copy=True, readonly=False, store=True)
|
||||
utm_medium_id = fields.Many2one(compute='_compute_utm_medium_id', copy=True, readonly=False, store=True)
|
||||
|
||||
@api.depends('sale_order_id')
|
||||
def _compute_utm_campaign_id(self):
|
||||
for registration in self:
|
||||
if registration.sale_order_id.campaign_id:
|
||||
registration.utm_campaign_id = registration.sale_order_id.campaign_id
|
||||
|
||||
@api.depends('sale_order_id')
|
||||
def _compute_utm_source_id(self):
|
||||
for registration in self:
|
||||
if registration.sale_order_id.source_id:
|
||||
registration.utm_source_id = registration.sale_order_id.source_id
|
||||
|
||||
@api.depends('sale_order_id')
|
||||
def _compute_utm_medium_id(self):
|
||||
for registration in self:
|
||||
if registration.sale_order_id.medium_id:
|
||||
registration.utm_medium_id = registration.sale_order_id.medium_id
|
||||
|
||||
def action_view_sale_order(self):
|
||||
action = self.env.ref('sale.action_orders').read()[0]
|
||||
|
||||
@@ -38,16 +38,11 @@
|
||||
<field name="is_paid" invisible="1"/>
|
||||
<widget name="web_ribbon" title="Paid" bg_color="bg-success" attrs="{'invisible': [('is_paid', '=', False)]}"/>
|
||||
</xpath>
|
||||
<group name="event" position="after">
|
||||
<group name="utm_link" position="before">
|
||||
<group string="Origin" groups="base.group_no_one">
|
||||
<field name="sale_order_id"/>
|
||||
<field name="sale_order_line_id" readonly="1" attrs="{'invisible': [('sale_order_id', '=', False)]}"/>
|
||||
</group>
|
||||
<group string="Marketing" name="utm_link" groups="base.group_no_one">
|
||||
<field name="campaign_id"/>
|
||||
<field name="medium_id"/>
|
||||
<field name="source_id"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user