Skip to Content

Contributors

How to test v14 upgrade scripts

Hi all,

we are porting to 14.0 the OCA/l10n-italy modules and developing some upgrade scripts, like this

Our doubt: is this testable?
In general, is it possible to test v14 upgrade scripts before OpenUpgrade is available for v14?

Thanks!

--

by Lorenzo Battistini. - 10:06 - 29 Jan 2021

Follow-Ups

  • Re: How to test v14 upgrade scripts
    Il giorno ven 29 gen 2021 alle ore 11:27 Holger Brunn
    <mail@hunki-enterprises.com> ha scritto:
    
    >
    
    > > In general, is it possible to test v14 upgrade scripts before OpenUpgrade is
    
    >
    
    > > available for v14?
    
    >
    
    > yes, you don't need OpenUpgrade for that.
    
    
    We did some test using a pre-migrate script like the one linked by Lorenzo (*).
    The main purpose is to change the name of the module, as well as
    rename xmlids, model and tables.
    
    Steps:
    
    1) old_name module installation
    2) add/change some data
    3) checkout to commit containing new_name module, migration script and
    version bumped
    4) launch old_name_module update:
    ./odoo-bin -c etc/odoo14.cfg -d testdb -u old_name_module --stop-after-init
    
    Output:
    old_name_module: not installable, skipped
    
    In fact pre-migrate script is not triggered.
    
    We tried this also:
    4) launch new_name_module update:
    ./odoo-bin -c etc/odoo14.cfg -d testdb -u new_name_module --stop-after-init
    
    But it didn't work as well.
    
    
    The only way (we have found so far) to trigger pre-migrate script is this:
    
    1) old_name module installation
    2) add/change some data
    3) checkout to commit containing new_name module, migration script and
    version bumped
    4) execute odoo shell
        >>> from openupgradelib import openupgrade
        >>> openupgrade.update_module_names(env.cr, [('old_name_module',
    'new_name_module'),], merge_modules=False,)
        >>> env.cr.commit()
    5) launch new_name_module update:
    ./odoo-bin -c etc/odoo14.cfg -d testdb -u new_name_module --stop-after-init
    
    
    Do you know a way to trigger the migration script without using odoo shell?
    
    Thanks in advance.
    S.
    
    
    (*) https://github.com/OCA/l10n-italy/blob/0d65b1f7fa23facd9ef52749571a4a18a58f4045/l10n_it_vat_payability/migrations/14.0.1.0.0/pre-migrate.py
    

    by Sergio Zanchetta - 10:15 - 28 Apr 2021
  • Re: How to test v14 upgrade scripts
    Il giorno ven 23 apr 2021 alle ore 15:20 Sergio Zanchetta
    <primes2h@gmail.com> ha scritto:
    
    >
    
    > Il giorno ven 29 gen 2021 alle ore 11:27 Holger Brunn
    
    > <mail@hunki-enterprises.com> ha scritto:
    
    > >
    
    
    > The only way (we have found so far) to trigger pre-migrate script is this:
    
    >
    
    > 1) old_name module installation
    
    > 2) add/change some data
    
    > 3) checkout to commit containing new_name module, migration script and
    
    > version bumped
    
    > 4) execute odoo shell
    
    > >>> from openupgradelib import openupgrade
    
    > >>> openupgrade.update_module_names(env.cr, [('l10n_it_codici_carica', 'l10n_it_appointment_code'),], merge_modules=False,)
    
    Sorry, this one is obviously:
    
    >>> openupgrade.update_module_names(env.cr, [('old_name_module', 'new_name_module'),], merge_modules=False,)
    

    by Sergio Zanchetta - 10:14 - 28 Apr 2021
  • Re: How to test v14 upgrade scripts
    Il giorno ven 29 gen 2021 alle ore 11:27 Holger Brunn
    <mail@hunki-enterprises.com> ha scritto:
    
    >
    
    > > In general, is it possible to test v14 upgrade scripts before OpenUpgrade is
    
    >
    
    > > available for v14?
    
    >
    
    > yes, you don't need OpenUpgrade for that.
    
    
    We did some test using a pre-migrate script like the one linked by Lorenzo (*).
    The main purpose is to change the name of the module, as well as
    rename xmlids, model and tables.
    
    Steps:
    
    1) old_name module installation
    2) add/change some data
    3) checkout to commit containing new_name module, migration script and
    version bumped
    4) launch old_name_module update:
    ./odoo-bin -c etc/odoo14.cfg -d testdb -u old_name_module --stop-after-init
    
    Output:
    old_name_module: not installable, skipped
    
    In fact pre-migrate script is not triggered.
    
    We tried this also:
    4) launch new_name_module update:
    ./odoo-bin -c etc/odoo14.cfg -d testdb -u new_name_module --stop-after-init
    
    But it didn't work as well.
    
    
    The only way (we have found so far) to trigger pre-migrate script is this:
    
    1) old_name module installation
    2) add/change some data
    3) checkout to commit containing new_name module, migration script and
    version bumped
    4) execute odoo shell
    
    >>> from openupgradelib import openupgrade
    
    >>> openupgrade.update_module_names(env.cr, [('l10n_it_codici_carica', 'l10n_it_appointment_code'),], merge_modules=False,)
    
    >>> env.cr.commit()
    5) launch new_name_module update:
    ./odoo-bin -c etc/odoo14.cfg -d testdb -u new_name_module --stop-after-init
    
    
    Do you know a way to trigger the migration script without using odoo shell?
    
    Thanks in advance.
    S.
    
    
    (*) https://github.com/OCA/l10n-italy/blob/0d65b1f7fa23facd9ef52749571a4a18a58f4045/l10n_it_vat_payability/migrations/14.0.1.0.0/pre-migrate.py
    

    by Sergio Zanchetta - 10:14 - 28 Apr 2021
  • Re: How to test v14 upgrade scripts
    > In general, is it possible to test v14 upgrade scripts before OpenUpgrade is
    
    > available for v14?
    
    yes, you don't need OpenUpgrade for that.
    
    We lack a good mechanism to test migration scripts, I'm also not sure how I 
    would implement such a thing in general. The specific script looks a bit 
    pointless to test to me, but you could mock the openupgradelib calls and call 
    the function if you're into coverage.
    
    
    -- 
    Your partner for the hard Odoo problems
    https://hunki-enterprises.com

    by Holger Brunn - 11:25 - 29 Jan 2021