This question has been flagged

Hello,

Im trying to delete the current record in model a via the button from model b.


I'd tried to used unlink() .


model_b.py :

name = fields.Many2one('hr.employee')


The wizard button in model_b.py :

def del_rec(self):

    for rec in self:

        abc = self.env["model.a"]            

            xyz = abc.search([('name', '=', rec.name.id)])          

            xyz.unlink()


but it will delete all records in model_a.py .


So how to delete the current record in model_a.py from model_b.py ?


Please help!

Thank you!

        


Avatar
Discard

Hi,

Your xyz gives you one or more ids by matching the employee between model a and model b.

In this, which record of model a you mean as current record .?

Please be more specific or clear with your requirement

Author

Hi Karthikeyan,

Thank you for your answer. When creating the record in model_a.py, I used context to pass the name to the model_b.py. So now, to determine the current record, I think I just use this condition: Is the name in model_a.py the same as the name of model_b.py or not? If the names match, then delete the record. That's my idea, or can you please give me the example or idea to do that. Thank you!