summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorXavier ALT <xal@odoo.com>2020-06-30 11:31:15 +0000
committerXavier ALT <xal@odoo.com>2020-07-06 09:40:09 +0000
commit2479da0176280d723a5c6f5de1f3be2b77dfb51f (patch)
tree2b3096b2918c80eb0f347fb0511befe37e2b7427 /addons/web/static/src
parent37f5424593221ccc0c80e68ea4c925fbfa05d9a9 (diff)
[FIX] web: do no try to render filters referencing access restricted fields
In case a field is limited to specific groups on the model, those fields are discarded from `fields_view_get()` but can still be referenced by some filters on the search view causing a traceback (see #53797) Model: ```python class MyModel(models.Model): my_field = fields.Char(groups='base.group_system') ``` Search views: ```xml <search string="My Model"> <filter name="group_myfield" context="{'group_by': 'my_field'}"/> </search> ``` This commit ensure those filter are correctly discarded. OPW-2284621 closes odoo/odoo#54112 X-original-commit: b3452a1863c36290b13e16161e2703d9a3737f0e Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/control_panel/control_panel_model.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/addons/web/static/src/js/control_panel/control_panel_model.js b/addons/web/static/src/js/control_panel/control_panel_model.js
index d09c6eeaa58..438ff98cd3a 100644
--- a/addons/web/static/src/js/control_panel/control_panel_model.js
+++ b/addons/web/static/src/js/control_panel/control_panel_model.js
@@ -778,6 +778,22 @@ odoo.define('web.ControlPanelModel', function (require) {
// and others are passive (require input(s) to become determined)
// What is the right place to process the attrs?
};
+ if (preFilter.attrs && JSON.parse(preFilter.attrs.modifiers || '{}').invisible) {
+ filter.invisible = true;
+
+ var preFilterFieldName = null;
+ if (preFilter.tag == 'filter' && preFilter.attrs.date) {
+ preFilterFieldName = preFilter.attrs.date;
+ } else if (preFilter.tag == 'groupBy') {
+ preFilterFieldName = preFilter.attrs.fieldName;
+ }
+ if (preFilterFieldName && !this.fields[preFilterFieldName]) {
+ // In some case when a field is limited to specific groups
+ // on the model, we need to ensure to discard related filter
+ // as it may still be present in the view (in 'invisible' state)
+ return;
+ }
+ }
if (filter.type === 'filter' || filter.type === 'groupBy') {
filter.groupNumber = groupNumber;
}
@@ -908,9 +924,6 @@ odoo.define('web.ControlPanelModel', function (require) {
filter.isDefault = attrs.isDefault;
}
filter.description = attrs.string || attrs.help || attrs.name || attrs.domain || 'Ω';
- if (JSON.parse(attrs.modifiers || '{}').invisible) {
- filter.invisible = true;
- }
switch (filter.type) {
case 'filter':
if (attrs.context) {