diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-18 18:59:06 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-18 18:59:06 +0200 |
| commit | 8383181b8f74c87c43bc6b8c97d84e550d5d89c4 (patch) | |
| tree | 9184a391e492bebf64cc0d1dbe5ffcaa7d7b0fbd /addons | |
| parent | 8ac98fc78a3794e06481b02a431bcdc386a5a6ee (diff) | |
| parent | 021d0e6a98bb9baa0d554d4e8b5717c7893a7641 (diff) | |
[MERGE] forward port branch saas-15 up to 021d0e6a98b
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/analytic/models/analytic_account.py | 23 | ||||
| -rw-r--r-- | addons/mrp/i18n/mrp.pot | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/core/ajax.js | 20 |
3 files changed, 32 insertions, 16 deletions
diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py index a87a948e1fa..f820f847398 100644 --- a/addons/analytic/models/analytic_account.py +++ b/addons/analytic/models/analytic_account.py @@ -21,21 +21,24 @@ class AccountAnalyticAccount(models.Model): @api.multi def _compute_debit_credit_balance(self): analytic_line_obj = self.env['account.analytic.line'] - domain = [('account_id', 'in', self.mapped('id'))] + domain = [('account_id', 'in', self.ids)] if self._context.get('from_date', False): domain.append(('date', '>=', self._context['from_date'])) if self._context.get('to_date', False): domain.append(('date', '<=', self._context['to_date'])) - account_amounts = analytic_line_obj.search_read(domain, ['account_id', 'amount']) - account_ids = set([line['account_id'][0] for line in account_amounts]) - data_debit = {account_id: 0.0 for account_id in account_ids} - data_credit = {account_id: 0.0 for account_id in account_ids} - for account_amount in account_amounts: - if account_amount['amount'] < 0.0: - data_debit[account_amount['account_id'][0]] += account_amount['amount'] - else: - data_credit[account_amount['account_id'][0]] += account_amount['amount'] + credit_groups = analytic_line_obj.read_group( + domain=domain + [('amount', '>=', 0.0)], + fields=['account_id', 'amount'], + groupby=['account_id'] + ) + data_credit = {l['account_id'][0]: l['amount'] for l in credit_groups} + debit_groups = analytic_line_obj.read_group( + domain=domain + [('amount', '<', 0.0)], + fields=['account_id', 'amount'], + groupby=['account_id'] + ) + data_debit = {l['account_id'][0]: l['amount'] for l in debit_groups} for account in self: account.debit = abs(data_debit.get(account.id, 0.0)) diff --git a/addons/mrp/i18n/mrp.pot b/addons/mrp/i18n/mrp.pot index 446acd706e5..ea1d7b28da9 100644 --- a/addons/mrp/i18n/mrp.pot +++ b/addons/mrp/i18n/mrp.pot @@ -2267,6 +2267,11 @@ msgid "Quantity To Produce" msgstr "" #. module: mrp +#: model:ir.model.fields,field_description:mrp.field_stock_move_quantity_done_store +msgid "Quantity done store" +msgstr "" + +#. module: mrp #: model:ir.model.fields,field_description:mrp.field_mrp_routing_workcenter_batch_size msgid "Quantity to Process" msgstr "" diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index 2912b319df2..d6c67eacaec 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -260,12 +260,20 @@ function get_file(options) { if (options.error) { var body = this.contentDocument.body; var nodes = body.children.length === 0 ? body.childNodes : body.children; - options.error({ - message: nodes.length > 1 ? nodes[1].textContent : '', - data: { - title: nodes.length > 0 ? nodes[0].textContent : '', - }, - }); + var errorParams = {}; + + try { // Case of a serialized Odoo Exception: It is Json Parsable + var node = nodes[1] || nodes[0]; + errorParams = JSON.parse(node.textContent); + } catch (e) { // Arbitrary uncaught python side exception + errorParams = { + message: nodes.length > 1 ? nodes[1].textContent : '', + data: { + title: nodes.length > 0 ? nodes[0].textContent : '', + } + } + } + options.error(errorParams); } } finally { complete(); |
