After saving the child record with the parent ID as a reference, the parent ID should not appear in the Many2One field.
I have written the following code but it is not working. it is working in odoo 15 but not odoo 17
class CustomPreset(models.Model):
_name = 'custom.preset'
_inherit = ['mail.thread', 'mail.activity.mixin']
name = fields.Many2one('custompreset.master', string='Name')
rel_id = fields.One2many('custompreset.child', 'parent_field_id', string='Detail')
search_dp = fields.Char(string='Search')
@api.onchange('search_dp')
def onchange_test_domain_fiedl(self):
mini_rec = self.env['custom.preset'].search([]).name
available_ids = []
for i in mini_rec:
available_ids.append(i.id)
return {'domain': {'name': [('id', '!=', available_ids)]}}