Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
4685 Näkymät

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
Hylkää

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

Tekijä

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!

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
5
heinäk. 20
10614
2
lokak. 15
10675
1
elok. 24
6500
0
marrask. 21
2251
2
syysk. 21
3844