Skip to content

Odoo live Q&A session Tutorial

  • Odoo
Odoo live Q&A session

Automate Your Odoo Workflows

Introduction

Firstly, this Odoo live Q&A session tutorial walks you through automation techniques that experts demonstrated in a recent live Odoo Q&A. Next, you will learn how to leverage server actions, Kanban stage triggers, and scheduled tasks in Odoo 18. Moreover, we provide clear code examples and step-by-step guidance. Additionally, we share best practices and tips from the interactive Odoo Q&A. Finally, you will find external resources to expand your knowledge on Odoo automation.


What Is an Odoo live Q&A session?

Firstly, an Odoo live Q&A session brings developers and users together in real time. Then, attendees can ask questions about module development, configuration, and automation. Additionally, presenters show code snippets and demo workflows live. Moreover, the session records practical use cases, often covering advanced topics such as server actions, scheduled tasks, and Studio customization. Furthermore, you can rewind the session to revisit critical steps.

Key Benefits of an Interactive Odoo Q&A

  • Real-time feedback on automation challenges
  • Detailed walkthroughs of code examples
  • Expert tips on performance and security
  • Direct link to community support via Odoo Forum

Preparing Your Environment for the Live Odoo Q&A

Firstly, install Odoo 18 on your local or test server. Then, clone the latest Odoo 18 repo from GitHub. Moreover, enable Developer Mode in your database. Additionally, install the Studio app to use drag-and-drop features. Finally, ensure you have a test CRM, Project, and Accounting database preconfigured.

Installing Odoo 18

  1. Update system packages sudo apt update && sudo apt upgrade -y
  2. Install dependencies sudo apt install python3-pip python3-dev build-essential \ libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev \ libldap2-dev libjpeg-dev libpq-dev
  3. Clone Odoo git clone https://github.com/odoo/odoo.git --branch 18.0 --depth 1
  4. Install Python requirements pip3 install -r odoo/requirements.txt
  5. Create a PostgreSQL user and database

Accessing the Q&A Recording

Additionally, view the Odoo live Q&A session video on the official YouTube channel. Moreover, download the subtitle file Odoo insider: regular Live Q&A session [PjEwxo4Swko].id.vtt from the session page. Finally, load it into a text editor to extract code examples and pointers.


Automating CRM-to-Project Link with Server Actions

Firstly, you can automate lead conversion by linking CRM leads to a Project. Then, Odoo server actions let you write Python code to handle this logic. Moreover, you can trigger a server action when the lead stage changes. Furthermore, the live Odoo session transcript shows how to integrate CRM to Project.

Creating a Server Action

  1. Go to Settings > Technical > Automation > Server Actions
  2. Click Create; set Model to CRM Lead
  3. Choose Action To Do as Execute Python Code
  4. Enter a descriptive name, e.g. Link Lead to Project

Writing Python Code for Server Action

# Runs when a CRM Lead stage changes to 'Won'
if record.stage_id.name == 'Won':
    # Search or create project by team name
    project = env['project.project'].search(
        [('name', '=', record.team_id.name)], limit=1
    )
    if not project:
        project = env['project.project'].create({
            'name': record.team_id.name,
        })
    # Create task linked to the lead
    env['project.task'].create({
        'name': record.name,
        'project_id': project.id,
        'partner_id': record.partner_id.id,
    })
    # Display success notification
    action = {
        'type': 'ir.actions.client',
        'tag': 'display_notification',
        'params': {
            'title': 'Task Created',
            'message': f'Task for lead "{record.name}" created',
            'type': 'success',
            'sticky': False,
        },
    }
    return action

Explanation of Code

  • First, the code checks if the lead stage equals 'Won'.
  • Next, it searches for an existing project or creates one.
  • Then, it creates a task using lead details.
  • Finally, it returns a client action to show a notification.

Testing the Server Action

  1. Open a CRM Lead record
  2. Change the stage to Won
  3. Confirm a new project or task appears
  4. Verify the success notification

Triggering Automations in Kanban Stages

Firstly, live Odoo Q&A experts used Odoo Studio to set automated actions based on Kanban stage changes. Then, you can link your server action to a specific stage. Moreover, this feature follows the Odoo Q&A session demonstration.

