Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2984 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Auteur

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

yes and?

Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 20
4870
2
mrt. 15
3992
1
okt. 22
1889
4
okt. 20
72810
6
dec. 19
17895