Reputation: 537
When using CookComputing (XML-RPC.net) trying to search on mail.notification model with just one condition, it is rather simple, as you just have to call:
object[] args = new object[1];
object[] subargs = new object[3];
subargs[0] = "partner_id";
subargs[1] = "=";
subargs[2] = partner_id.ToString();
int[] message_count = odooNewProxy.Search(database, userId, odoo_password, "mail.notification", "search", args);
Where Search is defined like:
[XmlRpcMethod("execute")]
int[] Search(string dbName, int userId, string pwd, string model, string method, object[] filters);
and you will get a result right away. The real problem comes when you want to call a two-or-more conditional search - such as [('partner_id', '=', 3), ('is_read', '=', False)]
. Does anyone have any clue on that? I've tried passing a single object containing two objects (one with partner_id, one with is_read) - that will work, but Odoo also takes that as a 3-objects domain, adding partner_id in []. Tried using string, tried using one object with 6 subargs - nothing seems to work. Any help will be appreciated.
Upvotes: 3
Views: 2760
Reputation: 11
Try PortaCapena.OdooJsonRpcClient , U can create advanced filtering queries using query builder using repository. This library maps models from odoo to models in C#
https://github.com/patricoos/PortaCapena.OdooJsonRpcClient
var products = await repository.Query()
.Where(x => x.WriteDate, OdooOperator.GreaterThanOrEqualTo, new DateTime(2020, 12, 2))
.Where(x => x.Name, OdooOperator.EqualsTo, "Bioboxen 610l")
.Select(x => new
{
x.Name,
x.Description,
x.WriteDate
})
.OrderByDescending(x => x.Id)
.Take(10)
.FirstOrDefaultAsync();
or using query with OdooFilter
await repository
.Query()
.Where(OdooFilter.Create()
.GreaterThanOrEqual("write_date", new DateTime(2020, 12, 2))
.And()
.EqualTo("name", "Bioboxen 610l"))
.ToListAsync()
Upvotes: 1
Reputation: 11
OdooAPI api = GetApiObject();
object[] filter = new object[3];
int id = 0;
filter[0] = new object[3] { "supplier", "=", true };
filter[1] = new object[3] { "active", "=", true };
filter[2] = new object[3] { "ref", "=", internal_reference };
Upvotes: 1
Reputation: 11
Just try this way:
object[] args= new object[] {
new object[] { "move_lines", "!=", null },
new object[] { "state", "!=", "done"}
};
Upvotes: 1