Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3012 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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

yes and?

Post correlati Risposte Visualizzazioni Attività
1
giu 20
4900
2
mar 15
3995
1
ott 22
1896
4
ott 20
72834
6
dic 19
17928