Class: Kangaroo::Util::Proxy::Object

Inherits:
Kangaroo::Util::Proxy show all
Defined in:
lib/kangaroo/util/proxy/object.rb

Instance Method Summary collapse

Methods inherited from Kangaroo::Util::Proxy

#__initialize__, new

Instance Method Details

#call!(name, *args) ⇒ Object

Call function via execute on OpenERPs object service.

Parameters:

  • name

    function name to call

Returns:

  • returned value



8
9
10
# File 'lib/kangaroo/util/proxy/object.rb', line 8

def call! name, *args
  super :execute, name, *args
end

#copy(id, default = nil, context = nil) ⇒ Object

Copy a record

Parameters:

  • id
  • default (defaults to: nil)

    values to override on copy (defaults to nil)

  • context (Hash) (defaults to: nil)

Returns:

  • attributes of copied record



72
73
74
# File 'lib/kangaroo/util/proxy/object.rb', line 72

def copy id, default = nil, context = nil
  call! :copy, id, default, context
end

#create(attributes, context = nil) ⇒ Object

Create a new record

Parameters:

  • attributes (Hash)

    attributes to set on new record

Returns:

  • id of new record



97
98
99
# File 'lib/kangaroo/util/proxy/object.rb', line 97

def create attributes, context = nil
  call! :create, attributes, context
end

#default_get(fields = nil, context = nil) ⇒ Hash

Get default values for a model

Parameters:

  • fields (Array) (defaults to: nil)

    list of field names

  • context (Hash) (defaults to: nil)

Returns:

  • (Hash)


26
27
28
# File 'lib/kangaroo/util/proxy/object.rb', line 26

def default_get fields = nil, context = nil
  call! :default_get, fields, context
end

#exists(ids, context = nil) ⇒ boolean

Check if records with given ids exist

Parameters:

  • ids
  • context (defaults to: nil)

Returns:

  • (boolean)

    true if all exist, else false



81
82
83
# File 'lib/kangaroo/util/proxy/object.rb', line 81

def exists ids, context = nil
  call! :exists, ids, context
end

#fields_get(fields = nil, context = {}) ⇒ Hash

Get for a model

Parameters:

  • list (Array)

    of field names, nil for all

  • context (Hash) (defaults to: {})

Returns:

  • (Hash)

    field names and properties



17
18
19
# File 'lib/kangaroo/util/proxy/object.rb', line 17

def fields_get fields = nil, context = {}
  call! :fields_get, fields, context
end

#get_xml_id(ids) ⇒ Hash

Get xml ids for records

Parameters:

  • ids

Returns:

  • (Hash)

    Hash with ids as keys and xml_ids as values



89
90
91
# File 'lib/kangaroo/util/proxy/object.rb', line 89

def get_xml_id ids
  call! :get_xml_id, ids
end

#name_get(ids, context = nil) ⇒ Array<Array>

Get names of records for to-many relationships

Parameters:

  • ids (Array)
  • context (Hash) (defaults to: nil)

Returns:

  • (Array<Array>)

    List of arrays [id, name]



35
36
37
# File 'lib/kangaroo/util/proxy/object.rb', line 35

def name_get ids, context = nil
  call! :name_get, ids, context
end

#name_search(name = '', args = nil, operator = 'ilike', context = nil, limit = 100) ⇒ Object

Search for records by name

Parameters:

  • name (String) (defaults to: '')
  • args (Array) (defaults to: nil)
  • operator (String) (defaults to: 'ilike')
  • context (Hash) (defaults to: nil)
  • limit (Number) (defaults to: 100)

Returns:

  • list of object names



47
48
49
# File 'lib/kangaroo/util/proxy/object.rb', line 47

def name_search name = '', args = nil, operator = 'ilike', context = nil, limit = 100
  call! :name_search, name, args, operator, context, limit
end

#read(ids, fields = [], context = nil) ⇒ Array

Read fields from records

Parameters:

  • ids (Array)

    ids of record to read fields from

  • fields (Array) (defaults to: [])

    fields to read

  • context (Hash) (defaults to: nil)

Returns:

  • (Array)

    Array of Hashes with field names and values



117
118
119
# File 'lib/kangaroo/util/proxy/object.rb', line 117

def read ids, fields = [], context = nil
  call! :read, ids, fields
end

#read_group(domain, fields, groupby, offset = 0, limit = nil, order = nil) ⇒ Array

Read records grouped by a field

Parameters:

  • domain (Array)

    search conditions

  • fields (Array)

    field names to read

  • groupby (Array)

    field names to group by

  • offset (defaults to: 0)

    number of records to skip (defaults to 0)

  • limit (defaults to: nil)

    max number of records to retrieve (defaults to nil)

  • order (defaults to: nil)

    order by clause

Returns:

  • (Array)


147
148
149
# File 'lib/kangaroo/util/proxy/object.rb', line 147

def read_group domain, fields, groupby, offset = 0, limit = nil, order = nil
  call! :read_group, domain, fields, groupby, offset, limit, order
end

#read_perm(ids, context = nil, details = false) ⇒ Array

Read metadata for records, including

- create user
- create date
- write user
- write date
- xml id

Parameters:

  • ids (Array)
  • context (Hash) (defaults to: nil)
  • details (boolean) (defaults to: false)

Returns:

  • (Array)

    list of Hashes with metadata



62
63
64
# File 'lib/kangaroo/util/proxy/object.rb', line 62

def read_perm ids, context = nil, details = false
  call! :read_perm, ids, context, details
end

#search(conditions, offset = 0, limit = nil, order = nil, context = nil, count = false) ⇒ Object

Search for records

Parameters:

  • model_name

    OpenERP model to search

  • conditions (Array)

    search conditions

  • offset (defaults to: 0)

    number of records to skip, defaults to 0

  • limit (defaults to: nil)

    max number of records, defaults to nil



107
108
109
# File 'lib/kangaroo/util/proxy/object.rb', line 107

def search conditions, offset = 0, limit = nil, order = nil, context = nil, count = false
  call! :search, conditions, offset, limit, order, context, count
end

Delete records

Parameters:

  • ids (Array)

    ids to to remove

Returns:

  • true



134
135
136
# File 'lib/kangaroo/util/proxy/object.rb', line 134

def unlink ids, context = nil
  call! :unlink, ids, context
end

#write(ids, values, context = nil) ⇒ Object

Update records

Parameters:

  • ids (Array)

    ids of record to update

  • values (Hash)

    Hash of field names => values

Returns:

  • true



126
127
128
# File 'lib/kangaroo/util/proxy/object.rb', line 126

def write ids, values, context = nil
  call! :write, ids, values, context
end