odoo_client 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f076564b3eb748af70ac3a22ae5f06da2b299e2b7aa34dc711ce940de269908
4
- data.tar.gz: 1928bedd9869d6257fe9624c3ab04574495b389915ea0bf99b882e271df0cb9b
3
+ metadata.gz: a1b096152d21875f0281e736b4c2d540a3995b3c90a74c0a23467eee1c741f2f
4
+ data.tar.gz: 2224c21f9e84d2cfc53343c6e32ea331608d6090825573848062734d6830475f
5
5
  SHA512:
6
- metadata.gz: 370e47841f4fcc084a8b196bde815dea8c7c074eccd518e63e126b02fb844c1259c7064a97de9bd3c07acc936143124326d22673ed690b069e47fab8ec8265dc
7
- data.tar.gz: 10140accdab271f2cff75b2ef06de6dcc2c0cbf38d525c941bb9aa2881b37d96115c1c4ee7e5db7154d8bc830bbda45bb9604505747d325933306d78bc8cc4e2
6
+ metadata.gz: 9bf926c9fcc2ec9e28f7ad0b1fc34cf5ebe7d69cca6542d6d4ebcd4ea5534107903d20ffd878f1d1d9639eedd398bdb833de2fa8cba8903da621d485badcf101
7
+ data.tar.gz: 3082a9b1906903f3e45af96c02b9d6ebbcaa5d085bc049180fb4ac3a785d93052cdcb73e581176d5c7301cb0c153124c040f909e1b108bb3662b208e2b117454
data/Rakefile CHANGED
@@ -14,10 +14,4 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
-
18
-
19
-
20
-
21
-
22
- Bundler::GemHelper.install_tasks
23
-
17
+ Bundler::GemHelper.install_tasks
@@ -1,14 +1,25 @@
1
1
  require "xmlrpc/client"
2
2
 
3
- module OdooClient
3
+ module Odoo
4
4
  class Client
5
5
 
6
+ VERSION = "0.1.0"
7
+
6
8
  class AuthenticationError < StandardError
7
9
  end
8
10
 
9
- def initialize(url, database, username, password)
11
+ ##
12
+ # Initialize a new Odoo client
13
+ # @param url [String] The URL of the Odoo server
14
+ # @param database [String] The name of the database to connect to
15
+ # @param username [String] The username to use for authentication
16
+ # @param password [String] The password to use for authentication
17
+ def initialize(url, database, username, password, options={})
10
18
  @url = url
11
19
  @common = XMLRPC::Client.new2("#{@url}/xmlrpc/2/common")
20
+
21
+ @common.instance_variable_get(:@http).verify_mode = OpenSSL::SSL::VERIFY_NONE if options[:skip_tls]
22
+
12
23
  @db = database
13
24
  @password = password
14
25
 
@@ -18,38 +29,48 @@ module OdooClient
18
29
  raise AuthenticationError.new if @uid == false
19
30
  end
20
31
 
32
+ ##
33
+ # Get the Odoo instance version
34
+ # @return [String] The version of the Odoo instance
21
35
  def version
22
36
  @common.call('version')["server_version"]
23
37
  end
24
38
 
25
- def count_records(model_name, filters=[])
39
+ ##
40
+ # Get logged user id
41
+ # @return [Integer] The user id
42
+ def me
43
+ @uid
44
+ end
45
+
46
+ def count(model_name, filters=[])
26
47
  models.execute_kw(@db, @uid, @password, model_name, 'search_count', [filters], {})
27
48
  end
28
49
 
29
- def list_records(model_name, filters=[])
50
+ def list(model_name, filters=[])
30
51
  models.execute_kw(@db, @uid, @password, model_name, 'search', [filters], {})
31
52
  end
32
53
 
33
- def read_records(model_name, filters=[], select_fields=[], offset=nil, limit=nil)
54
+ def read(model_name, filters=[], select_fields=[], offset=nil, limit=nil)
34
55
  optional_params = {fields: select_fields}
35
56
  optional_params[:offset] = offset unless offset.nil?
36
57
  optional_params[:limit] = limit unless limit.nil?
37
58
  models.execute_kw(@db, @uid, @password, model_name, 'search_read', [filters], optional_params)
38
59
  end
39
60
 
40
- def create_record(model_name, params)
61
+ def create(model_name, params)
41
62
  models.execute_kw(@db, @uid, @password, model_name, 'create', [params])
42
63
  end
43
64
 
44
- def update_record(model_name, id, params)
65
+ def update(model_name, id, params)
45
66
  update_records(model_name, [id], params)
46
67
  end
47
68
 
48
- def update_records(model_name, record_ids, params)
69
+ def update(model_name, record_ids, params)
49
70
  models.execute_kw(@db, @uid, @password, model_name, 'write', [record_ids, params])
50
71
  end
51
72
 
52
- def delete_records(model_name, params)
73
+ def delete(model_name, params)
53
74
  models.execute_kw(@db, @uid, @password, model_name, 'unlink', [params])
54
75
  end
55
76
 
@@ -63,9 +84,9 @@ module OdooClient
63
84
  end
64
85
 
65
86
  private
66
- def models
67
- @models ||= XMLRPC::Client.new2("#{@url}/xmlrpc/2/object").proxy
68
- end
69
87
 
88
+ def models
89
+ @models ||= XMLRPC::Client.new2("#{@url}/xmlrpc/2/object").proxy
90
+ end
70
91
  end
71
92
  end
data/lib/odoo_client.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'odoo_client/client'
2
2
 
3
- module OdooClient
3
+ module Odoo
4
4
  end
metadata CHANGED
@@ -1,20 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odoo_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Justin Berhang
8
7
  - Valentin LAMBOLEY
8
+ - Justin Berhang
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-21 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Ruby Client for Odoo ERP.
12
+ date: 2022-11-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: xmlrpc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.3.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.3.0
28
+ description: Connect to Odoo ERP and perform CRUD operations.
15
29
  email:
30
+ - vlamboley@zeto.fr
16
31
  - justin@scratch.com
17
- - valentin.lamboley@zeto.fr
18
32
  executables: []
19
33
  extensions: []
20
34
  extra_rdoc_files: []
@@ -23,7 +37,6 @@ files:
23
37
  - Rakefile
24
38
  - lib/odoo_client.rb
25
39
  - lib/odoo_client/client.rb
26
- - lib/odoo_client/version.rb
27
40
  - lib/tasks/odoo_client_tasks.rake
28
41
  homepage: https://github.com/Yub0/odoo_client
29
42
  licenses:
@@ -44,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
57
  - !ruby/object:Gem::Version
45
58
  version: '0'
46
59
  requirements: []
47
- rubygems_version: 3.1.4
60
+ rubygems_version: 3.3.19
48
61
  signing_key:
49
62
  specification_version: 4
50
- summary: Ruby Client for Odoo ERP.
63
+ summary: Pure Ruby Client for Odoo ERP
51
64
  test_files: []
@@ -1,3 +0,0 @@
1
- module OdooClient
2
- VERSION = "0.0.5"
3
- end