Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4691 Lượt xem

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!

        


Ảnh đại diện
Huỷ bỏ

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

Tác giả

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!

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 7 20
10619
2
thg 10 15
10676
1
thg 8 24
6509
0
thg 11 21
2252
2
thg 9 21
3845