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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
4435
Lượt xem
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
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký