跳至内容
菜单
此问题已终结
1 回复
6150 查看

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

形象
丢弃
最佳答案

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.

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 ?

编写者

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.

相关帖文 回复 查看 活动
0
6月 15
3895
5
12月 19
7711
1
7月 15
9275
0
7月 15
3810
0
6月 15
120