Difference between @api.one and @api.multi ?

Hello , In this post we will discuss about the difference between @api.one and @api.multi which often cause confusing among Odoo developers ,we will try to make the difference clear.


@api.multi is used when we want to loop on records in this case self is the recordset  , the recordset hold multiple record so we need to loop manually to extract record , below the code showing the synapse to use @api.multi.

note : the  code is a edited code from the previous article http://wp.me/p8qqyC-4S



@api.one loop automatically on record hence self will hold be the current record information, so no need to add additional loop.


@api.multi with self.ensure_one():

if we want to verify that the Recordset hold a single record while using @api.multi ,we have to add self.ensure_one(),if Recordset hold more the system will throw and exceptions.


Thank You For reading ,if you have a question or any suggestion you can comment below or contact us from here : http://wp.me/P8qqyC-3


One thought on “Difference between @api.one and @api.multi ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.