Odoo Help


Odoo 8 -Browse a model in Object Class

on 6/22/16, 5:56 AM 1,676 views

I have Object class and i need to browse the model document.directory in this class. I tried this.

class node_database(object):

   print'obj',obj # it ptints document.directory
   print'datas',datas # Here nothing print

and also tried this:

  osv_pool = pooler.get_pool(dbname)

Thnks Ajeng for your reply. I tried this :

dir_obj = pooler.get_pool(dbname).get('document.directory')


print'document_id',document_id #It prints correct value

document_data=dir_obj.browse(cr,uid,document_id) #not get into browse function

print'document_data',document_data #not print

on 6/23/16, 6:48 AM

Getting this Error:

2016-06-24 06:41:52,690 9427 ERROR dms1 openerp.addons.document_ftp.ftpserver: Traceback (most recent call last):

File "/home/kabeer/odoo-8.0-20151229/openerp/addons/document_ftp/ftpserver/ftpserver.py", line 1806, in try_as_current_user

re=self.run_as_current_user(function, *args, **kwargs)

File "/home/kabeer/odoo-8.0-20151229/openerp/addons/document_ftp/ftpserver/ftpserver.py", line 1779, in run_as_current_user

return function(*args, **kwargs)

File "/home/kabeer/odoo-8.0-20151229/openerp/addons/document_ftp/ftpserver/abstracted_fs.py", line 509, in get_list_dir

listing = self.listdir(datacr)

File "/home/kabeer/odoo-8.0-20151229/openerp/addons/document_ftp/ftpserver/abstracted_fs.py", line 377, in listdir

res = node.children(cr)

File "/home/kabeer/odoo-8.0-20151229/openerp/addons/document/document.py", line 981, in children

res = self._child_get(cr, domain=domain) + self._file_get(cr)

File "/home/kabeer/odoo-8.0-20151229/openerp/addons/document/document.py", line 1022, in _child_get

print'cntobj_search_read',cntobj.search_read(cr, uid,[('id','=',1)],['name'],context=ctx)

File "/home/kabeer/odoo-8.0-20151229/openerp/api.py", line 256, in wrapper

return old_api(self, *args, **kwargs)

File "/home/kabeer/odoo-8.0-20151229/openerp/models.py", line 5186, in search_read

result = self.read(cr, uid, record_ids, fields, context=read_ctx)

File "/home/kabeer/odoo-8.0-20151229/openerp/api.py", line 256, in wrapper

return old_api(self, *args, **kwargs)

File "/home/kabeer/odoo-8.0-20151229/openerp/models.py", line 3144, in read

records = self.browse(cr, user, ids, context)

File "/home/kabeer/odoo-8.0-20151229/openerp/api.py", line 256, in wrapper

return old_api(self, *args, **kwargs)

File "/home/kabeer/odoo-8.0-20151229/openerp/models.py", line 5266, in browse

return self._browse(Environment(cr, uid, context or {}), ids)

File "/home/kabeer/odoo-8.0-20151229/openerp/api.py", line 740, in __new__

env, envs = None, cls.envs

File "/home/kabeer/odoo-8.0-20151229/openerp/tools/func.py", line 109, in __get__

return self.fget.__get__(None, owner)()

File "/home/kabeer/odoo-8.0-20151229/openerp/api.py", line 713, in envs

return cls._local.environments

File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 71, in __getattr__

raise AttributeError(name)

AttributeError: environments

on 6/24/16, 2:45 AM
Ajeng Shilvie
On 6/23/16, 5:48 AM

Before u browse the other model, u have to make sure if there is some parameter that have to be search before u browse the model. such as :

document_search = self.pool.get('document.directory').search(cr,uid,[('field_name','=',condition)])

#after that u can browse like this
document_browse = self.pool.get('document.directory').browse(cr,uid,document_search)

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/22/16, 5:56 AM
Seen: 1676 times
Last updated: 6/23/16, 5:48 AM