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

i want to delete all products and leave products which is reference to another model.

@api.multi
def unlink(self):
for prod in self:
super(ProductProduct, prod).unlink()


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

b

lets say your product have relation to model example.example which is named in your product model example_id then you need to check if the example_id is null or not by this:

@api.multi
def unlink(self):
for prod in self:
        if not prod.example_id:
            super(ProductProduct, self).unlink()

but as far as i know product.product model is important model.. which is the original product.product model has many relations to another model..

อวตาร
ละทิ้ง
ผู้เขียน

product_id is foreign key in (sales.order.line or purchase.order.line ) not the opposite

yes and?

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 20
4883
2
มี.ค. 15
3994
1
ต.ค. 22
1891
4
ต.ค. 20
72819
6
ธ.ค. 19
17911