Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
154 มุมมอง

Hey everyone,

I’m working on integrating Odoo subscriptions with my app through webhooks, and I’ve been able to make some progress — but I’m stuck on a few fields.


What I Have So Far


I managed to set up a webhook that triggers when the “next invoice date” of a subscription changes. The webhook is connected to my Edge Function, and it’s receiving data correctly.


What I’m Trying to Add


I’d like to include a few more details in the webhook payload, but I couldn’t find them in the subscription model:


Last invoice ID


Status (active, expired, canceled, etc.)


Current period end (right now I’m just using the “next invoice date” as a placeholder)


The Problem


When creating the webhook in Odoo, I couldn’t find a clear way to include these variables — especially the status field. I’m not sure if it’s missing from the subscription model or if it’s stored in a related model (like invoices or analytic accounts).


Has anyone worked with subscription webhooks before or figured out how to include these kinds of fields in the payload? Any pointers or examples would be really helpful.


Thanks!


อวตาร
ละทิ้ง

Can you clarify what you're missing exactly, how you're trying to create the webhook and what your configuration is?

คำตอบที่ดีที่สุด

Hi,

To enhance your Odoo subscription webhook integration by including additional details such as the last invoice ID, subscription status, and current period end, you can utilize Odoo's built-in automation features.

Create a New Automated Action:

Navigate to Settings > Technical > Automation > Automated Actions.

Click on Create to define a new automated action.

Model: Select Subscription.

Trigger: Choose On Update to capture changes in subscription records.

Action To Do: Select Execute Python Code.


Python Code: Use the following script to compile the necessary subscription details:


subscription = record

last_invoice = subscription.recurring_invoice_ids.sorted('id')[-1] if subscription.recurring_invoice_ids else None

payload = {

    "subscription_id": subscription.id,

    "next_invoice_date": subscription.recurring_next_date,

    "current_period_end": getattr(subscription, 'recurring_next_date_end', None),

    "last_invoice_id": last_invoice.id if last_invoice else None,

    "last_invoice_name": last_invoice.name if last_invoice else None,

    "status": subscription.state

}

# Send the payload to your external system's webhook URL


Refer:

1. https://www.odoo.com/documentation/19.0/applications/studio/automated_actions/webhooks.html

Detailed information on setting up webhooks in Odoo

2. https://www.odoo.com/documentation/19.0/applications/studio/automated_actions.html

Automation rules — Odoo 19.0 documentation: Learn how to automate actions in Odoo, including sending data to external systems via webhooks


Hope it helps.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 25
557
0
เม.ย. 25
1084
0
ก.ย. 25
410
0
ต.ค. 25
159
2
ก.ค. 25
1351