class CrisalidOdooClient::Client
Constants
- DEFAULT_TIMEOUT
Attributes
odoo_db[R]
odoo_pass[R]
odoo_url[R]
odoo_user[R]
timeout[R]
Public Class Methods
new(odoo_url:, odoo_db:, odoo_user:, odoo_pass:, odoo_uid: nil, timeout: DEFAULT_TIMEOUT)
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 14 def initialize(odoo_url:, odoo_db:, odoo_user:, odoo_pass:, odoo_uid: nil, timeout: DEFAULT_TIMEOUT) @odoo_url, @odoo_db, @odoo_pass, @timeout = odoo_url, odoo_db, odoo_pass, timeout if @uid.nil? @odoo_user = odoo_user @uid = connect end if @uid != false @models = XMLRPC::Client.new2("#{@odoo_url}/xmlrpc/2/object", nil, @timeout).proxy @query ||= CrisalidOdooClient::Query.new(self) # Client connected else # Client not connected end end
Public Instance Methods
connected?()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 51 def connected? return (uid || false) != false end
employee()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 47 def employee @employee ||= CrisalidOdooClient::Resource::Employee.new(self) end
models()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 35 def models @models end
product()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 43 def product @product ||= CrisalidOdooClient::Resource::Product.new(self) end
query()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 39 def query @query end
uid()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 31 def uid @uid end
Private Instance Methods
connect()
click to toggle source
# File lib/crisalid_odoo_client/client.rb, line 57 def connect begin common = XMLRPC::Client.new2("#{@odoo_url}/xmlrpc/2/common", nil, @timeout) common.call('version') common.call('authenticate', @odoo_db, @odoo_user, @odoo_pass, {}) rescue raise CrisalidOdooClient::Error::OdooConnectionError.new('Error on connection, check the url and the database values') end end