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.
This commit is contained in:
Guewen Baconnier
2018-03-06 21:33:16 +01:00
committed by Carlos Roca
parent 517d5f6698
commit abae0f428a
3 changed files with 18 additions and 2 deletions

View File

@@ -10,7 +10,9 @@ odoo.define('web_tree_many2one_clickable.many2one_clickable', function (require)
ListRenderer.include({
_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,
// force `many2one` widget
node.attrs.widget = 'many2one';