mirror of https://github.com/OCA/web.git
[ADD] allow to open linked record
of one of the axes is a many2one fieldpull/1484/head
parent
fcafa6268f
commit
4a4bf0b68f
|
@ -0,0 +1,4 @@
|
||||||
|
.oe_form_field_x2many_2d_matrix th.oe_link
|
||||||
|
{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
|
@ -166,18 +166,12 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||||
return _.keys(this.by_y_axis);
|
return _.keys(this.by_y_axis);
|
||||||
},
|
},
|
||||||
|
|
||||||
// get x axis labels
|
// get the label for a value on the x axis
|
||||||
get_x_axis_labels: function()
|
get_x_axis_label: function(x)
|
||||||
{
|
{
|
||||||
var self = this;
|
return this.get_field_value(
|
||||||
return _.map(
|
_.first(_.values(this.by_x_axis[x])),
|
||||||
this.get_x_axis_values(),
|
this.field_label_x_axis, true);
|
||||||
function(val)
|
|
||||||
{
|
|
||||||
return self.get_field_value(
|
|
||||||
_.first(_.values(self.by_x_axis[val])),
|
|
||||||
self.field_label_x_axis, true);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// get the label for a value on the y axis
|
// get the label for a value on the y axis
|
||||||
|
@ -264,6 +258,36 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setup_many2one_axes: function()
|
||||||
|
{
|
||||||
|
if(this.fields[this.field_x_axis].type == 'many2one')
|
||||||
|
{
|
||||||
|
this.$el.find('th[data-x]').addClass('oe_link')
|
||||||
|
.click(_.partial(
|
||||||
|
this.proxy(this.many2one_axis_click),
|
||||||
|
this.field_x_axis, 'x'));
|
||||||
|
}
|
||||||
|
if(this.fields[this.field_y_axis].type == 'many2one')
|
||||||
|
{
|
||||||
|
this.$el.find('tr[data-y] th').addClass('oe_link')
|
||||||
|
.click(_.partial(
|
||||||
|
this.proxy(this.many2one_axis_click),
|
||||||
|
this.field_y_axis, 'y'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
many2one_axis_click: function(field, id_attribute, e)
|
||||||
|
{
|
||||||
|
this.do_action({
|
||||||
|
type: 'ir.actions.act_window',
|
||||||
|
name: this.fields[field].string,
|
||||||
|
res_model: this.fields[field].relation,
|
||||||
|
res_id: jQuery(e.currentTarget).data(id_attribute),
|
||||||
|
views: [[false, 'form']],
|
||||||
|
target: 'current',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
start: function()
|
start: function()
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -288,6 +312,7 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
|
||||||
|
|
||||||
});
|
});
|
||||||
this.compute_totals();
|
this.compute_totals();
|
||||||
|
this.setup_many2one_axes();
|
||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<templates>
|
<templates>
|
||||||
<t t-name="FieldX2Many2dMatrix">
|
<t t-name="FieldX2Many2dMatrix">
|
||||||
<div>
|
<div t-att-class="widget.widget_class">
|
||||||
<table class="oe_list_content">
|
<table class="oe_list_content">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="oe_list_header_columns">
|
<tr class="oe_list_header_columns">
|
||||||
<th />
|
<th />
|
||||||
<th t-foreach="widget.get_x_axis_labels()" t-as="label">
|
<th t-foreach="widget.get_x_axis_values()" t-as="x" t-att-data-x="x">
|
||||||
<t t-esc="label" />
|
<t t-esc="widget.get_x_axis_label(x)" />
|
||||||
</th>
|
</th>
|
||||||
<th t-if="widget.show_row_totals">Total</th>
|
<th t-if="widget.show_row_totals">Total</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr t-foreach="widget.get_y_axis_values()" t-as="y">
|
<tr t-foreach="widget.get_y_axis_values()" t-as="y" t-att-data-y="y">
|
||||||
<th><t t-esc="widget.get_y_axis_label(y)" /></th>
|
<th><t t-esc="widget.get_y_axis_label(y)" /></th>
|
||||||
<td t-foreach="widget.get_x_axis_values()" t-as="x" class="oe_list_field_cell">
|
<td t-foreach="widget.get_x_axis_values()" t-as="x" class="oe_list_field_cell">
|
||||||
<span t-att-class="widget.get_xy_value_class()">
|
<span t-att-class="widget.get_xy_value_class()">
|
||||||
|
|
Loading…
Reference in New Issue