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
- Bogføring
- Lager
- PoS
- Project
- MRP
Dette spørgsmål er blevet anmeldt
1232
Visninger
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Tilmeld digRelated Posts | Besvarelser | Visninger | Aktivitet | |
---|---|---|---|---|
|
3
aug. 25
|
2372 | ||
|
1
maj 25
|
2563 | ||
|
1
apr. 25
|
3520 | ||
|
1
apr. 25
|
4348 | ||
|
1
apr. 25
|
1828 |