I installed odoo 10 in Ubuntu 16.04, I have 2 databases at the same server, I like to create a module that access data from table in another database, how I can do that? Thanks for your 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 management
- MRP
This question has been flagged
1
Reply
4141
Views
You can do it by creating a new environment for another database.
Refer following sample code:
from odoo import api, models, registry, SUPERUSER_ID
class my_class(models.Model):
@api.multi
def get_data_from_database(self):
with registry('another_database_name') as new_cr:
env = api.Environment(new_cr, SUPERUSER_ID, {})
partner = env['res.partner'].search([('name', '=', 'ERP HARBOR CONSULTING SERVICES')], limit=1)
print partner.name, partner.phone
Hope this will help you.
Sudhir Arya ERP Harbor Consulting Services skype: sudhir@erpharbor.com website: http://www.erpharbor.com
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