Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4681 Zobrazení

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
Zrušit

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

Autor

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!

Related Posts Odpovědi Zobrazení Aktivita
5
čvc 20
10614
2
říj 15
10675
1
srp 24
6500
0
lis 21
2251
2
zář 21
3844