sauljabin / xmlrpcwsc-dotnet Goto Github PK
View Code? Open in Web Editor NEWXML-RPC Web Service Client C# implementation
License: GNU Lesser General Public License v3.0
XML-RPC Web Service Client C# implementation
License: GNU Lesser General Public License v3.0
The odoo code for calling is
def fcm_registry(self, deviceInfo, action, **kw):
But I write the code as below, the action is null. Does somebody know how to pass the multi-parameter of odoo function?
XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");
requestCreate.AddParams(db, loginDataReturnMgr.uid, passSign, "test.m", "fr",
XmlRpcParameter.AsArray(
XmlRpcParameter.AsStruct(
XmlRpcParameter.AsMember("config_name", deviceInfo.config_name)
, XmlRpcParameter.AsMember("device_uuid", deviceInfo.device_uuid)
, XmlRpcParameter.AsMember("device_os", deviceInfo.device_os)
, XmlRpcParameter.AsMember("device_os_ver", deviceInfo.device_os_ver)
, XmlRpcParameter.AsMember("device_manufacturer", deviceInfo.device_manufacturer)
, XmlRpcParameter.AsMember("model", deviceInfo.model)
, XmlRpcParameter.AsMember("fcm_token", deviceInfo.fcm_token)
)
, deviceInfo.action
, XmlRpcParameter.EmptyArray()
)
);
I want to reach this goal as below:
Could somebody know how to write by using C#?
models.execute_kw(db, uid, password,
'res.partner', 'search_read',
[[['is_company', '=', True], ['customer', '=', True]]],
{'fields': ['name', 'country_id', 'comment'], 'limit': 5})
Hi I have following lines of code
var dict = XmlRpcParameter.EmptyStruct();
dict = XmlRpcParameter.AsStruct(XmlRpcParameter.AsMember("state", "done"));
var parameters = XmlRpcParameter.AsArray(dict);
client.Rpc.Path = "xmlrpc/2/object";
XmlRpcRequest request = new XmlRpcRequest("execute_kw");
var objToUpdate = XmlRpcParameter.AsArray(XmlRpcParameter.AsArray(id),parameters);
request.AddParams(client.DbName, client.UserId, client.DbPwd, "stock.picking", "write", objToUpdate);
response = client.Rpc.Execute(request);
The error is:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/controllers/rpc.py", line 69, in xmlrpc_2
response = self._xmlrpc(service)
File "/usr/lib/python3/dist-packages/odoo/addons/base/controllers/rpc.py", line 49, in _xmlrpc
result = dispatch_rpc(service, method, params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 139, in dispatch_rpc
result = dispatch(method, params)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 41, in dispatch
res = fn(db, uid, *params)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 174, in execute_kw
return execute(db, uid, obj, method, *args, **kw or {})
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 181, in execute
res = execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 165, in execute_cr
result = odoo.api.call_kw(recs, method, args, kw)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/stock/models/stock_picking.py", line 594, in write
if vals.get('picking_type_id') and self.state != 'draft':
AttributeError: 'list' object has no attribute 'get'
This would be very nice :)
It would be really helpful if XmpRpcResponse.GetString() would return as valid json. The namespace / class name is used when values are of type Dictionary<string, object> in ObjectToString(object value) and the temp.Value is a List. My current workaround is to manually parse the response.
var query = new List<string> { "name", "ilike", "fieldservice.task"};
var fields = new List<string> { "problems", "name" };
var list = response.GetObject() as List<object>;
var dict = list[0] as Dictionary<string, object>;
var problemIds = dict["problems"];
Perhaps a new method GetJson() would be a great enhancement?
My XmlRpcResponse.GetString() returns the following:
[{"problems": "System.Collections.Generic.List
1[System.Object]", "id": "3434", "name": "Engine / Exhaust System"}]`
Another workaround, for me, would be to modify the foreach loop in the ObjectToString method to test if the temp.Value is List and insert another for loop to iterate over it to build up the desired json string. Is there another option that I am missing?
How to execute custom model and custom function?
like the python as below:
models.execute_kw(db, uid, password,
'res.partner', 'check_access_rights',
['read'], {'raise_exception': False})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.