mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 19:31:59 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -1,25 +1,24 @@
|
|||
# -*- 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
|
||||
from odoo.fields import Domain
|
||||
|
||||
|
||||
class MailTemplate(models.Model):
|
||||
_inherit = 'mail.template'
|
||||
|
||||
@api.model
|
||||
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||
def _search(self, domain, *args, **kwargs):
|
||||
"""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 `args` in the `_name_search`
|
||||
key is set, we add our domain in the `domain` in the `_search`
|
||||
method to filtrate the mail templates.
|
||||
"""
|
||||
if self.env.context.get('filter_template_on_event'):
|
||||
args = expression.AND([[('model', '=', 'event.registration')], args])
|
||||
return super(MailTemplate, self)._name_search(name, args, operator, limit, name_get_uid)
|
||||
domain = Domain('model', '=', 'event.registration') & Domain(domain)
|
||||
return super()._search(domain, *args, **kwargs)
|
||||
|
||||
def unlink(self):
|
||||
res = super().unlink()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue