Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Odoo 8 -Browse a model in Object Class

Subscribe

Get notified when there's activity on this post

This question has been flagged
modelobjectclassbrowse
1 Reply
7918 Views
Avatar
Kabeer KB

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')
0
Avatar
Discard
Kabeer KB
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

Kabeer KB
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

Avatar
Ajeng Shilvie
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)

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Is there any object attribute called _description? Solved
model object attributes
Avatar
Avatar
2
May 20
7155
readonly access to specific fields
field model object
Avatar
Avatar
1
Mar 15
8799
How can i browse this m2m record? Solved
object browse_record browse
Avatar
Avatar
2
Mar 15
5091
osv.Model field that could store Python objects?
python model object
Avatar
0
Mar 15
5546
How to get the id from a browse_record?
id object browse_record browse
Avatar
Avatar
1
Mar 15
8304
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now