콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3079 화면

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
5002
2
3월 15
4057
1
10월 22
1955
4
10월 20
72936
6
12월 19
18035