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

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()


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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..

Ảnh đại diện
Huỷ bỏ
Tác giả

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

yes and?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 20
4913
2
thg 3 15
3999
1
thg 10 22
1899
4
thg 10 20
72835
6
thg 12 19
17930