Odoo Help


Where can I use @ in Odoo?

Billiard R Made
on 11/20/14, 5:06 AM 1,640 views

from openerp import api, models

Being new to Python and OpenERP I have quite a bunch of questions.  One of then is, in my code where can I use @?  I see an example I got from https://www.odoo.com/documentation/8.0/reference/reports.html and here I would also like to know what @api.multi is in this piece of code below.  May you also recommand reading material on Python, XML and Java relevant to OpenERP

class ParticularReport(models.AbstractModel):

    _name = 'report.<<module.reportname>>'


    def render_html(self, data=None):

         report_obj = self.env['report']

         report = report_obj._get_report_from_name('<<module.reportname>>')

         docargs = {

                'doc_ids': self._ids,

                'doc_model': report.model,

                'docs': self,


        return report_obj.render('<<module.reportname>>', docargs)



| 8 8 8

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

On 11/20/14, 5:10 AM

For the general part:
I'm not exactly sure about what you would like to learn or find out but there is some great documentation to be found.
All developer documentation: https://www.odoo.com/documentation/8.0/
Tutorials: https://www.odoo.com/documentation/8.0/howtos/backend.html
Overview of parameters: https://www.odoo.com/documentation/8.0/reference.html

For the part about @api.multi (and @api.one):
The @api.one is specific for one record and can not be used for multiple records. It automaticly loops on records of of a Recordset for you. 
@api.many is for multiple records, where you can loop through it etc. It will be the current Recordset without the itiration. So any looping would need to be programmed by yourself, for whatever you want

An example of @api.one:

@api.one def _compute_name(self):
      self.name = str(random.randint(1, 1e6))

An example of @api.multi:

@api.multi def subscribe(self):
     for session in self.session_ids:
         session.attendee_ids |= self.attendee_ids
     return {}

You can read more about the @api.one and @api.multi here: http://odoo-new-api-guide-line.readthedocs.org/en/latest/decorator.html

I hope this gives you a good start and enough information. If you need more or have other questions do ask.

Thanks so much. So what is @ ??? Is anything that starts with @ a controller or what?

Billiard R Made
on 11/20/14, 5:41 AM

I can't tell you for sure where the @ stands for but I believe its built as a reference and is being used by the Odoo ORM. But I'd like this question open for somebody else to reply, as I'm not 100% sure of this. If my answer was helpful please upvote or accept it by the way! :)

on 11/20/14, 5:54 AM
On 12/30/15, 8:11 AM

If you want to learn more about the power (or should I say magic...), take a look at the very good blog of Simon Franklin http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/. In this blog you learn step by step what a python decorator is and how powerful decorators are.
Personally, I often use decorators to automatically add log messages to important methods. Don't hesitate to ask you if want some more advises. 

Best regards


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/20/14, 5:06 AM
Seen: 1640 times
Last updated: 12/30/15, 8:11 AM