Using Odoo Studio for Kanban Automation

  1. Enable Developer Mode
  2. Open a Kanban view (e.g., CRM > Pipeline)
  3. Click the Studio icon
  4. Select Automations > On Stage Changed
  5. Add your Link Lead to Project server action

Configuring Kanban Stage Rules

Additionally, set conditions for automation:

  • Trigger: Stage changes to Won
  • Action: Execute Link Lead to Project
    Moreover, you can restrict automation by team or user role. Then, click Save.

Scheduling Fiscal Year Closing with Cron Jobs

Firstly, you can automate fiscal year closing via Scheduled Actions. Then, a cron job runs Python code at set intervals. Moreover, the interactive Odoo Q&A explained how to close past years and log entries.

Creating a Scheduled Action

  1. Go to Settings > Technical > Automation > Scheduled Actions
  2. Click Create; set Model to Fiscal Year
  3. Enter Frequency (e.g., Daily)
  4. Choose Execute Python Code

Python Code to Close Fiscal Year

from datetime import date

years_to_close = env['account.fiscal.year'].search([
    ('date_end', '<', date.today()),
    ('state', '!=', 'done'),
])
for fy in years_to_close:
    fy.write({'state': 'done'})
# Log the action
env['ir.logging'].create({
    'name': 'Fiscal Year Closure',
    'type': 'server',
    'dbname': env.cr.dbname,
    'level': 'info',
    'message': f'Closed {len(years_to_close)} fiscal years',
    'path': 'scheduled.fiscal_closure',
})

Explanation of Fiscal Closure Code

  • First, import date for comparison
  • Next, search for fiscal years that ended before today
  • Then, set each found year’s state to done
  • Finally, log the number of years closed

Best Practices from the Odoo live Q&A session

Firstly, experts recommended investigating your business needs before automating. Then, they advised keeping code simple. Moreover, you should test automations in a staging or Runbot instance. Additionally, document your server actions and scheduled jobs. Finally, for complex logic, consider building a custom module.

Investigate Your Needs First

  • Ask stakeholders what to automate
  • Draft a workflow diagram
  • Identify edge cases, such as missing partner data

Keep Logic Simple

  • Use clear variable names
  • Avoid nested loops when possible
  • Return meaningful messages for users

Test in Runbot

  1. Set up a Runbot instance: https://runbot.odoo.com/latest
  2. Import your server actions
  3. Execute test scenarios
  4. Fix errors before production

Document Your Automations

  • Comment your Python code
  • Use a consistent naming convention
  • Maintain a reference document in your wiki

Create a Custom Module for Complex Logic

  1. Scaffold a module: odoo-bin scaffold auto_workflow addons/auto_workflow
  2. Define models and scheduled actions
  3. Add security rules and docs
  4. Upgrade via Apps > Update Apps List

How to Ask Questions in the Next live Odoo Q&A

Firstly, prepare detailed use cases. Then, submit tickets before the session. Moreover, ask directly in chat during the live event. Additionally, record your screen to show errors. Finally, follow up on answered questions in the session thread.

Prepare Your Use Cases

  • Write clear subject lines
  • Include model names and record IDs
  • Attach screenshots of errors or logs

Submit Tickets

  • Use the Odoo Support Portal
  • Tag your ticket: automation, server action, scheduled action
  • Attach logs and transcripts

Provide Reproducible Cases

  • Use a fresh database for testing
  • List exact steps to reproduce
  • Share minimal code in a Gist or Pastebin

Advanced Automations Inspired by the Live Odoo Q&A session

Firstly, the Odoo live Q&A session included advanced use cases. Then, we review three: WhatsApp autoresponder, customer onboarding, and API data sync. Moreover, these examples show how to extend core processes with custom code. Furthermore, they highlight integration with external services.

Use Case 1: Automated WhatsApp Message for New Leads

Overview

In the Q&A, a user asked for an automatic WhatsApp response when a new CRM lead arrives. Additionally, they wanted to avoid manual messaging.

Code Example

import requests

