Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
7 Odpovědi
3609 Zobrazení

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. 

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor

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.

Nejlepší odpověď

Hi,

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

Thanks

Avatar
Zrušit
Nejlepší odpověď

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

Odoo Store Plugin: "odoo_dynamic_webhooks".

Avatar
Zrušit
Nejlepší odpověď

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

Odoo Store Plugin: "odoo_dynamic_webhooks"

Avatar
Zrušit
Nejlepší odpověď

Hi does anyone have answer to this pls? 

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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


Avatar
Zrušit
Autor

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.

Related Posts Odpovědi Zobrazení Aktivita
0
čvc 24
1221
4
bře 24
2739
2
čvn 16
3132
3
led 16
4456
0
pro 24
675