odoo_client 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +23 -0
- data/lib/odoo_client.rb +4 -0
- data/lib/odoo_client/client.rb +71 -0
- data/lib/odoo_client/version.rb +3 -0
- data/lib/tasks/odoo_client_tasks.rake +4 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7539aa87801e6c0eeb0456cc51bba9e91c3bbc218a422606e8b10e7c4c755abf
|
4
|
+
data.tar.gz: 2915a236cb9c96cbdc2b02451f4086e016da19d71781af7b35ad4f7164428a53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d58369e00f1215a991790cc434b84d7828b34d1f48bea707fe72e0af6da1f9742102f52041dfe7a8ce004768bcae577a06c11f98e8a435c85b337f09341872a
|
7
|
+
data.tar.gz: 83ef2ec396c6cfa291a377d7380f70d2cb4b8e9be4dd58075d27b56c2b784806fc150524e9c816c3003086421cbcbad95704742b4476697f9f3607b4bfc52c78
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'OdooClient'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
data/lib/odoo_client.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "xmlrpc/client"
|
2
|
+
|
3
|
+
module OdooClient
|
4
|
+
class Client
|
5
|
+
|
6
|
+
class AuthenticationError < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(url, database, username, password)
|
10
|
+
@url = url
|
11
|
+
@common = XMLRPC::Client.new2("#{@url}/xmlrpc/2/common")
|
12
|
+
@db = database
|
13
|
+
@password = password
|
14
|
+
|
15
|
+
@common.call('version')
|
16
|
+
@uid = @common.call('authenticate', @db, username, @password, {})
|
17
|
+
|
18
|
+
raise AuthenticationError.new if @uid == false
|
19
|
+
end
|
20
|
+
|
21
|
+
def version
|
22
|
+
@common.call('version')["server_version"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def count_records(model_name, filters=[])
|
26
|
+
models.execute_kw(@db, @uid, @password, model_name, 'search_count', [filters], {})
|
27
|
+
end
|
28
|
+
|
29
|
+
def list_records(model_name, filters=[])
|
30
|
+
models.execute_kw(@db, @uid, @password, model_name, 'search', [filters], {})
|
31
|
+
end
|
32
|
+
|
33
|
+
def read_records(model_name, filters=[], select_fields=[], offset=nil, limit=nil)
|
34
|
+
optional_params = {fields: select_fields}
|
35
|
+
optional_params[:offset] = offset unless offset.nil?
|
36
|
+
optional_params[:limit] = limit unless limit.nil?
|
37
|
+
models.execute_kw(@db, @uid, @password, model_name, 'search_read', [filters], optional_params)
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_record(model_name, params)
|
41
|
+
models.execute_kw(@db, @uid, @password, model_name, 'create', [params])
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_record(model_name, id, params)
|
45
|
+
update_records(model_name, [id], params)
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_records(model_name, record_ids, params)
|
49
|
+
models.execute_kw(@db, @uid, @password, model_name, 'write', [record_ids, params])
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete_records(model_name, params)
|
53
|
+
models.execute_kw(@db, @uid, @password, model_name, 'unlink', [params])
|
54
|
+
end
|
55
|
+
|
56
|
+
def model_attributes(model_name, info=['string', 'help', 'type'])
|
57
|
+
models.execute_kw(@db, @uid, @password, model_name, 'fields_get', [], {'attributes': info})
|
58
|
+
end
|
59
|
+
|
60
|
+
def find(model_name, id, select_fields=[])
|
61
|
+
result = read_records(model_name, [["id", "=", id]], select_fields)
|
62
|
+
result[0] unless result.empty?
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def models
|
67
|
+
@models ||= XMLRPC::Client.new2("#{@url}/xmlrpc/2/object").proxy
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: odoo_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Berhang
|
8
|
+
- Valentin LAMBOLEY
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-12-21 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Ruby Client for Odoo ERP.
|
15
|
+
email:
|
16
|
+
- justin@scratch.com
|
17
|
+
- valentin.lamboley@zeto.fr
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- MIT-LICENSE
|
23
|
+
- Rakefile
|
24
|
+
- lib/odoo_client.rb
|
25
|
+
- lib/odoo_client/client.rb
|
26
|
+
- lib/odoo_client/version.rb
|
27
|
+
- lib/tasks/odoo_client_tasks.rake
|
28
|
+
homepage: https://github.com/jberhang/odoo_client
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubygems_version: 3.1.4
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Ruby Client for Odoo ERP.
|
51
|
+
test_files: []
|