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

I would like to add a server action to my module but I'm having trouble to find the correct syntax of object_write to do that: 

<record id="rest_env" model="ir.actions.server">
<field name="sequence" eval="5"/>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="rest.order"/>
<field name="code">Write on my fields here</field>
<field name="condition">True</field>
<field name="name">Rest_env</field>
</record>

In code I would like to update some fields, that's easy from the GUI, but I didn't understand how to do that from xml.

Odoo documentation doesn't offers examples for that...

Avatar
Descartar
Mejor respuesta

Example from crm_lead_view.xml:

        <record id="action_assign_salesman_according_assigned_partner" model="ir.actions.server">
<field name="name">Assign salesman of assigned partner</field>
<field name="model_id" ref="model_crm_lead"/>
<field name="state">code</field>
<field name="code">
if context.get('active_model') == 'crm.lead':
ids = []
if context.get('active_domain'):
ids = self.search(cr, uid, context['active_domain'], context=context)
elif context.get('active_ids'):
ids = context['active_ids']
if ids:
self.assign_salesman_of_assigned_partner(cr, uid, ids, context=context)
</field>
</record>


Avatar
Descartar
Autor

zbik, thanks for your reply but how this is supposed to help me with object_write? As far as I could understand I need to use

 use_write / current
Then I would like to understand the syntax.

Have you tried: self.write(cr, uid, ids, context=context) in the part at the end (where the example posted uses self.assign_salesman_of_assigned_partner ?

Autor

Nope. I give up. I'll add actions directly in Odoo every time a need, is really faster. I'm sorry to say that even with the new "skin" Odoo documentation is really inadequate.

Publicaciones relacionadas Respuestas Vistas Actividad
0
jun 15
3456
5
dic 19
7341
1
jul 15
8770
0
jul 15
3388
0
jun 15
120