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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
1
回复
14782
查看
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
Yes I know. I was asking if unlinking them all at once is better than one at a time.
相关帖文 | 回复 | 查看 | 活动 | |
---|---|---|---|---|
|
1
7月 18
|
4459 | ||
|
0
9月 15
|
4337 | ||
|
6
4月 15
|
7721 | ||
|
1
3月 15
|
6308 | ||
|
1
3月 15
|
364 |
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.