Skip to Content
Menu
This question has been flagged
1 Reply
5321 Views

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
Discard
Best Answer

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
Discard
Author

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 ?

Author

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.

Related Posts Replies Views Activity
0
Jun 15
2971
5
Dec 19
6756
1
Jul 15
8016
0
Jul 15
2763
0
Jun 15
120