Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4693 มุมมอง

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!

        


อวตาร
ละทิ้ง

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

ผู้เขียน

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 ตอบกลับ มุมมอง กิจกรรม
Confirm on delete one2many line แก้ไขแล้ว
5
ก.ค. 20
10619
2
ต.ค. 15
10676
1
ส.ค. 24
6509
0
พ.ย. 21
2252
2
ก.ย. 21
3845