web_tree_many2one_clickable: Check if the node is a field

If a list contains a node which is not a field (e.g. a button), it will
not be found in the fields so we'll have an error trying to get 'type'
from undefined.
pull/3035/head
Guewen Baconnier 2018-03-06 21:33:16 +01:00 committed by Carlos Roca
parent c5d4f53afe
commit 520154fac2
3 changed files with 18 additions and 2 deletions

View File

@ -7,7 +7,7 @@
{ {
"name": "Clickable many2one fields for tree views", "name": "Clickable many2one fields for tree views",
"summary": "Open the linked resource when clicking on their name", "summary": "Open the linked resource when clicking on their name",
"version": "11.0.1.0.0", "version": "11.0.1.0.1",
"category": "Hidden", "category": "Hidden",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
"author": "Therp BV, " "author": "Therp BV, "

View File

@ -0,0 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View File

@ -10,7 +10,9 @@ odoo.define('web_tree_many2one_clickable.many2one_clickable', function (require)
ListRenderer.include({ ListRenderer.include({
_renderBodyCell: function (record, node, colIndex, options) { _renderBodyCell: function (record, node, colIndex, options) {
if (!node.attrs.widget && this.state.fields[node.attrs.name].type === 'many2one') { if (!node.attrs.widget && node.attrs.name &&
this.state.fields[node.attrs.name] &&
this.state.fields[node.attrs.name].type === 'many2one') {
// no explicit widget provided on a many2one field, // no explicit widget provided on a many2one field,
// force `many2one` widget // force `many2one` widget
node.attrs.widget = 'many2one'; node.attrs.widget = 'many2one';