From 234ffd8ec159d3d60f00369415e90777cbe00095 Mon Sep 17 00:00:00 2001 From: Welling Guzman Date: Sun, 18 Mar 2018 17:11:43 -0400 Subject: [PATCH] m2o typeahead: fix when related to a relational field --- app/core/interfaces/many_to_one_typeahead/interface.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/core/interfaces/many_to_one_typeahead/interface.js b/app/core/interfaces/many_to_one_typeahead/interface.js index 6520152e0bc06..d35e1a94d1169 100644 --- a/app/core/interfaces/many_to_one_typeahead/interface.js +++ b/app/core/interfaces/many_to_one_typeahead/interface.js @@ -52,8 +52,9 @@ define(['app', 'handlebars', 'core/UIView', 'utils'], function (app, Handlebars, afterRender: function () { var self = this; var url = app.API_URL + 'tables/' + this.collection.table.id + '/typeahead/'; - var model = this.model.get(this.name); var params = {}; + var tableName = this.model.structure.get(this.name).getRelatedTableName(); + var table = app.schemaManager.getTable(tableName); if (this.visibleColumn) { params.columns = this.visibleColumn; @@ -64,8 +65,8 @@ define(['app', 'handlebars', 'core/UIView', 'utils'], function (app, Handlebars, status = this.options.settings.get('visible_status_ids'); } - if (model.table.hasStatusColumn()) { - params[model.table.getStatusColumnName()] = status; + if (table.hasStatusColumn()) { + params[table.getStatusColumnName()] = status; } var urlParams = Utils.encodeQueryParams(params);