Files
odoo_source/addons/utm/models/utm.py
T
qmo-odoo a661b00015 [REF] utm,mass_mailing: replace mass mailing campaign by utm campaign
PURPOSE

This commit removes the mass_mailing.campaign model. Instead of having a fully
fledged model, we will simply inherit utm.campaign. We will also add relevant
statistics on utm campaign model in order to use it in various applications.

SPECIFICATIONS

This commit removes the mass_mailing.campaign model. Instead of having a fully
fledged model, we will simply inherit utm.campaign. This change implies that
mass_mailing.tag and mass_mailing.stage have to move to the utm model along
their associated views/data.

These changes were made so that campaigns could be used in the future
by social, mass_mailing and mass_sms and available in the same view

This commit also removes the source_id and the medium_id
fields on the campaign.

This commit also moves the unique_ab_testing field from the mass_mailing_campaign
to the mass_mailing model

Task ID: 2002029
PR: #34015
2019-08-02 12:32:35 +00:00

73 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, api, SUPERUSER_ID
class UtmMedium(models.Model):
# OLD crm.case.channel
_name = 'utm.medium'
_description = 'UTM Medium'
_order = 'name'
name = fields.Char(string='Medium Name', required=True)
active = fields.Boolean(default=True)
class UtmCampaign(models.Model):
# OLD crm.case.resource.type
_name = 'utm.campaign'
_description = 'UTM Campaign'
name = fields.Char(string='Campaign Name', required=True, translate=True)
user_id = fields.Many2one(
'res.users', string='Responsible',
required=True, default=lambda self: self.env.uid)
stage_id = fields.Many2one('utm.stage', string='Stage', ondelete='restrict', required=True,
default=lambda self: self.env['utm.stage'].search([], limit=1),
group_expand='_group_expand_stage_ids')
tag_ids = fields.Many2many(
'utm.tag', 'utm_tag_rel',
'tag_id', 'campaign_id', string='Tags')
is_website = fields.Boolean(default=False, help="Allows us to filter relevant Campaign")
color = fields.Integer(string='Color Index')
@api.model
def _group_expand_stage_ids(self, stages, domain, order):
""" Read group customization in order to display all the stages in the
kanban view, even if they are empty
"""
stage_ids = stages._search([], order=order, access_rights_uid=SUPERUSER_ID)
return stages.browse(stage_ids)
class UtmSource(models.Model):
_name = 'utm.source'
_description = 'UTM Source'
name = fields.Char(string='Source Name', required=True, translate=True)
class UtmStage(models.Model):
"""Stage for utm campaigns. """
_name = 'utm.stage'
_description = 'Campaign Stage'
_order = 'sequence'
name = fields.Char(required=True, translate=True)
sequence = fields.Integer()
class UtmTag(models.Model):
"""Model of categories of utm campaigns, i.e. marketing, newsletter, ... """
_name = 'utm.tag'
_description = 'UTM Tag'
_order = 'name'
name = fields.Char(required=True, translate=True)
color = fields.Integer(string='Color Index')
_sql_constraints = [
('name_uniq', 'unique (name)', "Tag name already exists !"),
]