odoo-8 RPC using Odoo v8 API (Call Python function from JavaScript)


If you are considering to add new methods in Python to use them in RPC from JavaScript, then consider the following options of method decorators: if you've to deal with ids/recordsets then for python method definition choose decorator:

  • @api.multi - to get recordset in your method
  • @api.one - to get browse_records one by one in your method in above examples @api.multi is used, but @api.one also may be used to deal with ids, depending on requirements (However, it's strongly recommended to use @api.multi instead of @api.one for performance reasons).

Or if it's simple function that does not have to deal with records/ids then for python method choose decorator:

  • @api.model - Allows to be polite with old style API.
  • @api.multi - Again, you can use it here as well, just pass [ ] (empty array) as first argument in javascript...


References: Odoo RPC documentation, Odoo 8 API method decorators