Skip to Content

Contributors

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

Hi Janik,

On 6/21/24 14:02, Janik von Rotz wrote:
A simple solution is probably a fixed list of modules that should always 
be updated (from the cli) after the code change and before restarting 
the Odoo container.

This is indeed the more crude solution that we generally use for our clients - either figure out by hand which modules to update if you're in a hurry, or just `-u base`.

But the two solutions mentioned are smarter in that sense because they figure out from the code change what to update.

Cheers


by Tom Blauwendraat - 02:31 - 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