تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
7 الردود
3662 أدوات العرض

I am creating a webhook that imports customer data from a CSV.

I am fairly new to this as this was recently added to Odoo 17 as a standard feature.

I have seen multi good videos etc and how to setup the automation rules.

However, all samples I see are about changing a record. What I am struggling what if what will the Target record code be for a new record and not a get.id code for an existing record. 

الصورة الرمزية
إهمال
أفضل إجابة

Hi Laurent,

I happend to have the exact same usecase as you.
We want to trigger webhooks from a remote system to create a new record instead of updating existing records.
After digging in the core code from Odoo (https://github.com/odoo/odoo/blob/ad299c9325e0a0faf18ba8b2709d4be2829b7158/addons/base_automation/models/base_automation.py#L473-L516) I found out that Odoo in fact simply doesn't support it.. *shrugs*

I've opened a pull request (code change) that serves as a basis to discuss a possible solution for this in the core. You can view it at https://github.com/odoo/odoo/pull/154408

Regards,
Yenthe

الصورة الرمزية
إهمال
الكاتب

Thanks Yenthe,
You are obviously much more familiar with this coding. However what you are saying, Create record through webhook, get the new record ID and the fill this record with data is exactly what I as novice expected already to be in place. Hopefully soon.

أفضل إجابة

Hi,

To create new record using webhook, see the method explained here:  Create a New Record Using Webhook in Odoo 17

Thanks

الصورة الرمزية
إهمال
أفضل إجابة

Use this odoo plugin to send or receive data from external website

Odoo Store Plugin: "odoo_dynamic_webhooks".

الصورة الرمزية
إهمال
أفضل إجابة

Use this odoo plugin to send or receive data from external website

Odoo Store Plugin: "odoo_dynamic_webhooks"

الصورة الرمزية
إهمال
أفضل إجابة

Hi does anyone have answer to this pls? 

الصورة الرمزية
إهمال
أفضل إجابة

+1 to trying to figure this out too.

I tried creating a new record in the Target Record field with 

env['crm.lead'].create({'name': payload['name': 'foo']})

but it looks like this happens in a safety evaluation here. I'm not sure what that entails yet but that throws many errors I haven't decided to look into yet.

It also looks like it's not bringing in the env variable like it says it is right above it or I'm not accessing it correctly. I feel like env['crm.leads']​ shouldn't come back with an error that env is undefined.

I tried selecting a dummy record statically and then creating it in my Execute Code block too but that's causing all kinds of 500 page dead errors:

env['crm.lead'].create({
    'name': "FooBar",
    "user_id": 2
})

But this kicks back a 'dict' object has no attribute 'name'​ error from ir.logging when I wrap it in an except block. 

الصورة الرمزية
إهمال
أفضل إجابة

Have you seen this, which covers sending and receiving records:


الصورة الرمزية
إهمال
الكاتب

Thanks Ray, I know this video inside out already. While I certainly recommend it for anyone starting with Webhooks, it does not address the core issue I am facing. The sample shows also use update records etc, there is no example worked out to create a record.
In odoo the Target record field needs to be filled in. However what do I need to fill in there since the"target" record does not exist yet but I want it to be created.

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
يوليو 24
1264
4
مارس 24
2815
2
يونيو 16
3198
3
يناير 16
4518
0
ديسمبر 24
716