Skip to content

Commit

Permalink
Fix: No se podia buscar un campo vacio
Browse files Browse the repository at this point in the history
  • Loading branch information
joanperez1 committed Nov 30, 2023
1 parent 47e86ae commit fe4ae22
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,25 @@ def _get_model_data_name_search(
if not arg:
return [('id', '=', 0)]
else:
model_data_obj = self.pool.get('ir.model.data')
ids_model_data = model_data_obj.search(cursor, uid, [
('name', 'ilike', arg[0][2])
], context=context)
records = model_data_obj.read(cursor, uid, ids_model_data, ['id', 'res_id'], context=context)
res_ids = [record['res_id'] for record in records]
return [('id', 'in', res_ids)]
if arg[0][2]:
model_data_obj = self.pool.get('ir.model.data')
ids_model_data = model_data_obj.search(cursor, uid, [
('name', 'ilike', arg[0][2]),
('model', '=', 'poweremail.templates')
], context=context)
records = model_data_obj.read(cursor, uid, ids_model_data,
['id', 'res_id'], context=context)
res_ids = [record['res_id'] for record in records]
return [('id', 'in', res_ids)]
else:
model_data_obj = self.pool.get('ir.model.data')
ids_model_data = model_data_obj.search(cursor, uid, [
('model', '=', 'poweremail.templates')
], context=context)
records = model_data_obj.read(cursor, uid, ids_model_data,
['id', 'res_id'], context=context)
res_ids = [record['res_id'] for record in records]
return [('id', 'not in', res_ids)]

_columns = {
'name': fields.char('Name of Template', size=100, required=True),
Expand Down

0 comments on commit fe4ae22

Please sign in to comment.