By default osv_memory object is managed in memory instead of storing in database. So, if your system has lots of osv_memory wizards, then the system tends to slow down. So, this is how we explicitly remove them from memory.

from osv.orm import orm_memory

for model in self.pool.obj_list():
obj = self.pool.get(model)
if isinstance(obj, orm_memory):
obj.vaccum(cr, uid)

If you want to unlink only one object, then use-

obj = self.pool.get('object_name')
if isinstance(obj, orm_memory):
obj.vaccum(cr, uid)

Note- Make sure you put this code at the end to make sure unlink takes place after the task is done.

Advertisements