From ae7f574e5446a7bc6c939fc273225b41e2296bf7 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 3 Dec 2019 12:52:07 +0000 Subject: [FIX] web: calendar: allow to use fields.Reference Before this change, fields.Reference displayed into the popover of a calendar view was always empty. This was because the popover view generated from a double click on an element in the calendar view creates its own recordModel in JS and the function to create this record did not handle the reference field case. This commit detects if a reference field is defined into the record and adds the necessary processing to process its value and creates the corresponding dataPoint. opw 2151635 Closes #41262 closes odoo/odoo#42707 Signed-off-by: Lucas Perais (lpe) Co-authored-by: Aaron Bohy --- addons/web/static/src/js/views/basic/basic_model.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 7e42ad6cfca..a4c6d0e8795 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -818,6 +818,16 @@ var BasicModel = AbstractModel.extend({ defs.push(self._fetchNameGet(dataPoint)); } } + } else if (field.type === 'reference' && field.value) { + const ref = field.value.split(','); + dataPoint = self._makeDataPoint({ + context: record.context, + data: { id: parseInt(ref[1], 10) }, + modelName: ref[0], + parentID: record.id, + }); + defs.push(self._fetchNameGet(dataPoint)); + record.data[field.name] = dataPoint.id; } else if (field.type === 'one2many' || field.type === 'many2many') { var relatedFieldsInfo = {}; relatedFieldsInfo.default = {}; -- cgit v1.2.3