跳至內容
選單
此問題已被標幟
1 回覆
3021 瀏覽次數

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?

相關帖文 回覆 瀏覽次數 活動
1
6月 20
4926
2
3月 15
3999
1
10月 22
1903
4
10月 20
72841
6
12月 19
17943