mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
support reference fields in many2one_clickable widget
This commit is contained in:
committed by
Pedro M. Baeza
parent
c6a7f600bc
commit
834b5adb54
@@ -1,8 +1,8 @@
|
|||||||
Clickable many2one fields for tree views
|
Clickable many2one fields for tree views
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
This addon provides a separate widget to allow many2one fields in a tree view
|
This addon provides a separate widget to allow many2one or reference fields in
|
||||||
open the linked resource when clicking on their name.
|
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
|
You can also define a system parameter to have this behaviour for all the
|
||||||
existing many2one fields in tree views.
|
existing many2one fields in tree views.
|
||||||
@@ -15,9 +15,9 @@ Install it the regular way.
|
|||||||
Configuration
|
Configuration
|
||||||
=============
|
=============
|
||||||
|
|
||||||
If you want to have all many2one fields clickable by default, you have to
|
If you want to have all many2one and reference fields clickable by default, you
|
||||||
define in *Configuration > Technical > Parameters > System parameters*, a new
|
have to define in *Configuration > Technical > Parameters > System parameters*,
|
||||||
parameter with name `web_tree_many2one_clickable.default` and with value
|
a new parameter with name `web_tree_many2one_clickable.default` and with value
|
||||||
`true`.
|
`true`.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
|||||||
@@ -59,11 +59,22 @@ openerp.web_tree_many2one_clickable = function(instance, local)
|
|||||||
|
|
||||||
_format: function (row_data, options)
|
_format: function (row_data, options)
|
||||||
{
|
{
|
||||||
if (this.use_many2one_clickable) {
|
if (this.use_many2one_clickable && !!row_data[this.id]) {
|
||||||
return _.str.sprintf('<a class="oe_form_uri" data-many2one-clickable-model="%s" data-many2one-clickable-id="%s">%s</a>',
|
var values = {
|
||||||
this.relation,
|
model: this.relation,
|
||||||
row_data[this.id].value[0],
|
id: row_data[this.id].value[0],
|
||||||
_.escape(row_data[this.id].value[1] || options.value_if_empty));
|
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(
|
||||||
|
'<a class="oe_form_uri" data-many2one-clickable-model="%(model)s" data-many2one-clickable-id="%(id)s">%(name)s</a>',
|
||||||
|
values
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return this._super(row_data, options);
|
return this._super(row_data, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user