Hello, dears i want to make records to be unique and I did it by SQL constraints and it's worked well, and prevented me to make any duplication,
now I need to make a more advanced method, that will check the name while creating the record and search overall records so if I found it, should return an action with form view of the original record id
and here is what I had done.
testt = fields.Text(string="", compute='open_duplicates', required=False, )
@api.depends('name','id_num')
def open_duplicates(self):
duplicated = self.env['muk_dms.directory'].search([('name','=', self.name)])
if duplicated:
print('inn')
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'muk_dms. directory',
'target': 'current',
'res_id': duplicated.id,
'type': 'ir.actions.act_window',
}
else:
pass
now if I ityped a name which already exit the method runs and print the 'inn' but it is'nt return the action
so how can I do that ??
any help will be appreciated !!