| 1 |
from odoo import _, api, models, exceptions |
| 2 |
|
| 3 |
|
| 4 |
class UtmSource(models.Model): |
| 5 |
_inherit = 'utm.source' |
| 6 |
|
| 7 |
@api.ondelete(at_uninstall=False) |
| 8 |
def _unlink_except_utm_source_marketing_card(self): |
| 9 |
utm_source_marketing_card = self.env.ref('marketing_card.utm_source_marketing_card', raise_if_not_found=False) |
| 10 |
if utm_source_marketing_card and utm_source_marketing_card in self: |
| 11 |
raise exceptions.UserError(_( |
| 12 |
"The UTM source '%s' cannot be deleted as it is used to promote marketing cards campaigns.", |
| 13 |
utm_source_marketing_card.name |
| 14 |
)) |