Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

What is the use of @api.returns?

By
Karthik Arumugam
on 10/20/15, 7:11 AM 639 views

Please any one explain me about the use of @api.returns with simple example.

1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 10/20/15, 7:51 AM

Hello Karthik,

@api.returns specify what needs to be return, either id, ids, False or recordset.

Documentation:

1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 10/20/15, 9:49 AM

Hello Karthik,

@api.returns is the decorator, with the help of it you can return anything you want from specific function. So for example generally create method returns the record set of newly created record for particular model. Now for that specific model, if you want to return an dictionary instead of that record set, then you can define @api.returns like as follows,

@api.returns(self, lamda s: {s.id:s}) 
def create(self, vals)
res = super(xx, self).create(vals)
return res

Above method will return the dictionary of the record set ( { ID : Recordset } ), not just an record set of specific model.

Another good example to use @api.returns in a best way is :

Generally write method returns the Boolean value ( True or False ). That returned value becomes useless sometimes. So with usage of  @api.returns you can return the Recordset / List of ids which are successfully updated. ( With the magic of inheritance you can perform this thing into your specific model only. It's wonderful, No ?? )

I am not giving more lengthy specifications as other links are good for you to understand this concept into depth. Sometimes just concept clearance with a good example is necessary rather then read the detailed documentations first. And I hope i have been able to clear your confusion regarding @api.returns with proper example.

Hope this helps,

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/20/15, 7:11 AM
Seen: 639 times
Last updated: 7/13/16, 5:53 AM