Odoo Help

Welcome!

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.

0

[V8] XML for server action: how to write on fields?

By
FEDERICO LEONI
on 6/19/15, 1:52 PM 515 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...

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 6/19/15, 2:31 PM

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>


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.
FEDERICO LEONI
on 6/19/15, 3:14 PM

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 ?

Bista Solutions US, Ray Carnes
on 6/19/15, 4:30 PM

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.

FEDERICO LEONI
on 6/19/15, 7:48 PM

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)

Stats

Asked: 6/19/15, 1:52 PM
Seen: 515 times
Last updated: 6/19/15, 2:31 PM