From 1e0fa7971922f9ae5de2b0d16642f80aeb8619cd Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Wed, 25 Oct 2023 14:27:48 +0200 Subject: [PATCH] [IMP] base: company branches: improve helper function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes odoo/odoo#141033 X-original-commit: 5c05d8179ba757fc0b3067c8297e8636adc882e5 Related: odoo/enterprise#50190 Signed-off-by: William André (wan) Signed-off-by: Olivier Colson (oco) --- odoo/addons/base/models/res_company.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/odoo/addons/base/models/res_company.py b/odoo/addons/base/models/res_company.py index a3f72fc9deb..9875de1d89c 100644 --- a/odoo/addons/base/models/res_company.py +++ b/odoo/addons/base/models/res_company.py @@ -396,16 +396,13 @@ class Company(models.Model): return self.browse(self.__accessible_branches()) def _all_branches_selected(self): - """Return whether or all the branches of the main company are selected. + """Return whether or all the branches of the companies in self are selected. Is ``True`` if all the branches, and only those, are selected. - Can be used when some actions only make sense for a whole company regardless of the + Can be used when some actions only make sense for whole companies regardless of the branches. """ - return ( - len(self.env.companies.root_id) == 1 - and self.env.companies == self.env['res.company'].sudo().search([('id', 'child_of', self.env.company.root_id.ids)]) - ) + return self == self.sudo().search([('id', 'child_of', self.root_id.ids)]) def action_all_company_branches(self): self.ensure_one()