Skip to Content
Menu
This question has been flagged
2 Replies
5039 Views

Hi everyone,

2 short questions :

1:
raise Usererror('test') and datetime() are causing empty errors on Odoo 15.0 community edition. Whats wrong there?

2:
Is it possible to call python function from automated actions? if it is, I would be grateful for an example.

Br

Sascha

Avatar
Discard
Author Best Answer

Okay- I will give the answer for me myself :

raise Usererror('test') and datetime() are causing empty errors on Odoo 15.0 community edition. Whats wrong there?

Version of Odoo 15 Community is to old, update to newer Version and RPC_Error is not empty anymore
https://github.com/odoo/odoo/pull/79399

This is also Answer to question 2 as it now gives back a qualified error message to debug.
Cheers :)

Avatar
Discard
Best Answer

Hello Sascha,

I have included an example from the automation action as well as the preferred Odoo document.
https://www.odoo.com/documentation/16.0/applications/productivity/studio/automated_actions.html

Please find code in comment.

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

<record id="test_rule_on_write" model="base.automation">
<field name="name">Base Automation: test rule on write</field>
<field name="model_id" ref="base_automation.model_base_automation_lead_test"/>
<field name="state">code</field>
<field name="code" eval="'records.write({\'user_id\': %s})' % ref('base.user_demo')"/>
<field name="trigger">on_write</field>
<field name="active" eval="True"/>
<field name="model_id" ref="base_automation.model_base_automation_lead_test"/>
<field name="filter_domain">[('state', '=', 'done')]</field>
<field name="filter_pre_domain">[('state', '=', 'open')]</field>
</record>

OR

.xml file

<record id="test_rule_on_write" model="base.automation">
<field name="name">Base Automation: test rule on write</field>
<field name="model_id" ref="base_automation.model_base_automation_lead_test"/>
<field name="state">code</field>
<field name="trigger">on_write</field>
<field name="active" eval="True"/>
<field name="model_id" ref="base_automation.model_base_automation_lead_test"/>
<field name="filter_domain">[('state', '=', 'done')]</field>
<field name="filter_pre_domain">[('state', '=', 'open')]</field>
<field name="code">
if records:
records._my_func()
</field>
</record>

.py file

def _my_func(self):
add your code here....

Author

Hey Jainesh !
Thankyou so much for your help, but unfortunately, I already tried this.
I get the same empty RPC_Error as I get on raise UserError('something').

On the other Hand this works well :
if record['service_state'] == "verzug_1":
env['esc.sst'].browse(record['id']).copy({'parent_id':record['id'],'service_state':'verzug_1','fk_status':3})

Related Posts Replies Views Activity
0
Sep 23
671
0
May 24
334
1
Mar 24
293
1
Jun 24
658
1
Jan 24
412