Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

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

by
Camptocamp France SAS, Alexandre Fayolle
- 09/02/2022 13:41:43
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

Follow-Ups