Skip to Content
Menú
This question has been flagged
1 Respondre
2982 Vistes

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


Avatar
Descartar
Best Answer

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

Avatar
Descartar
Autor

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

yes and?

Related Posts Respostes Vistes Activitat
1
de juny 20
4867
2
de març 15
3990
1
d’oct. 22
1887
4
d’oct. 20
72809
6
de des. 19
17883