Files
odoo_source/addons/event/models/mail_template.py
T
Rémy Voet (ryv) 302c7baa87 [REM] core,*: remove name_get_uid parameter from _name_search.
`name_get_uid` is unused (at least since v14) and the
documentation about it, is wrong.

closes odoo/odoo#117819

Related: odoo/enterprise#39483
Signed-off-by: Rémy Voet <ryv@odoo.com>
2023-04-28 16:04:27 +02:00

23 lines
982 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
from odoo.osv import expression
class MailTemplate(models.Model):
_inherit = 'mail.template'
@api.model
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
"""Context-based hack to filter reference field in a m2o search box to emulate a domain the ORM currently does not support.
As we can not specify a domain on a reference field, we added a context
key `filter_template_on_event` on the template reference field. If this
key is set, we add our domain in the `domain` in the `_name_search`
method to filtrate the mail templates.
"""
if self.env.context.get('filter_template_on_event'):
domain = expression.AND([[('model', '=', 'event.registration')], domain])
return super()._name_search(name, domain, operator, limit, order)