Skip to Content

Contributors

Re: Technical Question: Restart Odoo process after res.partner model change

Janik, I'm afraid your deployment process is not correct, not an Odo bug, as both updating or installing changes DB schema, but obviously the Python code should be reloaded for this to happen (aka, the service should be restarted). Questioning an expert like Graeme with a lot of years of experience in such basic things is not a good practice IMO.

Regards.

by Pedro M. Baeza - 09:01 - 21 Jun 2024

Reference

  • Technical Question: Restart Odoo process after res.partner model change
    Hello Odoo contributors,
    
    I am developing, deploying and fixing Odoo for a while and there is one 
    issue I haven't bothered enough to come up with a proper solution or 
    strategy.
    
    The problem is simple: I have an Odoo instance running with a module 
    that extends the res.partner model. The res.partner code of this module 
    is updated with a new field. The Odoo server is restarted and exits with 
    a "column does not exist" error.
    
    The same procedure works for modules that extend other models than 
    res.partner or res.user. As I understand the res.partner (and other) 
    tables are queried when the Odoo process starts. The SQL queries fail, 
    because the model code does not match the database schema.
    
    The solution to the problem seems obvious, before starting the Odoo 
    server with the new code you install module (odoo-bin -i ...). However, 
    automating this step in a deployment pipeline is difficult as you don't 
    know which module needs to be updated. Always updating the base module 
    seems like an overkill.
    
    Do you know this problem? Have you solved this problem?
    
    I would be glad to hear from you.
    
    Regards,
    
    Janik
    
    Here is a guide to reproduce the issue with https://odoo.build/:
    
    1. Init a new datbase and start the Odoo server: `task start db; task 
    init-db; task start native`
    
    2. Install the contacts module: `task install-module contacts`
    
    3. Stop the Odoo process.
    
    4. Add a new field to the res.partner code: `vi 
    odoo/odoo/addons/base/models/res_partner.py`
    
    ```python
    
    xy = fields.Char()
    
    ```
    
    5. Start the Odoo server: `task start native`
    
    It fails with:
    
    ```
    
    ...
    
    psycopg2.errors.UndefinedColumn: column res_partner.xy does not exist
    LINE 1: ..."message_bounce", "res_partner"."name" AS "name", "res_partn...
    ```                                                        ^
    
    
    -- 
    We are hiring: https://www.mint-system.ch/jobs
    Send application to: jobs@mint-system.ch
    
    CTO Mint System GmbH
    Tel: +41 44 244 7222
    
    

    by Janik von Rotz - 05:22 - 20 Jun 2024