From ab19e0e7437252ebafcf0ded029230f524129b30 Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Tue, 19 Oct 2021 17:17:07 +0300 Subject: [PATCH 1/8] changed all targets to netcore3.1; added configuration loading with env overrides to sample program; moved existing samples to SampleClient --- .gitignore | 6 + README.md | 2 +- .../OdooRpc.CoreCLR.Client.Samples.csproj | 13 +- src/OdooRpc.CoreCLR.Client.Samples/Program.cs | 195 ++---------------- .../SampleClient.cs | 166 +++++++++++++++ .../appsettings.json | 1 + .../OdooRpc.CoreCLR.Client.csproj | 12 +- .../OdooRpc.CoreCLR.Client.Tests.csproj | 11 +- 8 files changed, 212 insertions(+), 194 deletions(-) create mode 100644 src/OdooRpc.CoreCLR.Client.Samples/SampleClient.cs diff --git a/.gitignore b/.gitignore index 4e4341c..e43de7a 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,9 @@ UpgradeLog*.htm *.pidb *.*sdf *.ipch + +# Vscode user-specific files +.vscode/ + +# appsetting envs +appsettings.*.json \ No newline at end of file diff --git a/README.md b/README.md index 5250dd6..b6defae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OdooRpc.CoreCLR.Client -Simple [Odoo JSON-RPC](https://www.odoo.com/documentation/9.0/api_integration.html) Client for [.Net Core 1.0](https://www.microsoft.com/net/core). +Simple [Odoo JSON-RPC](https://www.odoo.com/documentation/9.0/api_integration.html) Client for [.Net Core 3.1](https://www.microsoft.com/net/core). Inspired by https://github.com/saidimu/odoo and https://github.com/osiell/odoorpc. diff --git a/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj b/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj index 63cc630..0eea203 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj +++ b/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj @@ -1,22 +1,27 @@ - Simple Odoo JSON-RPC Client for .Net Core 1.0 + Simple Odoo JSON-RPC Client for .Net Core 3.1 vmlf01;trafaelsilva - netcoreapp2.0 + netcoreapp3.1 OdooRpc.CoreCLR.Client.Samples Exe OdooRpc.CoreCLR.Client.Samples odoo;openerp;dotnet code;json-rpc;dotnet https://github.com/vmlf01/OdooRpc.CoreCLR.Client - https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE + https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE git https://github.com/vmlf01/OdooRpc.CoreCLR.Client - 1.0.4 + + + + + + diff --git a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs index eaed408..e809401 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs @@ -1,196 +1,41 @@ using System; using System.IO; -using System.Linq; using System.Threading.Tasks; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -using OdooRpc.CoreCLR.Client.Interfaces; +using Microsoft.Extensions.Configuration; using OdooRpc.CoreCLR.Client.Models; -using OdooRpc.CoreCLR.Client.Models.Parameters; namespace OdooRpc.CoreCLR.Client.Samples { public class Program { - public static void Main(string[] args) + public static async Task Main(string[] args) { Console.WriteLine("Starting..."); + var configuration = LoadConfiguration(); + var odooConnection = configuration.GetSection("OdooConnection").Get(); - var p = new Program(); - p.LoginToOdoo().Wait(); - //p.GetDepartments().Wait(); - //p.SearchDepartments().Wait(); - //p.GetDepartmentsFields().Wait(); - //p.GetAllDepartments().Wait(); - //p.CreateDeleteDepartment().Wait(); - p.GetMetadata().Wait(); - Console.WriteLine("Done! Press a key to exit..."); - Console.ReadKey(); - } - - private OdooConnectionInfo OdooConnection; - private IOdooRpcClient OdooRpcClient; - - public Program() - { - LoadSettings(); - } - - private void LoadSettings() - { - try - { - var settings = JsonConvert.DeserializeObject(File.ReadAllText("appsettings.json")); - this.OdooConnection = settings["OdooConnection"].ToObject(); - } - catch (Exception ex) - { - Console.WriteLine("Error reading app settings: {0}", ex.Message); - } - } - - public async Task LoginToOdoo() - { - try - { - this.OdooRpcClient = new OdooRpcClient(this.OdooConnection); - - var odooVersion = await this.OdooRpcClient.GetOdooVersion(); - - Console.WriteLine("Odoo Version: {0} - {1}", odooVersion.ServerVersion, odooVersion.ProtocolVersion); - - await this.OdooRpcClient.Authenticate(); - - if (this.OdooRpcClient.SessionInfo.IsLoggedIn) - { - Console.WriteLine("Login successful => User Id: {0}", this.OdooRpcClient.SessionInfo.UserId); - } - else - { - Console.WriteLine("Login failed"); - } - } - catch (Exception ex) - { - Console.WriteLine("Error connecting to Odoo: {0}", ex.Message); - } - } - - public async Task GetAllDepartments() - { - try - { - var fieldParams = new OdooFieldParameters(); - fieldParams.Add("name"); - fieldParams.Add("company_id"); - fieldParams.Add("color"); - - var departments = await this.OdooRpcClient.GetAll("hr.department", fieldParams, new OdooPaginationParameters().OrderByDescending("name")); - - Console.WriteLine(departments.FirstOrDefault()); - } - catch (Exception ex) - { - Console.WriteLine("Error getting departments from Odoo: {0}", ex.Message); - } - } - - public async Task GetDepartments() - { - try - { - var reqParams = new OdooGetParameters("hr.department"); - reqParams.Ids.Add(6); - //reqParams.Ids.Add(7); + var client = new SampleClient(odooConnection); + await client.LoginToOdoo(); + await client.GetMetadata(); - var fieldParams = new OdooFieldParameters(); - fieldParams.Add("name"); - fieldParams.Add("company_id"); - - var departments = await this.OdooRpcClient.Get(reqParams, fieldParams); - - Console.WriteLine(departments.FirstOrDefault()); - } - catch (Exception ex) - { - Console.WriteLine("Error getting departments from Odoo: {0}", ex.Message); - } + // test your calls here + + Console.WriteLine("Done!"); } - public async Task SearchDepartments() + private static IConfiguration LoadConfiguration() { - try - { - var reqParams = new OdooSearchParameters( - "hr.department", - new OdooDomainFilter().Filter("name", "like", "SIC") - ); + var environment = Environment.GetEnvironmentVariable("DOTNETCORE_ENVIRONMENT") ?? "Development"; + Console.WriteLine($"Loading config for environment: {environment}"); - var count = await this.OdooRpcClient.SearchCount(reqParams); - var departments = await this.OdooRpcClient.Search(reqParams, new OdooPaginationParameters(0, 1)); + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile($"appsettings.json") + .AddJsonFile($"appsettings.{environment}.json", true) + .AddEnvironmentVariables(); + IConfiguration configuration = builder.Build(); - Console.WriteLine(departments.FirstOrDefault()); - } - catch (Exception ex) - { - Console.WriteLine("Error getting departments from Odoo: {0}", ex.Message); - } + return configuration; } - - public async Task GetDepartmentsFields() - { - try - { - var reqParams = new OdooGetModelFieldsParameters( - "hr.department" - ); - - var fields = await this.OdooRpcClient.GetModelFields(reqParams); - - fields.ToList().ForEach(f => Console.WriteLine(f)); - } - catch (Exception ex) - { - Console.WriteLine("Error getting partners from Odoo: {0}", ex.Message); - } - } - - public async Task CreateDeleteDepartment() - { - try - { - var id = await this.OdooRpcClient.Create("hr.department", new - { - name = "test" - }); - - Console.WriteLine(id); - - await this.OdooRpcClient.Delete("hr.department", id); - } - catch (Exception ex) - { - Console.WriteLine("Error getting partners from Odoo: {0}", ex.Message); - } - } - - public async Task GetMetadata() - { - try - { - var metaParams = new OdooMetadataParameters("res.groups", new System.Collections.Generic.List() { 4 }); - - var resp = await this.OdooRpcClient.GetMetadata(metaParams); - - Console.WriteLine(resp.FirstOrDefault().ExternalId); - } - catch (Exception ex) - { - Console.WriteLine("Error getting metadata from Odoo: {0}", ex.Message); - } - } - } } \ No newline at end of file diff --git a/src/OdooRpc.CoreCLR.Client.Samples/SampleClient.cs b/src/OdooRpc.CoreCLR.Client.Samples/SampleClient.cs new file mode 100644 index 0000000..98deab0 --- /dev/null +++ b/src/OdooRpc.CoreCLR.Client.Samples/SampleClient.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using OdooRpc.CoreCLR.Client; +using OdooRpc.CoreCLR.Client.Interfaces; +using OdooRpc.CoreCLR.Client.Models; +using OdooRpc.CoreCLR.Client.Models.Parameters; + +namespace OdooRpc.CoreCLR.Client.Samples +{ + public class SampleClient + { + public OdooConnectionInfo ConnectionInfo { get; private set; } + public IOdooRpcClient OdooRpcClient { get; private set; } + + public SampleClient(OdooConnectionInfo connectionInfo) + { + ConnectionInfo = connectionInfo; + } + + // needs to be called before any other method + public async Task LoginToOdoo() + { + try + { + this.OdooRpcClient = new OdooRpcClient(this.ConnectionInfo); + + var odooVersion = await this.OdooRpcClient.GetOdooVersion(); + + Console.WriteLine("Odoo Version: {0} - {1}", odooVersion.ServerVersion, odooVersion.ProtocolVersion); + + await this.OdooRpcClient.Authenticate(); + + if (this.OdooRpcClient.SessionInfo.IsLoggedIn) + { + Console.WriteLine("Login successful => User Id: {0}", this.OdooRpcClient.SessionInfo.UserId); + } + else + { + Console.WriteLine("Login failed"); + } + } + catch (Exception ex) + { + Console.WriteLine("Error connecting to Odoo: {0}", ex.Message); + } + } + + public async Task GetAllDepartments() + { + try + { + var fieldParams = new OdooFieldParameters(); + fieldParams.Add("name"); + fieldParams.Add("company_id"); + fieldParams.Add("color"); + + var departments = await this.OdooRpcClient.GetAll("hr.department", fieldParams, new OdooPaginationParameters().OrderByDescending("name")); + + Console.WriteLine(departments.FirstOrDefault()); + } + catch (Exception ex) + { + Console.WriteLine("Error getting departments from Odoo: {0}", ex.Message); + } + } + + public async Task GetDepartments() + { + try + { + var reqParams = new OdooGetParameters("hr.department"); + reqParams.Ids.Add(6); + //reqParams.Ids.Add(7); + + var fieldParams = new OdooFieldParameters(); + fieldParams.Add("name"); + fieldParams.Add("company_id"); + + var departments = await this.OdooRpcClient.Get(reqParams, fieldParams); + + Console.WriteLine(departments.FirstOrDefault()); + } + catch (Exception ex) + { + Console.WriteLine("Error getting departments from Odoo: {0}", ex.Message); + } + } + + public async Task SearchDepartments() + { + try + { + var reqParams = new OdooSearchParameters( + "hr.department", + new OdooDomainFilter().Filter("name", "like", "SIC") + ); + + var count = await this.OdooRpcClient.SearchCount(reqParams); + var departments = await this.OdooRpcClient.Search(reqParams, new OdooPaginationParameters(0, 1)); + + Console.WriteLine(departments.FirstOrDefault()); + } + catch (Exception ex) + { + Console.WriteLine("Error getting departments from Odoo: {0}", ex.Message); + } + } + + public async Task GetDepartmentsFields() + { + try + { + var reqParams = new OdooGetModelFieldsParameters( + "hr.department" + ); + + var fields = await this.OdooRpcClient.GetModelFields(reqParams); + + fields.ToList().ForEach(f => Console.WriteLine(f)); + } + catch (Exception ex) + { + Console.WriteLine("Error getting partners from Odoo: {0}", ex.Message); + } + } + + public async Task CreateDeleteDepartment() + { + try + { + var id = await this.OdooRpcClient.Create("hr.department", new + { + name = "test" + }); + + Console.WriteLine(id); + + await this.OdooRpcClient.Delete("hr.department", id); + } + catch (Exception ex) + { + Console.WriteLine("Error getting partners from Odoo: {0}", ex.Message); + } + } + + public async Task GetMetadata() + { + try + { + var metaParams = new OdooMetadataParameters("res.groups", new System.Collections.Generic.List() { 4 }); + + var resp = await this.OdooRpcClient.GetMetadata(metaParams); + + Console.WriteLine(resp.FirstOrDefault().ExternalId); + } + catch (Exception ex) + { + Console.WriteLine("Error getting metadata from Odoo: {0}", ex.Message); + } + } + + } +} \ No newline at end of file diff --git a/src/OdooRpc.CoreCLR.Client.Samples/appsettings.json b/src/OdooRpc.CoreCLR.Client.Samples/appsettings.json index 57709c3..f01aa58 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/appsettings.json +++ b/src/OdooRpc.CoreCLR.Client.Samples/appsettings.json @@ -2,6 +2,7 @@ "OdooConnection": { "Host": "", "Port": 0, + "IsSSL": false, "Database": "", "Username": "", "Password": "" diff --git a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj index ceb127f..e253675 100644 --- a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj +++ b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj @@ -1,14 +1,14 @@ - Simple Odoo JSON-RPC Client for .Net Core 2.0. Fork from https://github.com/vmlf01/OdooRpc.CoreCLR.Client + Simple Odoo JSON-RPC Client for .Net Core 3.1. Fork from https://github.com/vmlf01/OdooRpc.CoreCLR.Client LORDofDOOM;vmlf01;trafaelsilva - netstandard2.0 + netcoreapp3.1 OdooRpc.CoreCLR.Client OdooRpc.CoreCLR.Client.V2 odoo;openerp;dotnet code;json-rpc;dotnet https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client - https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client/blob/master/LICENSE + https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client/blob/master/LICENSE git https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client 2.0.0 @@ -17,11 +17,7 @@ - - - - - + diff --git a/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj b/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj index e27100c..0afb8ce 100644 --- a/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj +++ b/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj @@ -1,9 +1,9 @@ - Simple Odoo JSON-RPC Client for .Net Core 1.0 + Simple Odoo JSON-RPC Client for .Net Core 3.1 vmlf01;trafaelsilva - netcoreapp1.0 + netcoreapp3.1 OdooRpc.CoreCLR.Client.Tests OdooRpc.CoreCLR.Client.Tests true @@ -12,7 +12,6 @@ https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE git https://github.com/vmlf01/OdooRpc.CoreCLR.Client - 1.0.4 @@ -20,9 +19,9 @@ - - - + + + From ec0bace4bc8f45abf9b4bb9d3088d8577e90c50e Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Tue, 19 Oct 2021 18:04:39 +0300 Subject: [PATCH 2/8] added test client for invoices --- .../MyClient1.cs | 121 ++++++++++++++++++ src/OdooRpc.CoreCLR.Client.Samples/Program.cs | 11 +- 2 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs diff --git a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs new file mode 100644 index 0000000..2899a94 --- /dev/null +++ b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using OdooRpc.CoreCLR.Client.Interfaces; +using OdooRpc.CoreCLR.Client.Models; +using OdooRpc.CoreCLR.Client.Models.Parameters; + +namespace OdooRpc.CoreCLR.Client.Samples +{ + public class MyClient1 + { + public OdooConnectionInfo ConnectionInfo { get; private set; } + public IOdooRpcClient OdooRpcClient { get; private set; } + + public MyClient1(OdooConnectionInfo connectionInfo) + { + ConnectionInfo = connectionInfo; + } + + // needs to be called before any other method + public async Task LoginToOdoo() + { + try + { + this.OdooRpcClient = new OdooRpcClient(this.ConnectionInfo); + + var odooVersion = await this.OdooRpcClient.GetOdooVersion(); + + Console.WriteLine("Odoo Version: {0} - {1}", odooVersion.ServerVersion, odooVersion.ProtocolVersion); + + await this.OdooRpcClient.Authenticate(); + + if (this.OdooRpcClient.SessionInfo.IsLoggedIn) + { + Console.WriteLine("Login successful => User Id: {0}", this.OdooRpcClient.SessionInfo.UserId); + } + else + { + Console.WriteLine("Login failed"); + } + } + catch (Exception ex) + { + Console.WriteLine("Error connecting to Odoo: {0}", ex.Message); + } + } + + public async Task GetAllInvoices() + { + try + { + var fieldParams = new OdooFieldParameters + { + "id", + "name", + "partner_id", + "company_id", + "move_type", + "state" + }; + + var departments = await this.OdooRpcClient.GetAll("account.move", fieldParams, new OdooPaginationParameters().OrderByDescending("name")); + + Array.ForEach(departments, Console.WriteLine); + } + catch (Exception ex) + { + Console.WriteLine("Error getting invoices from Odoo: {0}", ex.Message); + } + } + + public async Task CreateInvoice(string customerName = null) + { + try + { + long customerId = 0; + if (customerName != null) + { + var reqParams = new OdooSearchParameters( + "res.partner", + new OdooDomainFilter().Filter("name", "like", customerName) + ); + + var count = await this.OdooRpcClient.SearchCount(reqParams); + var customers = await this.OdooRpcClient.Search(reqParams, new OdooPaginationParameters(0, 1)); + + var foundCustomer = customers.Any() ? customers[0] : 0; + + if (foundCustomer > 0) + { + customerId = foundCustomer; + } + else + { + // TODO: create customer + } + + Console.WriteLine(foundCustomer); + } + + var id = await this.OdooRpcClient.Create("account.move", new + { + partner_id = customerId, + move_type = "out_invoice" + }); + + Console.WriteLine("Created " + id); + + // await this.OdooRpcClient.Delete("account.move", 2); + } + catch (RpcCallException ex) + { + Console.WriteLine("Error creating invoice: {0}", ex.Message); + Console.WriteLine(JsonConvert.SerializeObject(ex.RpcErrorData)); + } + } + } +} \ No newline at end of file diff --git a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs index e809401..a46ccab 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs @@ -14,12 +14,15 @@ public static async Task Main(string[] args) var configuration = LoadConfiguration(); var odooConnection = configuration.GetSection("OdooConnection").Get(); - var client = new SampleClient(odooConnection); - await client.LoginToOdoo(); - await client.GetMetadata(); + // var client = new SampleClient(odooConnection); + // await client.LoginToOdoo(); + // await client.GetMetadata(); // test your calls here - + var client = new MyClient1(odooConnection); + await client.LoginToOdoo(); + await client.GetAllInvoices(); + await client.CreateInvoice("Test Company"); Console.WriteLine("Done!"); } From 4985289682641599c4be64a4f1f4f3dba3db01b1 Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Wed, 20 Oct 2021 17:12:23 +0300 Subject: [PATCH 3/8] more test calls --- .../MyClient1.cs | 48 +++++++++++++++++-- src/OdooRpc.CoreCLR.Client.Samples/Program.cs | 5 +- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs index 2899a94..c68387b 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -72,6 +73,22 @@ public async Task GetAllInvoices() } } + public async Task GetCustomers(IEnumerable ids) + { + try + { + var searchParams = new OdooGetParameters("res.partner", ids); + + var departments = await this.OdooRpcClient.Get(searchParams); + + Array.ForEach(departments, Console.WriteLine); + } + catch (Exception ex) + { + Console.WriteLine("Error getting customers from Odoo: {0}", ex.Message); + } + } + public async Task CreateInvoice(string customerName = null) { try @@ -95,26 +112,49 @@ public async Task CreateInvoice(string customerName = null) } else { + string searchCountry = "bulgaria"; + var matchingCountries = await this.OdooRpcClient.Search(new OdooSearchParameters + ( + "res.country", + new OdooDomainFilter().Filter("name", "ilike", searchCountry) + )); + + long countryId = matchingCountries.FirstOrDefault(); + if (countryId <= 0) + { + throw new ArgumentException("Cannot find country " + searchCountry); + } // TODO: create customer + customerId = await this.OdooRpcClient.Create("res.partner", new { + name = customerName, + street = "Made-up address 1", + city = "Vratza", + country_id = countryId, + email = "madeupemail1@abv.bg", + x_nickname = $"{customerName} accountId" + }); } - Console.WriteLine(foundCustomer); + Console.WriteLine("Creating invoice for customer " + customerId); } var id = await this.OdooRpcClient.Create("account.move", new { partner_id = customerId, - move_type = "out_invoice" + move_type = "out_invoice", + x_external_creator = "portal Admin3" }); - Console.WriteLine("Created " + id); + Console.WriteLine("Created invoice " + id); // await this.OdooRpcClient.Delete("account.move", 2); } catch (RpcCallException ex) { Console.WriteLine("Error creating invoice: {0}", ex.Message); - Console.WriteLine(JsonConvert.SerializeObject(ex.RpcErrorData)); + var valueErr = Regex.Match(JsonConvert.SerializeObject(ex.RpcErrorData), "message\":.*"); + // System.Console.WriteLine(JsonConvert.SerializeObject(ex.RpcErrorData)); + Console.WriteLine(valueErr); } } } diff --git a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs index a46ccab..9725681 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs @@ -21,8 +21,9 @@ public static async Task Main(string[] args) // test your calls here var client = new MyClient1(odooConnection); await client.LoginToOdoo(); - await client.GetAllInvoices(); - await client.CreateInvoice("Test Company"); + // await client.GetAllInvoices(); + // await client.GetCustomers(new[] { 1L }); + await client.CreateInvoice("Test Company 4"); Console.WriteLine("Done!"); } From dad2cfabbd6cb58b92b472654da2061b65c98333 Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Wed, 20 Oct 2021 17:27:54 +0300 Subject: [PATCH 4/8] updated readme --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b6defae..29d0bbc 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,12 @@ nuget.exe push .\build\OdooRpc.CoreCLR.Client.0.0.1.nupkg ``` ### Samples +All updated to work with dotnetcore 3.1 -*TODO* +1. update the appsettings.json file (note: enter the host without protocol prefix, and set the use of ssl) +2. Alternative 1, create an appsettings.Development.json file and optionally other env settings files, which you don't want source controlled. +Then run the sample project with `DOTNETCORE_ENVIRONMENT=Development dotnet run` +3. Alernative 2, use env variables instead of appsetting values when starting the sample project. Example: +`OdooConnection__Host=my.odoohost.com OdooConnection__Password=mypassword dotnet run` + +The above commands are for UNIX, if you are on windows, command-line env vars are set like `set ENV_VAR=value && dotnet run` From 64ee8bbb7fdaf31a520f0e87fe09a5d757535e70 Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Thu, 21 Oct 2021 16:35:17 +0300 Subject: [PATCH 5/8] added getfullinvoice; added create inv line --- .../MyClient1.cs | 46 ++++++++++++++++++- src/OdooRpc.CoreCLR.Client.Samples/Program.cs | 4 +- .../OdooRpc.CoreCLR.Client.csproj | 2 +- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs index c68387b..6fd0fb6 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs @@ -89,7 +89,32 @@ public async Task GetCustomers(IEnumerable ids) } } - public async Task CreateInvoice(string customerName = null) + public async Task GetInvoiceFull(long id) + { + try + { + var searchParams = new OdooGetParameters("account.move", new long[]{id}); + + var invoices = await this.OdooRpcClient.Get(searchParams); + foreach (var inv in invoices) + { + System.Console.WriteLine(inv); + var ids = (JArray)inv["line_ids"]; + var lineIds = ids.Select(l => (long)l).ToList(); + var invLines = await this.OdooRpcClient.Get(new OdooGetParameters("account.move.line", lineIds)); + foreach (var line in invLines) + { + System.Console.WriteLine(line); + } + } + } + catch (Exception ex) + { + Console.WriteLine("Error getting invoices from Odoo: {0}", ex.Message); + } + } + + public async Task CreateInvoice(string customerName, string reason, decimal amount) { try { @@ -138,6 +163,7 @@ public async Task CreateInvoice(string customerName = null) Console.WriteLine("Creating invoice for customer " + customerId); } + // create invoice var id = await this.OdooRpcClient.Create("account.move", new { partner_id = customerId, @@ -145,6 +171,24 @@ public async Task CreateInvoice(string customerName = null) x_external_creator = "portal Admin3" }); + // create invoice line + var salesAccounts = await this.OdooRpcClient.Search(new OdooSearchParameters + ( + "account.account", + new OdooDomainFilter().Filter("code", "=", 700000) + )); + long salesAccId = salesAccounts.FirstOrDefault(); + + var lineId = await this.OdooRpcClient.Create("account.move.line", new + { + move_id = id, + name = reason, + quantity = 1.0, + price_unit = amount, + tax_ids = 1, + account_id = salesAccId // 700000 - Sales + }); + Console.WriteLine("Created invoice " + id); // await this.OdooRpcClient.Delete("account.move", 2); diff --git a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs index 9725681..e961c69 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs @@ -21,9 +21,9 @@ public static async Task Main(string[] args) // test your calls here var client = new MyClient1(odooConnection); await client.LoginToOdoo(); - // await client.GetAllInvoices(); + await client.GetInvoiceFull(14); // await client.GetCustomers(new[] { 1L }); - await client.CreateInvoice("Test Company 4"); + // await client.CreateInvoice("Test Company 2", "order 1122", 90.00m); Console.WriteLine("Done!"); } diff --git a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj index e253675..c171f33 100644 --- a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj +++ b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj @@ -11,7 +11,7 @@ https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client/blob/master/LICENSE git https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client - 2.0.0 + 2.1.0 true LORDofDOOM;vmlf01;trafaelsilva From 7c91f2b5d6b4cc9a527d0c75ed55646be8ba65d8 Mon Sep 17 00:00:00 2001 From: Stann Date: Fri, 22 Oct 2021 15:39:21 +0300 Subject: [PATCH 6/8] added multi-create command; modified inv creation --- .../MyClient1.cs | 78 ++++++++++++++----- src/OdooRpc.CoreCLR.Client.Samples/Program.cs | 4 +- .../Interfaces/IOdooRpcClient.cs | 1 + .../Internals/Commands/OdooCreateCommand.cs | 6 ++ src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs | 6 ++ 5 files changed, 74 insertions(+), 21 deletions(-) diff --git a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs index 6fd0fb6..4a7fdb3 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs @@ -116,6 +116,7 @@ public async Task GetInvoiceFull(long id) public async Task CreateInvoice(string customerName, string reason, decimal amount) { + long createdId = 0; try { long customerId = 0; @@ -164,32 +165,66 @@ public async Task CreateInvoice(string customerName, string reason, decimal amou } // create invoice - var id = await this.OdooRpcClient.Create("account.move", new + createdId = await this.OdooRpcClient.Create("account.move", new { partner_id = customerId, move_type = "out_invoice", x_external_creator = "portal Admin3" }); - // create invoice line - var salesAccounts = await this.OdooRpcClient.Search(new OdooSearchParameters - ( - "account.account", - new OdooDomainFilter().Filter("code", "=", 700000) - )); - long salesAccId = salesAccounts.FirstOrDefault(); - - var lineId = await this.OdooRpcClient.Create("account.move.line", new - { - move_id = id, - name = reason, - quantity = 1.0, - price_unit = amount, - tax_ids = 1, - account_id = salesAccId // 700000 - Sales - }); + // create invoice lines + // var salesAccounts = await this.OdooRpcClient.Search(new OdooSearchParameters + // ( + // "account.account", + // new OdooDomainFilter().Filter("code", "=", 700000) + // )); + // long salesAccId = salesAccounts.FirstOrDefault(); + long salesAccId = 1; + long receivablesAccId = 2; // TODO: get from response + + var createLines = new List(){ + new + { + move_id = createdId, + name = reason, + quantity = 1.0, + price_unit = amount, + credit = amount, + partner_id = customerId, + //tax_ids = new object[]{new object[]{6, false, new object[]{1}}}, + account_id = salesAccId // 700000 - Sales + }, + new + { + move_id = createdId, + name = reason, + quantity = 1.0, + debit = 1.0m * amount, + exclude_from_invoice_tab = true, + partner_id = customerId, + //tax_ids = new object[]{new object[]{6, false, new object[]{}}}, + //tax_tag_ids = new object[]{new object[]{6, false, new object[]{}}}, + account_id = receivablesAccId // 410000 - Receivables + }, + // new + // { + // move_id = createdId, + // name = "VAT 20%", + // quantity = 1.0, + // credit = 0.2m * amount, + // tax_base_amount = amount, + // exclude_from_invoice_tab = true, + // partner_id = customerId, + // tax_ids = new object[]{new object[]{6, false, new object[]{}}}, + // tax_repartition_line_id = 2, + // account_id = 13 // VAT + // } + }; + await this.OdooRpcClient.CreateMulti>("account.move.line", createLines); + // var salesLineId = await this.OdooRpcClient.Create("account.move.line", ); + // var receivesLineId = await this.OdooRpcClient.Create("account.move.line", ); - Console.WriteLine("Created invoice " + id); + Console.WriteLine("Created invoice " + createdId); // await this.OdooRpcClient.Delete("account.move", 2); } @@ -199,6 +234,11 @@ public async Task CreateInvoice(string customerName, string reason, decimal amou var valueErr = Regex.Match(JsonConvert.SerializeObject(ex.RpcErrorData), "message\":.*"); // System.Console.WriteLine(JsonConvert.SerializeObject(ex.RpcErrorData)); Console.WriteLine(valueErr); + + if (createdId > 0) + { + await this.OdooRpcClient.Delete("account.move", createdId); + } } } } diff --git a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs index e961c69..b2c877e 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs @@ -21,9 +21,9 @@ public static async Task Main(string[] args) // test your calls here var client = new MyClient1(odooConnection); await client.LoginToOdoo(); - await client.GetInvoiceFull(14); + // await client.GetInvoiceFull(14); // await client.GetCustomers(new[] { 1L }); - // await client.CreateInvoice("Test Company 2", "order 1122", 90.00m); + await client.CreateInvoice("Test Company 2", "order 1000", 150.00m); Console.WriteLine("Done!"); } diff --git a/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs b/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs index 5b78dd0..c7bbf10 100644 --- a/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs +++ b/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs @@ -35,6 +35,7 @@ public interface IOdooRpcClient Task ExecWorkFlow(string model, string method, long id); Task Create(string model, T newRecord); + Task> CreateMulti(string model, T newRecord); Task CreateDynamic(string model, string method, T newRecord); Task Delete(string model, long id); diff --git a/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs b/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs index f0b1d1e..8356c00 100644 --- a/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs +++ b/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs @@ -2,6 +2,7 @@ using OdooRpc.CoreCLR.Client.Internals.Interfaces; using OdooRpc.CoreCLR.Client.Models; using JsonRpc.CoreCLR.Client.Interfaces; +using System.Collections.Generic; namespace OdooRpc.CoreCLR.Client.Internals.Commands { @@ -17,6 +18,11 @@ public Task Execute(OdooSessionInfo sessionInfo, string model, T newRec return InvokeRpc(sessionInfo, CreateCreateRequest(sessionInfo, model, newRecord)); } + public Task> ExecuteMulti(OdooSessionInfo sessionInfo, string model, T newRecord) + { + return InvokeRpc>(sessionInfo, CreateCreateRequest(sessionInfo, model, newRecord)); + } + private OdooRpcRequest CreateCreateRequest(OdooSessionInfo sessionInfo, string model, object newRecord) { return new OdooRpcRequest() diff --git a/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs b/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs index 65e25da..8758d47 100644 --- a/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs +++ b/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs @@ -144,6 +144,12 @@ public Task Create(string model, T newRecord) return createCommand.Execute(this.SessionInfo, model, newRecord); } + public Task> CreateMulti(string model, T newRecord) + { + var createCommand = new OdooCreateCommand(CreateRpcClient()); + return createCommand.ExecuteMulti(this.SessionInfo, model, newRecord); + } + public Task CreateDynamic(string model, string method, T id) { var createCommand = new OdooCreateDynamicCommand(CreateRpcClient()); From 6027f080c38e6ffbe34b3729ff9a49cc128626d5 Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Mon, 25 Oct 2021 15:49:03 +0300 Subject: [PATCH 7/8] updated package meta and readme --- README.md | 2 +- .../OdooRpc.CoreCLR.Client.csproj | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 29d0bbc..eaaeac6 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ You will need nuget.exe on your path and set the NuGet API Key before you can pu ```Shell nuget.exe setApiKey 76d7xxxx-xxxx-xxxx-xxxx-eabb8b0cxxxx -nuget.exe push .\build\OdooRpc.CoreCLR.Client.0.0.1.nupkg +nuget.exe push .\build\OdooRpc.CoreCLR.Client.V3.2.2.0.nupkg ``` ### Samples diff --git a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj index c171f33..5b3d6eb 100644 --- a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj +++ b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj @@ -1,24 +1,27 @@ - Simple Odoo JSON-RPC Client for .Net Core 3.1. Fork from https://github.com/vmlf01/OdooRpc.CoreCLR.Client - LORDofDOOM;vmlf01;trafaelsilva + Simple Odoo JSON-RPC Client, adapted to .Net Core 3.1. Fork from https://github.com/vmlf01/OdooRpc.CoreCLR.Client + Stann netcoreapp3.1 OdooRpc.CoreCLR.Client - OdooRpc.CoreCLR.Client.V2 + OdooRpc.CoreCLR.Client.V3 odoo;openerp;dotnet code;json-rpc;dotnet - https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client - https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client/blob/master/LICENSE + https://github.com/stann1/OdooRpc.CoreCLR.Client + LICENSE git - https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client - 2.1.0 + https://github.com/stann1/OdooRpc.CoreCLR.Client + 2.2.0 true - LORDofDOOM;vmlf01;trafaelsilva + Hollso.com + + + From 88a843f0480e8c1eaec20d6bcca18240e9e3ce0f Mon Sep 17 00:00:00 2001 From: Stanislav Stoychev Date: Mon, 25 Oct 2021 15:56:49 +0300 Subject: [PATCH 8/8] removed extra samples --- .../MyClient1.cs | 245 ------------------ src/OdooRpc.CoreCLR.Client.Samples/Program.cs | 5 - 2 files changed, 250 deletions(-) delete mode 100644 src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs diff --git a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs b/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs deleted file mode 100644 index 4a7fdb3..0000000 --- a/src/OdooRpc.CoreCLR.Client.Samples/MyClient1.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using OdooRpc.CoreCLR.Client.Interfaces; -using OdooRpc.CoreCLR.Client.Models; -using OdooRpc.CoreCLR.Client.Models.Parameters; - -namespace OdooRpc.CoreCLR.Client.Samples -{ - public class MyClient1 - { - public OdooConnectionInfo ConnectionInfo { get; private set; } - public IOdooRpcClient OdooRpcClient { get; private set; } - - public MyClient1(OdooConnectionInfo connectionInfo) - { - ConnectionInfo = connectionInfo; - } - - // needs to be called before any other method - public async Task LoginToOdoo() - { - try - { - this.OdooRpcClient = new OdooRpcClient(this.ConnectionInfo); - - var odooVersion = await this.OdooRpcClient.GetOdooVersion(); - - Console.WriteLine("Odoo Version: {0} - {1}", odooVersion.ServerVersion, odooVersion.ProtocolVersion); - - await this.OdooRpcClient.Authenticate(); - - if (this.OdooRpcClient.SessionInfo.IsLoggedIn) - { - Console.WriteLine("Login successful => User Id: {0}", this.OdooRpcClient.SessionInfo.UserId); - } - else - { - Console.WriteLine("Login failed"); - } - } - catch (Exception ex) - { - Console.WriteLine("Error connecting to Odoo: {0}", ex.Message); - } - } - - public async Task GetAllInvoices() - { - try - { - var fieldParams = new OdooFieldParameters - { - "id", - "name", - "partner_id", - "company_id", - "move_type", - "state" - }; - - var departments = await this.OdooRpcClient.GetAll("account.move", fieldParams, new OdooPaginationParameters().OrderByDescending("name")); - - Array.ForEach(departments, Console.WriteLine); - } - catch (Exception ex) - { - Console.WriteLine("Error getting invoices from Odoo: {0}", ex.Message); - } - } - - public async Task GetCustomers(IEnumerable ids) - { - try - { - var searchParams = new OdooGetParameters("res.partner", ids); - - var departments = await this.OdooRpcClient.Get(searchParams); - - Array.ForEach(departments, Console.WriteLine); - } - catch (Exception ex) - { - Console.WriteLine("Error getting customers from Odoo: {0}", ex.Message); - } - } - - public async Task GetInvoiceFull(long id) - { - try - { - var searchParams = new OdooGetParameters("account.move", new long[]{id}); - - var invoices = await this.OdooRpcClient.Get(searchParams); - foreach (var inv in invoices) - { - System.Console.WriteLine(inv); - var ids = (JArray)inv["line_ids"]; - var lineIds = ids.Select(l => (long)l).ToList(); - var invLines = await this.OdooRpcClient.Get(new OdooGetParameters("account.move.line", lineIds)); - foreach (var line in invLines) - { - System.Console.WriteLine(line); - } - } - } - catch (Exception ex) - { - Console.WriteLine("Error getting invoices from Odoo: {0}", ex.Message); - } - } - - public async Task CreateInvoice(string customerName, string reason, decimal amount) - { - long createdId = 0; - try - { - long customerId = 0; - if (customerName != null) - { - var reqParams = new OdooSearchParameters( - "res.partner", - new OdooDomainFilter().Filter("name", "like", customerName) - ); - - var count = await this.OdooRpcClient.SearchCount(reqParams); - var customers = await this.OdooRpcClient.Search(reqParams, new OdooPaginationParameters(0, 1)); - - var foundCustomer = customers.Any() ? customers[0] : 0; - - if (foundCustomer > 0) - { - customerId = foundCustomer; - } - else - { - string searchCountry = "bulgaria"; - var matchingCountries = await this.OdooRpcClient.Search(new OdooSearchParameters - ( - "res.country", - new OdooDomainFilter().Filter("name", "ilike", searchCountry) - )); - - long countryId = matchingCountries.FirstOrDefault(); - if (countryId <= 0) - { - throw new ArgumentException("Cannot find country " + searchCountry); - } - // TODO: create customer - customerId = await this.OdooRpcClient.Create("res.partner", new { - name = customerName, - street = "Made-up address 1", - city = "Vratza", - country_id = countryId, - email = "madeupemail1@abv.bg", - x_nickname = $"{customerName} accountId" - }); - } - - Console.WriteLine("Creating invoice for customer " + customerId); - } - - // create invoice - createdId = await this.OdooRpcClient.Create("account.move", new - { - partner_id = customerId, - move_type = "out_invoice", - x_external_creator = "portal Admin3" - }); - - // create invoice lines - // var salesAccounts = await this.OdooRpcClient.Search(new OdooSearchParameters - // ( - // "account.account", - // new OdooDomainFilter().Filter("code", "=", 700000) - // )); - // long salesAccId = salesAccounts.FirstOrDefault(); - long salesAccId = 1; - long receivablesAccId = 2; // TODO: get from response - - var createLines = new List(){ - new - { - move_id = createdId, - name = reason, - quantity = 1.0, - price_unit = amount, - credit = amount, - partner_id = customerId, - //tax_ids = new object[]{new object[]{6, false, new object[]{1}}}, - account_id = salesAccId // 700000 - Sales - }, - new - { - move_id = createdId, - name = reason, - quantity = 1.0, - debit = 1.0m * amount, - exclude_from_invoice_tab = true, - partner_id = customerId, - //tax_ids = new object[]{new object[]{6, false, new object[]{}}}, - //tax_tag_ids = new object[]{new object[]{6, false, new object[]{}}}, - account_id = receivablesAccId // 410000 - Receivables - }, - // new - // { - // move_id = createdId, - // name = "VAT 20%", - // quantity = 1.0, - // credit = 0.2m * amount, - // tax_base_amount = amount, - // exclude_from_invoice_tab = true, - // partner_id = customerId, - // tax_ids = new object[]{new object[]{6, false, new object[]{}}}, - // tax_repartition_line_id = 2, - // account_id = 13 // VAT - // } - }; - await this.OdooRpcClient.CreateMulti>("account.move.line", createLines); - // var salesLineId = await this.OdooRpcClient.Create("account.move.line", ); - // var receivesLineId = await this.OdooRpcClient.Create("account.move.line", ); - - Console.WriteLine("Created invoice " + createdId); - - // await this.OdooRpcClient.Delete("account.move", 2); - } - catch (RpcCallException ex) - { - Console.WriteLine("Error creating invoice: {0}", ex.Message); - var valueErr = Regex.Match(JsonConvert.SerializeObject(ex.RpcErrorData), "message\":.*"); - // System.Console.WriteLine(JsonConvert.SerializeObject(ex.RpcErrorData)); - Console.WriteLine(valueErr); - - if (createdId > 0) - { - await this.OdooRpcClient.Delete("account.move", createdId); - } - } - } - } -} \ No newline at end of file diff --git a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs index b2c877e..5981c11 100644 --- a/src/OdooRpc.CoreCLR.Client.Samples/Program.cs +++ b/src/OdooRpc.CoreCLR.Client.Samples/Program.cs @@ -19,11 +19,6 @@ public static async Task Main(string[] args) // await client.GetMetadata(); // test your calls here - var client = new MyClient1(odooConnection); - await client.LoginToOdoo(); - // await client.GetInvoiceFull(14); - // await client.GetCustomers(new[] { 1L }); - await client.CreateInvoice("Test Company 2", "order 1000", 150.00m); Console.WriteLine("Done!"); }