Odoo CRM

Zapier

Sending postcards from Odoo CRM can be done with the Zapier integration we have developed. Every time a new lead is created in Odoo CRM, a personalized postcard can be sent via the Print.one API.

Click here for the Odoo CRM - Zapier integration.

Odoo webhook integration

Below is a step-by-step guide to setting up a webhook in Odoo CRM to send a JSON payload to the Print.one API.


Preparation

Odoo Account

Ensure you have access to your Odoo CRM instance with sufficient administrative privileges.

Print.one API Key

Obtain your API key from Print.one. Use a TEST API key for testing and a LIVE API key for production.


Step 1: Log in to Odoo

Log in to your Odoo CRM account using your credentials.


Step 2: Navigate to Developer Mode

Enable Developer Mode in Odoo to access advanced settings:

  1. Go to the top-right corner of the interface.

  2. Click your profile and select

    Activate the Developer Mode

    (or similar, depending on your Odoo version).


Step 3: Go to Automated Actions

  1. Navigate to Settings → Technical → Automation → Automated Actions.

  2. Click Create to add a new automated action.


Step 4: Configure the Automated Action

Fill in the following details for the automated action:

  • Name: Enter a name for the action, such as "Send to Print.one API".

  • Model: Select the Odoo model associated with the webhook (e.g., "Lead/Opportunity" for CRM leads).

  • Trigger Condition: Choose when the webhook should be triggered, e.g.:

    • On Creation

    • On Update

    • On Deletion

  • Apply On: Specify any additional conditions (optional), such as filtering by lead stage.


Step 5: Add the Webhook Call

  1. Under the Action To Do section, select Execute Python Code.

  2. Paste the following Python code to perform the webhook call:

Python code example for Odoo CRM
1import requests
2
3# Define the endpoint and headers
4url = "https://api.print.one/v2/orders"
5headers = {
6 "X-API-KEY": "YOUR_API_KEY", # Replace with your Print.one API key
7 "Content-Type": "application/json"
8}
9
10# Define the payload
11payload = {
12 "sender": {
13 "name": "Your Name",
14 "address": "Street 123",
15 "postalCode": "1234AB",
16 "city": "Amsterdam",
17 "country": "Netherlands"
18 },
19 "recipient": {
20 "name": "{{Field_Name}}",
21 "address": "{{Field_Name}}",
22 "postalCode": "{{Field_Name}}",
23 "city": "{{Field_Name}}",
24 "country": "{{Field_Name}}"
25 },
26 "mergeVariables": {
27 "firstname": "{{Field_Name}}",
28 "discount": "{{Field_Name}}",
29 "couponcode": "{{Field_Name}}"
30 },
31 "templateId": "tmpl_1234567890987654321",
32 "finish": "GLOSSY",
33 "billingId": "Your attribute or campaign name for cost allocation"
34}
35
36# Send the POST request
37response = requests.post(url, headers=headers, json=payload)
38
39# Log the response (optional, for debugging)
40if not response.ok:
41 raise Exception(f"Failed to send webhook: {response.status_code} - {response.text}")

  1. Replace YOUR_API_KEY with your Print.one API key.

  2. Modify the product_id and other fields as needed to match your Print.one setup.


Step 6: Save and Test

  1. Save the automated action.

  2. Test the webhook:

    • Create or update a record in Odoo CRM that matches the trigger condition.

    • Check in Print.one if the order was received correctly.

    • If using a TEST API key, the order will not be printed or shipped, but a PDF will be generated.

    • If using a LIVE API key, the order will be printed and shipped.


Step 7: Troubleshooting

If the webhook doesn’t work as expected, check the following:

  1. API Key: Ensure the X-API-KEY header contains the correct API key (TEST for testing, LIVE for production).

  2. JSON Payload: Verify the structure of the payload and that it includes the correct data.

  3. URL: Confirm the URL is set to https://api.print.one/v2/orders.

  4. Automated Action: Ensure the action triggers on the appropriate events in Odoo.

  5. Python Code: Check for syntax errors or missing fields in the code.


Step 8: Use the LIVE API Key for Production

Once you’ve confirmed the webhook works with the TEST API key:

  1. Replace the TEST API key with your LIVE API key in the Python code.

  2. Run the test again to ensure everything functions correctly.