Comment by [email protected]:

Ruby Example, validated to work with 1.8

{{{
# Prepare the Client
require 'pp
require 'xmlrpc/client'
obj = XMLRPC::Client.new2('http://USER:PASSWORD@localhost:8069/DATABASE')

# This will retrieve the Tree to show the Models you might later want to manipulate pp obj.call('model.ir.ui.menu.search', ['OR', ['parent', '=', false]], 0, 5, FALSE, {})
#=> [60, 135, 74, 57, 1]
pp obj.call('model.ir.ui.menu.read', [1, 57, 74, 135, 60], {})
#=> { .., 'name' => 'Administration', 'id' => 1, 'childs' => [2, 14, 18, 23, 25, 36, 42, 47, 51, 59], .. }, { .. }

# User selects Menu Administration
pp obj.call('model.ir.ui.menu.search', ['OR', ['parent', '=', 1]], 0, 5, FALSE, {})
#=> [2, 14, 18, 23, 25]

pp obj.call('model.ir.ui.menu.read', [2,14,18,23,25], {})
# => { .. } containing Objects like "User Interface, Models, Scheduler" as shown in the UI Tree

# now id 23 is the Scheduler here, it has childs => [24]
pp obj.call('model.ir.ui.menu.read', [24], {})
# =>  [{ .., "action"=>"ir.action.act_window,21", .. }]
# so we have an action linked, its actually doing something

# Lets find out to what model that actionWindow is linked:
pp obj.call('model.ir.action.act_window.read', [21], {})
#=> [{"name"=>"Scheduled Actions", ..,   "res_model"=>"ir.cron"}]

# And now let us retrieve the Objects that are linked:
pp obj.call('model.ir.cron.search', [], 0, 10, {})
#=> [1]

pp obj.call('model.ir.cron.read', [1], {})
#=> [{"model"=>"ir.trigger", ..}]
}}}

Congratulations, at this point you have retrieved your first object off the Database.

For more information:
http://code.google.com/p/tryton/wiki/RemoteCalls

--
[email protected] mailing list

Reply via email to