mirror of
https://github.com/bringout/oca-ocb-mail.git
synced 2026-04-21 02:02:02 +02:00
19.0 vanilla
This commit is contained in:
parent
5df8c07b59
commit
daa394e8b0
2114 changed files with 564841 additions and 299642 deletions
|
|
@ -18,17 +18,13 @@ class IrModel(models.Model):
|
|||
model.is_mailing_enabled = getattr(self.env[model.model], '_mailing_enabled', False)
|
||||
|
||||
def _search_is_mailing_enabled(self, operator, value):
|
||||
if operator not in ('=', '!='):
|
||||
raise ValueError(_("Searching Mailing Enabled models supports only direct search using '='' or '!='."))
|
||||
if operator not in ('in', 'not in'):
|
||||
return NotImplemented
|
||||
|
||||
valid_models = self.env['ir.model']
|
||||
for model in self.search([]):
|
||||
if model.model not in self.env or model.is_transient():
|
||||
continue
|
||||
if getattr(self.env[model.model], '_mailing_enabled', False):
|
||||
valid_models |= model
|
||||
valid_models = self.search([]).filtered(
|
||||
lambda model: model.model in self.env
|
||||
and not model.is_transient()
|
||||
and getattr(self.env[model.model], '_mailing_enabled', False)
|
||||
)
|
||||
|
||||
search_is_mailing_enabled = (operator == '=' and value) or (operator == '!=' and not value)
|
||||
if search_is_mailing_enabled:
|
||||
return [('id', 'in', valid_models.ids)]
|
||||
return [('id', 'not in', valid_models.ids)]
|
||||
return [('id', operator, valid_models.ids)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue