Unlinking osv_memory wizards from memory in OpenERP

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.

3 thoughts on “Unlinking osv_memory wizards from memory in OpenERP

  1. Anonymous

    In OpenERP 6.1, that import statement gives me an error. Is that code designed for 6.0, or is there something else that I’m missing?

    Like your blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s