diff --git a/web_tree_many2one_clickable/README.rst b/web_tree_many2one_clickable/README.rst
index 4ce9c82a..daafb2c2 100644
--- a/web_tree_many2one_clickable/README.rst
+++ b/web_tree_many2one_clickable/README.rst
@@ -1,8 +1,8 @@
Clickable many2one fields for tree views
========================================
-This addon provides a separate widget to allow many2one fields in a tree view
-open the linked resource when clicking on their name.
+This addon provides a separate widget to allow many2one or reference fields in
+a tree view open the linked resource when clicking on their name.
You can also define a system parameter to have this behaviour for all the
existing many2one fields in tree views.
@@ -15,9 +15,9 @@ Install it the regular way.
Configuration
=============
-If you want to have all many2one fields clickable by default, you have to
-define in *Configuration > Technical > Parameters > System parameters*, a new
-parameter with name `web_tree_many2one_clickable.default` and with value
+If you want to have all many2one and reference fields clickable by default, you
+have to define in *Configuration > Technical > Parameters > System parameters*,
+a new parameter with name `web_tree_many2one_clickable.default` and with value
`true`.
Usage
diff --git a/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js b/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js
index 6c8e365e..810d4de0 100644
--- a/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js
+++ b/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js
@@ -59,11 +59,22 @@ openerp.web_tree_many2one_clickable = function(instance, local)
_format: function (row_data, options)
{
- if (this.use_many2one_clickable) {
- return _.str.sprintf('%s',
- this.relation,
- row_data[this.id].value[0],
- _.escape(row_data[this.id].value[1] || options.value_if_empty));
+ if (this.use_many2one_clickable && !!row_data[this.id]) {
+ var values = {
+ model: this.relation,
+ id: row_data[this.id].value[0],
+ name: _.escape(row_data[this.id].value[1] || options.value_if_empty),
+ }
+ if(this.type == 'reference' && !!row_data[this.id + '__display'])
+ {
+ values.model = row_data[this.id].value.split(',', 1)[0];
+ values.id = row_data[this.id].value.split(',', 2)[1];
+ values.name = _.escape(row_data[this.id + '__display'].value || options.value_if_empty);
+ }
+ return _.str.sprintf(
+ '%(name)s',
+ values
+ );
}
else {
return this._super(row_data, options);