if record.id:
    phone = record.partner_id.phone
    message = f"Hello {record.partner_id.name}, thanks for contacting us!"
    url = "https://api.whatsapp.com/send"
    params = {'phone': phone, 'text': message}
    response = requests.get(url, params=params)
    if response.status_code == 200:
        record.message_post(
            body=f"Sent WhatsApp message to {phone}",
            message_type='comment'
        )
    else:
        record.message_post(
            body=f"Failed to send to {phone}: {response.text}",
            message_type='warning'
        )

Explanation

  • First, import requests for HTTP calls.
  • Next, fetch the phone number and craft a message.
  • Then, send a GET request to WhatsApp’s click-to-chat API.
  • Finally, log success or failure in the lead’s chatter.

Use Case 2: Automated Customer Onboarding

Overview

Secondly, presenters showed automating onboarding tasks when a customer registers online. Additionally, they suggested creating tasks and sending welcome emails.

Code Example

if record._origin.signup_completed:
    task = env['project.task'].create({
        'name': f"Welcome call to {record.name}",
        'user_id': env.uid,
        'project_id': env.ref('project.project_project_sales').id,
        'partner_id': record.id,
    })
    template = env.ref('sale_rental.email_template_rental_welcome')
    template.send_mail(record.id, force_send=True)

Explanation

  • First, check if signup finished.
  • Next, create a task in the Sales project.
  • Then, retrieve an email template by XML ID.
  • Finally, send the welcome email.

Use Case 3: Syncing Product Data with External API

Overview

Then, a participant asked about syncing product prices from an external ERP. Moreover, the expert showed a scheduled action for data sync.

Code Example

import requests

url = "https://api.vendor.com/products"
response = requests.get(url)
if response.status_code == 200:
    products = response.json().get('data', [])
    for item in products:
        prod = env['product.product'].search(
            [('default_code', '=', item['sku'])], limit=1
        )
        vals = {'list_price': item['price']}
        if prod:
            prod.write(vals)
        else:
            env['product.product'].create({
                'name': item['name'],
                'default_code': item['sku'],
                **vals,
            })

Explanation

  • First, request the vendor API.
  • Next, loop through returned items.
  • Then, update existing products or create new ones.
  • Finally, rely on Odoo’s ORM for consistency.

Debugging and Logging Tips from the Live Odoo Q&A session

Firstly, experts emphasized clear logging. Then, you will learn how to use Odoo’s built-in logger and filter logs effectively.

Using Odoo’s Logger

import logging
_logger = logging.getLogger(__name__)

_logger.debug(f"Starting automation for record {record.id}")
try:
    # Your automation code here
    pass
except Exception as e:
    _logger.error(f"Automation error: {e}", exc_info=True)
    raise
_logger.info("Automation completed successfully")

Explanation

  • First, import Python’s logging module.
  • Next, get a logger specific to your module.
  • Then, write debug, info, and error logs.
  • Finally, use exc_info=True to include tracebacks.

Filtering Logs

  1. Go to Settings > Technical > Logs > Log Records
  2. Filter by Level set to Error
  3. Search by Path to narrow results to your module

Performance Considerations

Firstly, ensure your server actions and cron jobs run efficiently. Then, avoid full model searches inside loops. Moreover, use domain filters and limit=1 where possible. Additionally, consider caching reused data. Finally, test performance on large datasets and schedule jobs for off-peak hours.


Resources and Further Learning


Conclusion

Firstly, this Odoo live Q&A session tutorial showed you how to automate CRM-to-Project workflows, Kanban triggers, and fiscal year closing. Next, you wrote Python code for server actions and scheduled cron jobs. Moreover, you learned best practices shared during the live Odoo Q&A. Additionally, you discovered how to prepare questions for future sessions. Finally, you found useful links to deepen your Odoo automation skills.

Now, you can apply these techniques in your Odoo 18 instance. Moreover, join the next Odoo live Q&A session to get direct help from experts. Good luck with your Odoo development journey!


Discover more from teguhteja.id

Subscribe to get the latest posts sent to your email.

Leave a Reply

WP Twitter Auto Publish Powered By : XYZScripts.com