When i check connection database using xmlrpc or jsonrpc the data will not update or be same before update but data in db updated so i will refresh browser for update ui data, how to fix it like example in test connection in outgoing email server
<buttonstring="Check API"name="check_api"type="object"class="btn-primary"attrs="{'invisible': [('selection_rpc', '==', 'local')]}"/>
def check_api(self):
host = self.fields_host
port = self.fields_port
db_name = self.fields_database
username = self.fields_username
password = self.fields_password
title = "Warning!"
message = "Database Disconnected, Please Check Username or Password!!"
type = 'warning'
try:
# if (self.selection_rpc == 'socketrpc'):
# odoo = odoorpc.ODOO(host, port=port)
# # # Login
# odoo.login(db_name, username, password)
# if (odoo.env.uid):
# title = "Success!"
# message = "Database Connected"
# type = 'success'
if (self.selection_rpc == 'xmlrpc'):
base_url = 'http://' + host + ':' + port + '/'
common = xmlrpc.client.ServerProxy(
'{}/xmlrpc/2/common'.format(base_url))
uid = common.authenticate(db_name, username, password, {})
if (uid):
title = "Success!"
message = "Database Connected"
type = 'success'
elif (self.selection_rpc == 'jsonrpc'):
url = "http://%s:%s/jsonrpc" % (host, port)
uid = self.call(url, "common", "login", db_name,
username, password)
if (uid):
title = "Success!"
message = "Database Connected"
type = 'success'
except Exception as e:
print("Except", str(e))
return False
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _(title),
'message': message,
'type': type,
'sticky': False
}
}
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ờ
1233
Lượt xem
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ýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
3
thg 8 25
|
2372 | ||
|
1
thg 5 25
|
2563 | ||
|
1
thg 4 25
|
3520 | ||
|
1
thg 4 25
|
4348 | ||
|
1
thg 4 25
|
1828 |