From 010ae983ea0b42e44c008aa13baa7a3632a7ae7e Mon Sep 17 00:00:00 2001 From: D J Date: Wed, 13 Apr 2022 10:45:49 +0000 Subject: [PATCH] [IMP] base: allow company selection while creating a user Currently, when creating a new user, even if there are multiple companies to select from, the "Multi Companies" related fields are not visible in the form view. However once the record is saved, they simply appear. This happens because the `companies_count` field based on which the visibility changes, is a computed one but is not dependent on any other field, and so while creating a new record, the value is always zero for our compute field. This commit improves the behavior by making the compute method dependent on `company_id` field so that it can be triggered while creating the record (thanks to default value being set for this field), and thus shows / hides the company related fields properly. taskID-2819559 Part-of: odoo/odoo#88738 --- odoo/addons/base/models/res_users.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index d6e9cb406ff..f9a5b0d2588 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -415,6 +415,7 @@ class Users(models.Model): internal_users.share = False (self - internal_users).share = True + @api.depends('company_id') def _compute_companies_count(self): self.companies_count = self.env['res.company'].sudo().search_count([])