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

Sometimes I find myself looping through a browse() call and needing to delete a related object. Is it better to append the id to delete to a list and, after the loop, call unlink using the list? Or is just calling unlink each time, deleting a single record at a time, good enough?

Avatar
Abbandona

The unlink function used in openerp can be apply in the case of a list of records, Only thing is you have to pass the record ids you wish to delete as arguements in unlink method.

Risposta migliore

The unlink function used in openerp can be apply in the case of a list of records, Only thing is you have to pass the record ids you wish to delete as arguements in unlink method. But Be careful, once a record deleted cannot be retrieved.

self.pool.get('your.model.name').unlink(cr, uid, list_ids, context=context)

The above piece of code will help you to unlink your records. Thanks

Avatar
Abbandona
Autore

Yes I know. I was asking if unlinking them all at once is better than one at a time.

Post correlati Risposte Visualizzazioni Attività
1
lug 18
4461
0
set 15
4342
6
apr 15
7724
1
mar 15
6316
1
mar 15
364