Skip to Content

Contributors

XML errors when upgrading modules, because of fields in unrelated modules

Hello,

I've been finding this weird issue for a while, but decided to take some tome to write about it.

I've seen frequently the case where:

1. A custom module adds a field to a model and view. For example. to res.company.
2. Later, another (unrelated) custom module also adds a new field to that same model (model and view).

When installing or upgrading that second module, I see errors loading the XML with the form view.
The error says that the field added by module 1 is missing in the view.
But a) module 1 is installed an the field exists and b) the XML for the view in module 2 doesn't have any reference to that "missing" field!

I found this frequently in Odoo 14.
Honestly I'm not sure if it if also happens in other versions.

Has anyone else experienced this?

Thank you

--
DANIEL REIS
MANAGING DIRECTOR

M: +351 919 991 307
E: dreis@OpenSourceIntegrators.com
A: Avenida da República 3000, Estoril Office B, #34


by Daniel Reis - 02:30 - 25 Nov 2022

Follow-Ups

  • Re: XML errors when upgrading modules, because of fields in unrelated modules

    Hi Daniel,

    I encountered a similar issue lately when developing a module in OCA/sale-workflow, everything was working fine locally, but the XML error you described was raised on the CI:

    - my module was adding a field in the embedded tree view of sale order line in the SO form, which by default is in editable mode (no form)

    - another module from OCA/sale-workflow disabled this editable mode so the form view of the SO line was open, on which my field wasn't added, so during tests when opening the form, the "field not found" error was triggered. Adding the field also on the embedded SO line form view fixed the issue.

    Could it be the same kind of issue you are facing?

    Regards,

    Le 25/11/2022 à 14:31, Daniel Reis a écrit :
    Hello,

    I've been finding this weird issue for a while, but decided to take some tome to write about it.

    I've seen frequently the case where:

    1. A custom module adds a field to a model and view. For example. to res.company.
    2. Later, another (unrelated) custom module also adds a new field to that same model (model and view).

    When installing or upgrading that second module, I see errors loading the XML with the form view.
    The error says that the field added by module 1 is missing in the view.
    But a) module 1 is installed an the field exists and b) the XML for the view in module 2 doesn't have any reference to that "missing" field!

    I found this frequently in Odoo 14.
    Honestly I'm not sure if it if also happens in other versions.

    Has anyone else experienced this?

    Thank you

    --
    DANIEL REIS
    MANAGING DIRECTOR

    M: +351 919 991 307
    E: dreis@OpenSourceIntegrators.com
    A: Avenida da República 3000, Estoril Office B, #34

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Sébastien Alix
    Business Solutions Odoo Developer
    
    Camptocamp France SA
    https://www.camptocamp.com/

    by Sébastien Alix - 09:46 - 28 Nov 2022
  • Re: XML errors when upgrading modules, because of fields in unrelated modules
    Hi Daniel

    the error you describe usually comes when you remove a field from a model and view.

    If you now update both modules at the same time, it depends on how your Postgres server returns the modules.
    Because no explicit ordering is specified when loading the module.

    If the module is updated first that the field is not removed, an error occurs because the other view is still in the database and not updated.

    in this context, however, other errors can also occur.
    such as. when loading data via XML.

    I hope this helps. 

    Regards
    Michael


    Am 25.11.2022 15:42 schrieb Daniel Reis <notifications@odoo-community.org>:
    Hi Moises,

    I haven't found this to be easy reproductible.
    The particular case I encountered today went away after I ran a "-u base" (that I really din't like to do).

    On your questions:

    1) Yes, In this case both inherited from "base.view_company_form".
    2) No (see 1)
    3) No groups set on model on view
    4) Yes. View on Module 1 does not have a default priority (16 was assigned) and View in Module 2 has priority=100. This looked good to me.
    5) Yes, tons of them, between core addons and other OCA modules  :-)

    I can give it a try at stripping the modules down and reproducing.

    Thanks Moises
    /Daniel

    On 25/11/22 14:22, Moises Lopez wrote:
    Hi Daniel

    I have a few question related to reproduce the case

    1) Do The third view is inherited from original one?

    1. id=original
    2. id=inh_a inherit=original
    3. id=inh_b inherit=original

    2) Do The third view is inherited from 2nd one?

    1. id=original
    2. id=inh_a inherit=original
    3. id=inh_b inherit=inh_a

    3) Do the original field has "groups"?

    4) Do the inherited views has "priority"?

    5) Are there other views inheriting the same view?


    Could you share the both modules with minimal code and the odoo-bin command to reproduce it, please?


    --
    Moisés López Calderón
    Mobile: (+521) 477-752-22-30
    Twitter: @moylop260
    hangout: moylop260@vauxoo.com
    http://www.vauxoo.com - Odoo Gold Partner
    Twitter: @vauxoo

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    --
    DANIEL REIS
    MANAGING DIRECTOR

    M: +351 919 991 307
    E: dreis@OpenSourceIntegrators.com
    A: Avenida da República 3000, Estoril Office B, #34

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe



    by Michael Tietz - 07:20 - 25 Nov 2022
  • Re: XML errors when upgrading modules, because of fields in unrelated modules
    Hi Moises,

    I haven't found this to be easy reproductible.
    The particular case I encountered today went away after I ran a "-u base" (that I really din't like to do).

    On your questions:

    1) Yes, In this case both inherited from "base.view_company_form".
    2) No (see 1)
    3) No groups set on model on view
    4) Yes. View on Module 1 does not have a default priority (16 was assigned) and View in Module 2 has priority=100. This looked good to me.
    5) Yes, tons of them, between core addons and other OCA modules  :-)

    I can give it a try at stripping the modules down and reproducing.

    Thanks Moises
    /Daniel

    On 25/11/22 14:22, Moises Lopez wrote:
    Hi Daniel

    I have a few question related to reproduce the case

    1) Do The third view is inherited from original one?

    1. id=original
    2. id=inh_a inherit=original
    3. id=inh_b inherit=original

    2) Do The third view is inherited from 2nd one?

    1. id=original
    2. id=inh_a inherit=original
    3. id=inh_b inherit=inh_a

    3) Do the original field has "groups"?

    4) Do the inherited views has "priority"?

    5) Are there other views inheriting the same view?


    Could you share the both modules with minimal code and the odoo-bin command to reproduce it, please?


    --
    Moisés López Calderón
    Mobile: (+521) 477-752-22-30
    Twitter: @moylop260
    hangout: moylop260@vauxoo.com
    http://www.vauxoo.com - Odoo Gold Partner
    Twitter: @vauxoo

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    --
    DANIEL REIS
    MANAGING DIRECTOR

    M: +351 919 991 307
    E: dreis@OpenSourceIntegrators.com
    A: Avenida da República 3000, Estoril Office B, #34


    by Daniel Reis - 03:41 - 25 Nov 2022
  • Re: XML errors when upgrading modules, because of fields in unrelated modules
    Hi Daniel

    I have a few question related to reproduce the case

    1) Do The third view is inherited from original one?

    1. id=original
    2. id=inh_a inherit=original
    3. id=inh_b inherit=original

    2) Do The third view is inherited from 2nd one?

    1. id=original
    2. id=inh_a inherit=original
    3. id=inh_b inherit=inh_a

    3) Do the original field has "groups"?

    4) Do the inherited views has "priority"?

    5) Are there other views inheriting the same view?


    Could you share the both modules with minimal code and the odoo-bin command to reproduce it, please?


    --
    Moisés López Calderón
    Mobile: (+521) 477-752-22-30
    Twitter: @moylop260
    hangout: moylop260@vauxoo.com
    http://www.vauxoo.com - Odoo Gold Partner
    Twitter: @vauxoo

    by Moisés López Calderón - 03:20 - 25 Nov 2022