- Mailing Lists
- Contributors
- Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13
Archives
- By thread 1419
-
By date
- August 2019 59
- September 2019 118
- October 2019 165
- November 2019 97
- December 2019 35
- January 2020 58
- February 2020 204
- March 2020 121
- April 2020 172
- May 2020 50
- June 2020 158
- July 2020 85
- August 2020 94
- September 2020 193
- October 2020 277
- November 2020 100
- December 2020 159
- January 2021 38
- February 2021 87
- March 2021 146
- April 2021 73
- May 2021 90
- June 2021 86
- July 2021 123
- August 2021 50
- September 2021 68
- October 2021 66
- November 2021 74
- December 2021 75
- January 2022 98
- February 2022 77
- March 2022 68
- April 2022 31
- May 2022 59
- June 2022 87
- July 2022 141
- August 2022 38
- September 2022 73
- October 2022 152
- November 2022 39
- December 2022 50
- January 2023 93
- February 2023 49
- March 2023 106
- April 2023 47
- May 2023 69
- June 2023 92
- July 2023 64
- August 2023 103
- September 2023 91
- October 2023 101
- November 2023 94
- December 2023 46
- January 2024 75
- February 2024 79
- March 2024 104
- April 2024 63
- May 2024 40
- June 2024 160
- July 2024 80
- August 2024 70
- September 2024 62
- October 2024 121
- November 2024 117
- December 2024 89
- January 2025 59
- February 2025 104
- March 2025 96
- April 2025 107
- May 2025 52
- June 2025 72
- July 2025 60
- August 2025 81
- September 2025 124
- October 2025 63
- November 2025 22
Contributors
Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13
On Wed, Feb 9, 2022 at 2:41 PM Holger Brunn <mail@hunki-enterprises.nl> wrote:could we write the AST version of grep -RE 'user(_id|).company_id[^s]' --include=*.py ?I recently came across https://semgrep.dev/ which might be handy in such situations.-sbi_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
by Simone Rubino - 02:50 - 18 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-
Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13
Worth mentioning: the fine tool for module migrations https://github.com/OCA/odoo-module-migrator warns the developer about this thanks to https://github.com/OCA/odoo-module-migrator/pull/53.On Wed, 9 Feb 2022 at 14:51, Stéphane Bidoul <stephane.bidoul@acsone.eu> wrote:On Wed, Feb 9, 2022 at 2:41 PM Holger Brunn <mail@hunki-enterprises.nl> wrote:could we write the AST version of grep -RE 'user(_id|).company_id[^s]' --include=*.py ?
I recently came across https://semgrep.dev/ which might be handy in such situations.-sbi_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
by Simone Rubino - 02:50 - 18 Feb 2022 -
Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13
On Wed, Feb 9, 2022 at 2:41 PM Holger Brunn <mail@hunki-enterprises.nl> wrote:could we write the AST version of grep -RE 'user(_id|).company_id[^s]' --include=*.py ?
I recently came across https://semgrep.dev/ which might be handy in such situations.-sbi
by Stéphane Bidoul - 02:51 - 9 Feb 2022 -
Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13
On 09/02/2022 14:37, Holger Brunn wrote: > 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. > I don't think we want to exclude default lambdas. In my opinion we want env.company_id in these (and this is what Odoo is using). Tests are a bit more of an issue. We should have a pylint check for this, I think, which would require an explicit deactivation to be able to use user.company_id anywhere. -- 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 - 02:51 - 9 Feb 2022 -
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 -
Re: Lots of our modules do not handle multi-company correctly with Odoo >= 13
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
by Denis Roussel - 02:25 - 9 Feb 2022
-