Odoo Help


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.


How do I write server action with new api?

on 10/29/14, 12:43 AM 1,236 views

I am trying to change an existing server action to new api using the code as follows

    <record id="change_article" model="ir.actions.server">
      <field name="name">Change Article</field>
      <field name="type">ir.actions.server</field>
      <field name="model_id" ref="model_article"/>
      <field name="state">code</field>
      <field name="code">self.change_article()</field>

But this does not work. It was working earlier when i was passing cr, uid, context etc to self.change_article(). Shouldnt these be available now from env object or am i still required to pass these from the view



change_article(cr=cr, uid=uid, ids=context.get('active_ids'), context=context) worked

on 11/22/14, 12:38 AM

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 10/29/14, 2:44 AM

use @api.model in the method "def change_article(..."

from openerp import models, fields, api

    def change_article(self):
        print "hello"

Thanks. I have already used it. But what about the signature in xml. self.change_article(). Does this remain like this or does it have to confirm to old api like self.change_article(cr, uid, ids, context...)

on 10/29/14, 3:21 AM

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)


Asked: 10/29/14, 12:43 AM
Seen: 1236 times
Last updated: 5/14/15, 5:04 AM