diff --git a/OdooRpc.CoreCLR.Client.sln b/OdooRpc.CoreCLR.Client.sln new file mode 100644 index 0000000..8d5a516 --- /dev/null +++ b/OdooRpc.CoreCLR.Client.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.8 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OdooRpc.CoreCLR.Client", "src\OdooRpc.CoreCLR.Client\OdooRpc.CoreCLR.Client.csproj", "{63A7DA18-D63F-4108-9CEB-EC1304461C24}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OdooRpc.CoreCLR.Client.Samples", "src\OdooRpc.CoreCLR.Client.Samples\OdooRpc.CoreCLR.Client.Samples.csproj", "{87BCC575-BD82-4B44-BD71-8D0D5C8EB841}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63A7DA18-D63F-4108-9CEB-EC1304461C24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63A7DA18-D63F-4108-9CEB-EC1304461C24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63A7DA18-D63F-4108-9CEB-EC1304461C24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63A7DA18-D63F-4108-9CEB-EC1304461C24}.Release|Any CPU.Build.0 = Release|Any CPU + {87BCC575-BD82-4B44-BD71-8D0D5C8EB841}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87BCC575-BD82-4B44-BD71-8D0D5C8EB841}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87BCC575-BD82-4B44-BD71-8D0D5C8EB841}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87BCC575-BD82-4B44-BD71-8D0D5C8EB841}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D4894610-CB54-4E73-A415-2A712320F921} + EndGlobalSection +EndGlobal diff --git a/global.json b/global.json deleted file mode 100644 index 0ea5ee2..0000000 --- a/global.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "sdk": { "version": "1.0.0-preview2-*" }, - "projects": [ "src", "tests" ] -} diff --git a/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj b/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj new file mode 100644 index 0000000..63cc630 --- /dev/null +++ b/src/OdooRpc.CoreCLR.Client.Samples/OdooRpc.CoreCLR.Client.Samples.csproj @@ -0,0 +1,22 @@ + + + + Simple Odoo JSON-RPC Client for .Net Core 1.0 + vmlf01;trafaelsilva + netcoreapp2.0 + 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 + git + https://github.com/vmlf01/OdooRpc.CoreCLR.Client + 1.0.4 + + + + + + + diff --git a/src/OdooRpc.CoreCLR.Client.Samples/project.json b/src/OdooRpc.CoreCLR.Client.Samples/project.json deleted file mode 100644 index 8b97184..0000000 --- a/src/OdooRpc.CoreCLR.Client.Samples/project.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "Simple Odoo JSON-RPC Client for .Net Core 1.0", - "authors": [ - "vmlf01", - "trafaelsilva" - ], - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "OdooRpc.CoreCLR.Client": "1.0.0" - }, - "commands": {}, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - } - } - }, - "packOptions": { - "tags": [ - "odoo", - "openerp", - "dotnet code", - "json-rpc", - "dotnet" - ], - "projectUrl": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client", - "licenseUrl": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE", - "repository": { - "type": "git", - "url": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client" - } - } -} diff --git a/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs b/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs index c7f5316..5b78dd0 100644 --- a/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs +++ b/src/OdooRpc.CoreCLR.Client/Interfaces/IOdooRpcClient.cs @@ -33,7 +33,9 @@ public interface IOdooRpcClient Task Search(OdooSearchParameters searchParameters, OdooPaginationParameters pagParameters); Task SearchCount(OdooSearchParameters parameters); + Task ExecWorkFlow(string model, string method, long id); Task Create(string model, T newRecord); + Task CreateDynamic(string model, string method, T newRecord); Task Delete(string model, long id); Task Delete(OdooDeleteParameters parameters); diff --git a/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs b/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs index e3fae1c..f0b1d1e 100644 --- a/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs +++ b/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCreateCommand.cs @@ -39,4 +39,43 @@ private OdooRpcRequest CreateCreateRequest(OdooSessionInfo sessionInfo, string m }; } } + + // Needed for e.g.: + // var changeQuantity = OdooRpcClient.OdooCreateWithMethodCommand("stock.change.product.qty", "change_product_qty", 1 ); + internal class OdooCreateDynamicCommand : OdooAbstractCommand + { + public OdooCreateDynamicCommand(IJsonRpcClient rpcClient) + : base(rpcClient) + { + } + + public Task Execute(OdooSessionInfo sessionInfo, string model, string method, T id) + { + return InvokeRpc(sessionInfo, CreateCreateDynamicRequest(sessionInfo, model, method, id)); + } + + private OdooRpcRequest CreateCreateDynamicRequest(OdooSessionInfo sessionInfo, string model, string method, object id) + { + return new OdooRpcRequest() + { + service = "object", + method = "execute_kw", + args = new object[] + { + sessionInfo.Database, + sessionInfo.UserId, + sessionInfo.Password, + model, + method, + new object[] + { + id + } + }, + context = sessionInfo.UserContext + }; + } + + } + } \ No newline at end of file diff --git a/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCustomCommand.cs b/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCustomCommand.cs new file mode 100644 index 0000000..c7df781 --- /dev/null +++ b/src/OdooRpc.CoreCLR.Client/Internals/Commands/OdooCustomCommand.cs @@ -0,0 +1,39 @@ +using System.Threading.Tasks; +using OdooRpc.CoreCLR.Client.Internals.Interfaces; +using OdooRpc.CoreCLR.Client.Models; +using JsonRpc.CoreCLR.Client.Interfaces; + +namespace OdooRpc.CoreCLR.Client.Internals.Commands +{ + internal class OdooExecWorkFlowCommand : OdooAbstractCommand + { + public OdooExecWorkFlowCommand(IJsonRpcClient rpcClient) + : base(rpcClient) + { + } + + public Task Execute(OdooSessionInfo sessionInfo, string model, string method, T id) + { + return InvokeRpc(sessionInfo, CreateExecWorkFlowRequest(sessionInfo, model, method, id)); + } + + private OdooRpcRequest CreateExecWorkFlowRequest(OdooSessionInfo sessionInfo, string model, string method, object id) + { + return new OdooRpcRequest() + { + service = "object", + method = "exec_workflow", + args = new object[] + { + sessionInfo.Database, + sessionInfo.UserId, + sessionInfo.Password, + model, + method, + id + }, + context = sessionInfo.UserContext + }; + } + } +} \ No newline at end of file diff --git a/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj new file mode 100644 index 0000000..ceb127f --- /dev/null +++ b/src/OdooRpc.CoreCLR.Client/OdooRpc.CoreCLR.Client.csproj @@ -0,0 +1,28 @@ + + + + Simple Odoo JSON-RPC Client for .Net Core 2.0. Fork from https://github.com/vmlf01/OdooRpc.CoreCLR.Client + LORDofDOOM;vmlf01;trafaelsilva + netstandard2.0 + 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 + git + https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client + 2.0.0 + true + LORDofDOOM;vmlf01;trafaelsilva + + + + + + + + + + + + diff --git a/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs b/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs index e0d3baa..65e25da 100644 --- a/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs +++ b/src/OdooRpc.CoreCLR.Client/OdooRpcClient.cs @@ -132,12 +132,25 @@ public Task SearchCount(OdooSearchParameters searchParams) return searchCommand.ExecuteCount(this.SessionInfo, searchParams); } + public Task ExecWorkFlow(string model, string method, long id) + { + var createCommand = new OdooExecWorkFlowCommand(CreateRpcClient()); + return createCommand.Execute(this.SessionInfo, model, method, id); + } + public Task Create(string model, T newRecord) { var createCommand = new OdooCreateCommand(CreateRpcClient()); return createCommand.Execute(this.SessionInfo, model, newRecord); } + public Task CreateDynamic(string model, string method, T id) + { + var createCommand = new OdooCreateDynamicCommand(CreateRpcClient()); + return createCommand.Execute(this.SessionInfo, model, method, id); + } + + public Task Delete(string model, long id) { return Delete(new OdooDeleteParameters(model, new long[] { id })); diff --git a/src/OdooRpc.CoreCLR.Client/project.json b/src/OdooRpc.CoreCLR.Client/project.json deleted file mode 100644 index 67208a6..0000000 --- a/src/OdooRpc.CoreCLR.Client/project.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "Simple Odoo JSON-RPC Client for .Net Core 1.0", - "authors": [ - "vmlf01", - "trafaelsilva" - ], - "dependencies": { - "System.Runtime": "4.1.0", - "System.IO": "4.1.0", - "System.Net.Requests": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "Newtonsoft.Json": "9.0.1", - "JsonRpc.CoreCLR.Client": "1.0.1" - }, - "commands": {}, - "frameworks": { - "netstandard1.1":{} - }, - "packOptions": { - "tags": [ - "odoo", - "openerp", - "dotnet code", - "json-rpc", - "dotnet" - ], - "projectUrl": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client", - "licenseUrl": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE", - "repository": { - "type": "git", - "url": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client" - } - } -} \ No newline at end of file diff --git a/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj b/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj new file mode 100644 index 0000000..e27100c --- /dev/null +++ b/tests/OdooRpc.CoreCLR.Client.Tests/OdooRpc.CoreCLR.Client.Tests.csproj @@ -0,0 +1,28 @@ + + + + Simple Odoo JSON-RPC Client for .Net Core 1.0 + vmlf01;trafaelsilva + netcoreapp1.0 + OdooRpc.CoreCLR.Client.Tests + OdooRpc.CoreCLR.Client.Tests + true + odoo;openerp;dotnet code;json-rpc;dotnet + https://github.com/vmlf01/OdooRpc.CoreCLR.Client + https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE + git + https://github.com/vmlf01/OdooRpc.CoreCLR.Client + 1.0.4 + + + + + + + + + + + + + diff --git a/tests/OdooRpc.CoreCLR.Client.Tests/project.json b/tests/OdooRpc.CoreCLR.Client.Tests/project.json deleted file mode 100644 index f3594a7..0000000 --- a/tests/OdooRpc.CoreCLR.Client.Tests/project.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "Simple Odoo JSON-RPC Client for .Net Core 1.0", - "authors": [ - "vmlf01", - "trafaelsilva" - ], - "testRunner": "xunit", - "dependencies": { - "xunit": "2.2.0-*", - "dotnet-test-xunit": "2.2.0-*", - "OdooRpc.CoreCLR.Client": "1.0.0-*" - }, - "commands": {}, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - } - } - }, - "packOptions": { - "tags": [ - "odoo", - "openerp", - "dotnet code", - "json-rpc", - "dotnet" - ], - "projectUrl": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client", - "licenseUrl": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client/blob/master/LICENSE", - "repository": { - "type": "git", - "url": "https://github.com/vmlf01/OdooRpc.CoreCLR.Client" - } - } -} \ No newline at end of file