[FIX] web: Find key in stringified JSON
Steps to reproduce the bug: - In Projects, switch to the calendar view - Click a task Bug: Traceback here: https://github.com/odoo/odoo/blob/7ba47e7215df69b6556a848532e4f33ef4243e83/addons/web/static/src/js/fields/basic_fields.js#L2181 TypeError: Cannot use 'in' operator to search for 'invisible' in {} Explanation: We could change the inherited model of CalendarView from AbstractView to BasicView but it would be adding 400 lines of code to every calendar view. So, for now, and to keep it simple, we just parse the modifiers where it's needed to. opw:2352436 opw:2352890 opw:2354039 closes odoo/odoo#59876 X-original-commit: 422c52a0823b1a53eeb974e76d08a44cacf4ea0a Signed-off-by: backspac <backspac@users.noreply.github.com>
This commit is contained in:
@@ -193,6 +193,9 @@ var CalendarPopover = Widget.extend(WidgetAdapterMixin, StandaloneFieldManagerMi
|
||||
FieldClass = fieldRegistry.getAny([field.widget, field.type]);
|
||||
fieldWidget = new FieldClass(self, field.name, record, self.displayFields[field.name]);
|
||||
}
|
||||
if (fieldWidget.attrs && !_.isObject(fieldWidget.attrs.modifiers)) {
|
||||
fieldWidget.attrs.modifiers = fieldWidget.attrs.modifiers ? JSON.parse(fieldWidget.attrs.modifiers) : {};
|
||||
}
|
||||
self._registerWidget(recordID, field.name, fieldWidget);
|
||||
|
||||
var $field = $('<li>', {class: 'list-group-item flex-shrink-0 d-flex flex-wrap'});
|
||||
|
||||
@@ -915,6 +915,40 @@ QUnit.module('Views', {
|
||||
calendar.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('render popover with modifiers', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
this.data.event.fields.priority = {string: "Priority", type: "selection", selection: [['0', 'Normal'], ['1', 'Important']],};
|
||||
|
||||
var calendar = await createCalendarView({
|
||||
View: CalendarView,
|
||||
model: 'event',
|
||||
data: this.data,
|
||||
arch:
|
||||
'<calendar class="o_calendar_test" '+
|
||||
'date_start="start" '+
|
||||
'date_stop="stop" '+
|
||||
'all_day="allday" '+
|
||||
'mode="week">'+
|
||||
'<field name="priority" widget="priority" readonly="1"/>'+
|
||||
'</calendar>',
|
||||
archs: archs,
|
||||
viewOptions: {
|
||||
initialDate: initialDate,
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.dom.click($('.fc-event:contains(event 4)'));
|
||||
|
||||
assert.containsOnce(calendar, '.o_cw_popover', "should open a popover clicking on event");
|
||||
assert.containsOnce(calendar, '.o_cw_popover .o_priority span.o_priority_star', "priority field should not be editable");
|
||||
|
||||
await testUtils.dom.click($('.o_cw_popover .o_cw_popover_close'));
|
||||
assert.containsNone(calendar, '.o_cw_popover', "should close a popover");
|
||||
|
||||
calendar.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('render popover with widget which has specialData attribute', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user