Class: Ooor::Base
- Inherits:
-
MiniActiveResource
- Object
- MiniActiveResource
- Ooor::Base
- Includes:
- ActiveModel::Dirty, Associations, AutosaveAssociation, Callbacks, FieldMethods, FinderMethods, Naming, NestedAttributes, Persistence, Reflection, ReflectionOoor, Report, Serialization, TypeCasting
- Defined in:
- lib/ooor/base.rb
Overview
the base class for proxies to OpenERP objects
Constant Summary
Constants included from Callbacks
Constants included from TypeCasting
TypeCasting::BLACKLIST, TypeCasting::OPERATORS
Class Attribute Summary collapse
-
.name ⇒ Object
Returns the value of attribute name.
-
.scope_prefix ⇒ Object
Returns the value of attribute scope_prefix.
-
.session ⇒ Object
Returns the value of attribute session.
-
.t ⇒ Object
Returns the value of attribute t.
Instance Attribute Summary collapse
-
#associations ⇒ Object
********************** instance methods **********************************.
-
#ir_model_data_id ⇒ Object
********************** instance methods **********************************.
-
#loaded_associations ⇒ Object
********************** instance methods **********************************.
Attributes included from FieldMethods
Attributes inherited from MiniActiveResource
Class Method Summary collapse
- .all(*args) ⇒ Object
- .context ⇒ Object
- .first(*args) ⇒ Object
- .last(*args) ⇒ Object
- .limit(value) ⇒ Object
- .logger ⇒ Object
- .method_missing(method_symbol, *args) ⇒ Object
- .name_search(name = '', domain = [], operator = 'ilike', context = {}, limit = 100) ⇒ Object
- .object_service(service, obj, method, *args) ⇒ Object
- .offset(value) ⇒ Object
- .order(value) ⇒ Object
- .rpc_exec_workflow(action, *args) ⇒ Object
- .rpc_execute(method, *args) ⇒ Object
-
.search(domain = [], offset = 0, limit = false, order = false, context = {}, count = false) ⇒ Object
OpenERP search method.
-
.where(opts, *rest) ⇒ Object
******************** AREL Minimal implementation ***********************.
Instance Method Summary collapse
-
#call(method, *args) ⇒ Object
Generic OpenERP rpc method call.
- #get_report_data(report_name, report_type = "pdf", context = {}) ⇒ Object
-
#on_change(on_change_method, field_name, field_value, *args) ⇒ Object
Generic OpenERP on_change method.
- #rpc_execute(method, *args) ⇒ Object
-
#type ⇒ Object
skips deprecated Object#type method.
-
#wkf_action(action, context = {}, reload = true) ⇒ Object
wrapper for OpenERP exec_workflow Business Process Management engine.
Methods included from Persistence
#copy, #delete, #destroy, #destroy!, #destroyed?, #initialize, #load, #save, #save!, #update, #update!, #update_attribute, #valid?
Methods included from Associations
Methods included from FieldMethods
#_destroy, #_destroy=, #get_association, #get_attribute, #lazy_load, #method_missing, #set_association, #set_attribute
Methods included from AutosaveAssociation
#changed_for_autosave?, #destroyed_by_association, #destroyed_by_association=, #mark_for_destruction, #marked_for_destruction?, #reload
Methods included from Naming
Methods included from TypeCasting
#cast_association, #cast_m2o_association, #cast_o2m_association, #cast_o2m_nested_attributes, #get_changed_values, #sanitize_association, #sanitize_association_as_string, #sanitize_attribute, #sanitize_m2o_association, #to_openerp_hash
Methods included from Serialization
#serializable_hash, #serialize_many2one, #serialize_x_to_many
Methods included from ReflectionOoor
Methods inherited from MiniActiveResource
element_name, #errors, #new?, #persisted?, #reload, #to_json, #to_xml
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ooor::FieldMethods
Class Attribute Details
.name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/ooor/base.rb', line 23 def name @name end |
.scope_prefix ⇒ Object
Returns the value of attribute scope_prefix.
23 24 25 |
# File 'lib/ooor/base.rb', line 23 def scope_prefix @scope_prefix end |
.session ⇒ Object
Returns the value of attribute session.
23 24 25 |
# File 'lib/ooor/base.rb', line 23 def session @session end |
.t ⇒ Object
Returns the value of attribute t.
23 24 25 |
# File 'lib/ooor/base.rb', line 23 def t @t end |
Instance Attribute Details
#associations ⇒ Object
********************** instance methods **********************************
81 82 83 |
# File 'lib/ooor/base.rb', line 81 def associations @associations end |
#ir_model_data_id ⇒ Object
********************** instance methods **********************************
81 82 83 |
# File 'lib/ooor/base.rb', line 81 def ir_model_data_id @ir_model_data_id end |
#loaded_associations ⇒ Object
********************** instance methods **********************************
81 82 83 |
# File 'lib/ooor/base.rb', line 81 def loaded_associations @loaded_associations end |
Class Method Details
.all(*args) ⇒ Object
62 |
# File 'lib/ooor/base.rb', line 62 def all(*args); relation.all(*args); end |
.context ⇒ Object
50 51 52 |
# File 'lib/ooor/base.rb', line 50 def context session.session_context end |
.first(*args) ⇒ Object
66 |
# File 'lib/ooor/base.rb', line 66 def first(*args); relation.first(*args); end |
.last(*args) ⇒ Object
67 |
# File 'lib/ooor/base.rb', line 67 def last(*args); relation.last(*args); end |
.limit(value) ⇒ Object
63 |
# File 'lib/ooor/base.rb', line 63 def limit(value); relation.limit(value); end |
.logger ⇒ Object
69 |
# File 'lib/ooor/base.rb', line 69 def logger; Ooor.logger; end |
.method_missing(method_symbol, *args) ⇒ Object
54 55 56 57 |
# File 'lib/ooor/base.rb', line 54 def method_missing(method_symbol, *args) raise RuntimeError.new("Invalid RPC method: #{method_symbol}") if [:type!, :allowed!].index(method_symbol) self.rpc_execute(method_symbol.to_s, *args) end |
.name_search(name = '', domain = [], operator = 'ilike', context = {}, limit = 100) ⇒ Object
33 34 35 |
# File 'lib/ooor/base.rb', line 33 def name_search(name='', domain=[], operator='ilike', context={}, limit=100) rpc_execute(:name_search, name, to_openerp_domain(domain), operator, context, limit) end |
.object_service(service, obj, method, *args) ⇒ Object
45 46 47 48 |
# File 'lib/ooor/base.rb', line 45 def object_service(service, obj, method, *args) reload_fields_definition(false) cast_answer_to_ruby!(session.object.object_service(service, obj, method, *cast_request_to_openerp(args))) end |
.offset(value) ⇒ Object
65 |
# File 'lib/ooor/base.rb', line 65 def offset(value); relation.offset(value); end |
.order(value) ⇒ Object
64 |
# File 'lib/ooor/base.rb', line 64 def order(value); relation.order(value); end |
.rpc_exec_workflow(action, *args) ⇒ Object
41 42 43 |
# File 'lib/ooor/base.rb', line 41 def rpc_exec_workflow(action, *args) object_service(:exec_workflow, openerp_model, action, *args) end |
.rpc_execute(method, *args) ⇒ Object
37 38 39 |
# File 'lib/ooor/base.rb', line 37 def rpc_execute(method, *args) object_service(:execute, openerp_model, method, *args) end |
.search(domain = [], offset = 0, limit = false, order = false, context = {}, count = false) ⇒ Object
OpenERP search method
29 30 31 |
# File 'lib/ooor/base.rb', line 29 def search(domain=[], offset=0, limit=false, order=false, context={}, count=false) rpc_execute(:search, to_openerp_domain(domain), offset, limit, order, context, count) end |
.where(opts, *rest) ⇒ Object
******************** AREL Minimal implementation ***********************
61 |
# File 'lib/ooor/base.rb', line 61 def where(opts, *rest); relation.where(opts, *rest); end |
Instance Method Details
#call(method, *args) ⇒ Object
Generic OpenERP rpc method call
91 |
# File 'lib/ooor/base.rb', line 91 def call(method, *args) rpc_execute(method, *args) end |
#get_report_data(report_name, report_type = "pdf", context = {}) ⇒ Object
108 109 110 |
# File 'lib/ooor/base.rb', line 108 def get_report_data(report_name, report_type="pdf", context={}) self.class.get_report_data(report_name, [self.id], report_type, context) end |
#on_change(on_change_method, field_name, field_value, *args) ⇒ Object
Generic OpenERP on_change method
94 95 96 97 98 99 |
# File 'lib/ooor/base.rb', line 94 def on_change(on_change_method, field_name, field_value, *args) # NOTE: OpenERP doesn't accept context systematically in on_change events unfortunately ids = self.id ? [id] : [] result = self.class.object_service(:execute, self.class.openerp_model, on_change_method, ids, *args) load_on_change_result(result, field_name, field_value) end |
#rpc_execute(method, *args) ⇒ Object
85 86 87 88 |
# File 'lib/ooor/base.rb', line 85 def rpc_execute(method, *args) args += [self.class.context] unless args[-1].is_a? Hash self.class.object_service(:execute, self.class.openerp_model, method, *args) end |
#type ⇒ Object
skips deprecated Object#type method
112 |
# File 'lib/ooor/base.rb', line 112 def type() method_missing(:type) end |
#wkf_action(action, context = {}, reload = true) ⇒ Object
wrapper for OpenERP exec_workflow Business Process Management engine
102 103 104 105 |
# File 'lib/ooor/base.rb', line 102 def wkf_action(action, context={}, reload=true) self.class.object_service(:exec_workflow, self.class.openerp_model, action, self.id, context) reload_fields if reload end |