Skip to Content
Menu
This question has been flagged
1 Reply
6443 Views

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


class node_database(object):

   obj=openerp.registry(cr.dbname).get('document.directory')
   print'obj',obj # it ptints document.directory
   datas=obj.browse(cr,uid,ids)
   print'datas',datas # Here nothing print

and also tried this:

  osv_pool = pooler.get_pool(dbname)
  dir_obj=osv_pool.get('document.directory')
Avatar
Discard
Author

Thnks Ajeng for your reply. I tried this :

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

document_id=dir_obj.search(cr,uid,[('id','=',ids[0])])

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

Author

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

Best Answer

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)

Avatar
Discard
Related Posts Replies Views Activity
2
May 20
5072
1
Mar 15
6446
2
Mar 15
3571
0
Mar 15
3541
1
Mar 15
6457