Hi, everyone I'm trying to make a search wizard which will find records in res.partner based on our given condition. For example, I'm giving a value in CNIC field to search if the record exists on a button click it works correctly and find the existing record (if any) but it does not return the form of existing record it opens the new form always. Can anyone help me to return an existing form with all the values?
Here's my function:
def existing_record(self):
search = []
if self.cnic:
search.append(('cnic', '=', self.cnic))
else:
raise ValidationError(_("Please Enter CNIC."))
if search:
partner = self.env['res.partner'].search(search)
if not partner:
raise ValidationError(_("This member is not yet created. So, you can not see his details."))
return {
'name': 'Member Form',
'view_mode': 'form',
'res_model': 'res.partner',
'view_id': self.env.ref('real_estate.view_partner_form').id,
'domain': [('cnic','=',self.cnic)],
'context': {
"default_is_member": True,
},
'type': 'ir.actions.act_window',