Using a `frozenset` leads to non deterministic issues. Because when nothing is set in the context key `allowed_company_ids`, `self.env.companies` will fallback on `self['res.company'].browse(user_company_ids)` Since the browsing is done on a non ordered set, the recordset doesn't follow the `_order` set on the model, by definition. This has the effect of not being deterministic when iterating on `self.env.companies`. For instance https://runbot.odoo.com/runbot/build/20539598 closes odoo/odoo#104538 X-original-commit: bfee55b14c918c44ebbb2563d5dc0e102edf396e Signed-off-by: Rémy Voet <ryv@odoo.com> Signed-off-by: William André (wan) <wan@odoo.com>