Purpose ======= This commit cleans the UTM module and uses a different file for each model in order to clarify organization and ease reading. Each model belongs to its file. Task-2245823 Part-of: odoo/odoo#83070
26 lines
893 B
Python
26 lines
893 B
Python
# -*- 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 UserError
|
|
|
|
|
|
class UtmMedium(models.Model):
|
|
_name = 'utm.medium'
|
|
_description = 'UTM Medium'
|
|
_order = 'name'
|
|
|
|
name = fields.Char(string='Medium Name', required=True, translate=True)
|
|
active = fields.Boolean(default=True)
|
|
|
|
@api.ondelete(at_uninstall=False)
|
|
def _unlink_except_utm_medium_email(self):
|
|
utm_medium_email = self.env.ref('utm.utm_medium_email', raise_if_not_found=False)
|
|
if utm_medium_email and utm_medium_email in self:
|
|
raise UserError(_(
|
|
"The UTM medium '%s' cannot be deleted as it is used in some main "
|
|
"functional flows, such as the recruitment and the mass mailing.",
|
|
utm_medium_email.name
|
|
))
|