From d2dbc4faaad0988d71f591be7f50c94d455541b0 Mon Sep 17 00:00:00 2001
From: Jason Van Malder <jvm@odoo.com>
Date: Wed, 4 Dec 2019 12:04:51 +0000
Subject: [PATCH] [FIX] web: fix studio child view datapoint content

Issue

    - Install Employees & Studio
    - Configuration > Check Skills Management
    - Go on an employee form
    - Remove all data in Experience, Education & Skills
    - Open Studio
    - Click in the blank space before Skills
    - Edit Form View

    Traceback

Cause

    The ORM tries to get the parent fields because the generated
    datapoint includes them. (45bc7c9)

    Normally the parent model is the same than the child model
    but not in studio.

Solution

    Merging the fields in the datapoint only if the models are the same.

OPW-2125214

closes odoo/odoo#41317

Related: odoo/enterprise#7179
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
---
 addons/web/static/src/js/views/basic/basic_model.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 bf9048561a44..232582bc638e 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -3921,7 +3921,8 @@ var BasicModel = AbstractModel.extend({
 
         // Fields that are present in the originating view, that need to be initialized
         // Hence preventing their value to crash when getting back to the originating view
-        var parentRecord = self.localData[params.parentID];
+        var parentRecord = params.parentID && this.localData[params.parentID].type === 'list' ? this.localData[params.parentID] : null;
+
         if (parentRecord) {
             var originView = parentRecord.viewType;
             fieldNames = _.union(fieldNames, Object.keys(parentRecord.fieldsInfo[originView]));
-- 
GitLab