diff options
| author | Mathieu Duckerts-Antoine <dam@odoo.com> | 2020-04-21 18:18:57 +0000 |
|---|---|---|
| committer | Mathieu Duckerts-Antoine <dam@odoo.com> | 2020-04-28 14:57:58 +0000 |
| commit | 7b402c5e59282eb9100adede97e730cdc73da690 (patch) | |
| tree | c1bcdc9a90a25689f9dee5aa3f4ce840a4e98e5c /addons/web/models | |
| parent | 64ae832a8ae04ad86b7707e507b71ab612bce87e (diff) | |
[FIX] web: limit on search panel values
Before this commit, if a many2X field with a big comodel was added
in a search panel, the view using it would crash. For instance that
problem occured in the kanban view for hr.job, where res.users
appears as the comodel for the field user_id.
Now, we fix an arbitrary limit of 200 to the numbers of values to fetch
for each many2X fields in the search panel. This avoid the problem
mentionned above.
Furthermore, in case the limit is attained for a field used
as select="one", the values are displayed without being hierarchized.
Indeed the limit can leads to gaps in the knowledge of the hierarchy
and consequently to a bad representation of it.
Task ID: 2154668
closes odoo/odoo#50334
X-original-commit: 8d57153b34c04952a85f6642951cb2697016da84
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/models')
| -rw-r--r-- | addons/web/models/models.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/web/models/models.py b/addons/web/models/models.py index 7a55026eb05..702f8824895 100644 --- a/addons/web/models/models.py +++ b/addons/web/models/models.py @@ -10,6 +10,8 @@ from odoo.tools import lazy from odoo.tools.misc import get_lang from odoo.exceptions import UserError +SEARCH_PANEL_LIMIT = 200 + class IrActionsActWindowView(models.Model): _inherit = 'ir.actions.act_window.view' @@ -240,7 +242,7 @@ class Base(models.AbstractModel): fields.append(parent_name) return { 'parent_field': parent_name, - 'values': Comodel.with_context(hierarchical_naming=False).search_read([], fields), + 'values': Comodel.with_context(hierarchical_naming=False).search_read([], fields, limit=SEARCH_PANEL_LIMIT), } @api.model @@ -315,7 +317,7 @@ class Base(models.AbstractModel): } # retrieve all possible values, and return them with their label and counter field_names = ['display_name', group_by] if group_by else ['display_name'] - records = Comodel.search_read(comodel_domain, field_names) + records = Comodel.search_read(comodel_domain, field_names, limit=SEARCH_PANEL_LIMIT) for record in records: record_id = record['id'] values = { @@ -330,7 +332,7 @@ class Base(models.AbstractModel): elif field.type == 'many2many': # retrieve all possible values, and return them with their label and counter field_names = ['display_name', group_by] if group_by else ['display_name'] - records = Comodel.search_read(comodel_domain, field_names) + records = Comodel.search_read(comodel_domain, field_names, limit=SEARCH_PANEL_LIMIT) for record in records: record_id = record['id'] values = { |
