Browse Source

[IMP] handle readonly flag

[ADD] show grand total
[IMP] classify floats as floats
pull/96/head
Holger Brunn 10 years ago
parent
commit
59803fb145
  1. 4
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js
  2. 9
      web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml

4
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -230,6 +230,7 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
compute_totals: function() compute_totals: function()
{ {
var self = this, var self = this,
grand_total = 0,
totals_x = {}, totals_x = {},
totals_y = {}; totals_y = {};
return self.dataset.read_ids(self.dataset.ids).then(function(rows) return self.dataset.read_ids(self.dataset.ids).then(function(rows)
@ -240,6 +241,7 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
key_y = self.get_field_value(row, self.field_y_axis); key_y = self.get_field_value(row, self.field_y_axis);
totals_x[key_x] = (totals_x[key_x] || 0) + self.get_field_value(row, self.field_value); totals_x[key_x] = (totals_x[key_x] || 0) + self.get_field_value(row, self.field_value);
totals_y[key_y] = (totals_y[key_y] || 0) + self.get_field_value(row, self.field_value); totals_y[key_y] = (totals_y[key_y] || 0) + self.get_field_value(row, self.field_value);
grand_total += self.get_field_value(row, self.field_value);
}); });
}).then(function() }).then(function()
{ {
@ -255,6 +257,8 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
_.str.sprintf('td.column_total[data-x="%s"]', x)).text( _.str.sprintf('td.column_total[data-x="%s"]', x)).text(
self.format_xy_value(total)); self.format_xy_value(total));
}); });
self.$el.find('.grand_total').text(
self.format_xy_value(grand_total))
}); });
}, },

9
web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml

@ -14,19 +14,20 @@
<tbody> <tbody>
<tr t-foreach="widget.get_y_axis_values()" t-as="y" t-att-data-y="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" t-att-class="'oe_list_field_cell' + (widget.is_numeric ? ' oe_number' : '')">
<span t-att-class="widget.get_xy_value_class()"> <span t-att-class="widget.get_xy_value_class()">
<input t-att-data-x="x" t-att-data-y="y" t-att-data-id="widget.get_xy_id(x, y)" t-att-value="widget.format_xy_value(widget.get_xy_value(x, y))" />
<input t-if="!widget.get('effective_readonly')" t-att-data-x="x" t-att-data-y="y" t-att-data-id="widget.get_xy_id(x, y)" t-att-value="widget.format_xy_value(widget.get_xy_value(x, y))" />
<t t-if="widget.get('effective_readonly')" t-esc="widget.format_xy_value(widget.get_xy_value(x, y))" />
</span> </span>
</td> </td>
<td t-if="widget.show_row_totals" class="row_total" t-att-data-y="y"/>
<td t-if="widget.show_row_totals" class="row_total oe_number" t-att-data-y="y"/>
</tr> </tr>
</tbody> </tbody>
<tfoot t-if="widget.show_column_totals"> <tfoot t-if="widget.show_column_totals">
<tr> <tr>
<th>Total</th> <th>Total</th>
<td t-foreach="widget.get_x_axis_values()" t-as="x" class="oe_list_footer oe_number column_total" t-att-data-x="x" /> <td t-foreach="widget.get_x_axis_values()" t-as="x" class="oe_list_footer oe_number column_total" t-att-data-x="x" />
<td />
<td class="grand_total oe_number" />
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

Loading…
Cancel
Save