Skip to Content

Contributors

Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13

Thank you for raising this.


> * gather information about affected modules and versions (so that people

> can quickly check if their instances are affected by this)

could we write the AST version of
grep -RE 'user(_id|).company_id[^s]' --include=*.py
?
(which already finds a lot of problematic cases, but also a lot of false 
positives we could exclude when knowing the code, like in default lambdas)

When we have that we could even flag such lines in PRs to have reviewers/
contributors pay extra attention.


-- 
Your partner for the hard Odoo problems
https://hunki-enterprises.com

by "Holger Brunn" <mail@hunki-enterprises.nl> - 02:40 - 9 Feb 2022

Reference

  • Lots of our modules do not handle multi-company correctly with Odoo >= 13
    Dear colleagues,
    
    It seems we have a widely spread bug on our code base, related to Odoo 
     >= 13.0 and multi-company.
    
    Starting on Odoo 13.0 the company switch widget in the UI no longer 
    changes the user's company_id field. It changes the company via the 
    force_company context key, and you get the value of the current company 
    by checking `self.env.company`, and not any longer through 
    `self.env.user.company_id`
    
    This is documented in 
    https://www.odoo.com/documentation/13.0/developer/howtos/company.html
    
    However, in many places in our code base, I see things such as
    
    https://github.com/OCA/account-invoicing/blob/13.0/stock_picking_invoicing/wizards/stock_invoice_onshipping.py#L209 
    
    
    This calls for a massive bug fix campaign (and probably for an official 
    statement from the community to ask customers to upgrade their modules 
    if they are in multi-company).
    
    I am not sure what the best course of action is.
    
    Things I think we should do:
    
    * gather information about affected modules and versions (so that people 
    can quickly check if their instances are affected by this)
    * prepare fixes and get them applied
    * publish the fix versions
    * be super careful about this in the reviews of module migration pull 
    requests (I admit I have been careless on this, and I really feel bad 
    about it)
    
    Feedback welcome,
    
    
    -- 
    Alexandre Fayolle
    Senior Software Engineer
    Tel : +33 4 58 48 20 30
    
    Camptocamp France SAS
    18 rue du Lac Saint André
    73 370 Le Bourget-du-Lac
    France
    
    http://www.camptocamp.com
    

    by Alexandre Fayolle - 01:46 - 9 Feb 2022