Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
6491 Vistas

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>
    </record>

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

 

 

Avatar
Descartar
Autor

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

Mejor respuesta

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

from openerp import models, fields, api

    @api.model
    def change_article(self):
        print "hello"

Avatar
Descartar
Autor

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...)