Luke404
Luke404

Reputation: 10620

OpenERP: answering module configuration via XML-RPC

I can easily install new modules in OpenERP v6.1 using XML-RPC from a Python script:

response = sock.execute(db, uid, pwd, 'ir.module.module', 'button_immediate_install', module_ids)

sometimes response is just False (eg. edi module), sometimes it's just an indication to refresh the web client (eg. product module). That's easy, I've got nothing to do.

But sometimes the newly installed module asks the client for some configuration (eg. the sales module or one of its dependencies asking to choose a Chart of Accounts template to import). When that happens the response is a big dictionary and I can guess at the values it's asking me and the multiple choices for those values, but how can I respond back via XML-RPC?

Upvotes: 2

Views: 1139

Answers (2)

James
James

Reputation: 36

In case anyone else finds this, it took me a long time to work out how to successfully install modules via XML-RPC.

Here is what I ended up with:

# A list of module ids to install:
module_ids = (
    59, #account_accountant
    104, # account_asset
    7, # account_voucher
    47, # crm
    23, # crm_todo
    119, # hr
    115, # hr_timesheet_sheet
    14, # knowledge
    191, # purchase
    175, # stock
)

#send request to server
response = sock.execute(dbname, uid, pwd, 'ir.module.module', 'button_immediate_install', module_ids)

Upvotes: 2

Don Kirkby
Don Kirkby

Reputation: 56720

If you want to see the detailed content of RPC requests and responses, you can either run the server in debug mode and put a breakpoint in the dispatch_rpc() function in server/openerp/netsvc.py, or you can add this line to your configuration file:

log_level = debug_rpc_answer

Once you've set that up, you can install the module with your client and see what values it sends.

It's worth looking at your logging options. You can see them all in the init_logger() function in netsvc.py. There are several preset options that you can choose with log_level, or you can specify your own with log_handler.

If you're writing OpenERP scripts, you might find our client helper class useful. It reads a configuration file and takes care of connecting and sending messages for you.

Upvotes: 2

Related Questions