diff options
| author | Yannick Tivisse <yti@odoo.com> | 2016-11-08 17:08:01 +0100 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-11-09 15:35:21 +0100 |
| commit | df69b5bb846fda29a397bb43f74f73f795b28eea (patch) | |
| tree | 02aed637854226130ca5ef279a439bb08d64fbb7 /addons | |
| parent | 9e26d875db668ced71122eba41c7e98dd26b4d93 (diff) | |
[IMP] web: Don't display aggregates in list views for columns with multi-currency records
Purpose:
On a list view (Ex: the invoices list view), if a column is a currency column (Ex: total amount), it makes no sense to display the aggregate (Ex: sum) if the records contains several currencies.
Spec:
Don't display the aggregate of a column if a least two records are in different currencies.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/static/src/js/views/list_view.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index db50fbb6208..bf4a48a5917 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -759,7 +759,16 @@ var ListView = View.extend({ }); var aggregates = {}; - _(columns).each(function (column) { + _.each(_.filter(columns, function (column) { + if (column.currency_field === 'currency_id' && records && records[0].values['currency_id']) { + var currency_ids = _.map(records, function(record) {return record.values['currency_id'][0]}); + if (_.every(currency_ids, function (currency_id){return currency_id === currency_ids[0]})) { + return column; + } + } else { + return column; + } + }), function (column) { var field = column.id; switch (column['function']) { case 'avg': |
