When to use api.one and api.multi in odoo | openerp?

前端 未结 3 383
忘掉有多难
忘掉有多难 2021-02-02 01:07

Recently odoo (formerly OpenERP) V8 has been released. In new API method decorators are introduced. in models.py methods needs to be decorated with @api.one

3条回答
  •  被撕碎了的回忆
    2021-02-02 01:24

    @api.one:

    This decorator loops automatically on Records of RecordSet for you. Self is redefined as current record:

    @api.one
    def func(self):
        self.name = 'xyz'
    

    @api.multi:

    Self will be the current RecordSet without iteration. It is the default behavior:

    @api.multi
    def func(self):
        len(self)
    

    For the detailed description of all API you can refer this Link

提交回复
热议问题