Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

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

by
Acsone SA/NV, Denis Roussel
- 09/02/2022 14:23:26
Hi Alex.

Indeed as `self.env.user.company_id` is used to represent the default company of the user and not the current one.

I think effort can be split through PSC's and I'll be pleased to be part of that effort.

We can at least create an issue for that in every repo (I don't know if it has been done automatically or not...)


Le mer. 9 févr. 2022 à 13:47, Alexandre Fayolle <alexandre.fayolle@camptocamp.com> a écrit :
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

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

Reference