odoo-8 RPC using Odoo v8 API (Call Python function from JavaScript) An example Odoo model to call methods from

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

class my_model(models.Model):
    _name = "my.model"

    name = fields.Char('Name')

    @api.multi
    def foo_manipulate_records_1(self):
        """ function returns list of tuples (id,name) """
        return [(i.id,i.name) for i in self]

    @api.multi
    def foo_manipulate_records_2(self, arg1, arg2)
        #here you can take advantage of "self" recordset and same time use aditional arguments "arg1", "arg2"
        pass

    @api.model
    def bar_no_deal_with_ids(self, arg1, arg2):
        """ concatenate arg1 and arg2 """
        return unicode(arg1) + unicode(arg2)


Got any odoo-8 Question?