From 1112ca05ab81ad4a716f042ede21d957dec754a1 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 12 Jul 2019 15:14:15 +0000 Subject: [PATCH] [FIX] account: reconciliation model support tags in widget Activate analytic tags Create an reconciliation model on which you set at least one tag Create a bank statement and a line Click on reconcile (or access the reconciliation widget by another means) Quick Create a writeoff line Click on the button corresponding to the reconciliation model Before this commit: The many2many tags was buggy, there was one empty tag, corresponding to nothing clicking on the field triggered errors validating the reconciliation by clicking on reconcile triggered a server traceback in the real backend, opening the tag form view triggered an access error This was because the data were not formatted the right way to be passed to the m2m_tag_field through notifyChanges After this commit, the reconciliation model's tag renders and behaves well Validating the reconciliation works OPW 2033350 As a side note, in the future, the reconciliation widget Model should fully implement basicModel or not at all. Some of the heavy plumbing that the ReconciliationModel does (fetch records, data...) is imitating what fetchRecord does closes odoo/odoo#34838 Signed-off-by: Lucas Perais (lpe) --- .../js/reconciliation/reconciliation_model.js | 75 ++++++++++++++----- .../static/tests/reconciliation_tests.js | 65 +++++++++++++++- 2 files changed, 117 insertions(+), 23 deletions(-) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index ede81ea2043..d655d94ed01 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -384,14 +384,7 @@ var StatementModel = BasicModel.extend({ if (context && context.active_model === 'account.journal' && context.active_ids) { domainReconcile.push(['journal_id', 'in', [false].concat(context.active_ids)]); } - var def_reconcileModel = this._rpc({ - model: 'account.reconcile.model', - method: 'search_read', - domain: domainReconcile, - }) - .then(function (reconcileModels) { - self.reconcileModels = reconcileModels; - }); + var def_reconcileModel = this._loadReconciliationModel({domainReconcile: domainReconcile}); var def_account = this._rpc({ model: 'account.account', method: 'search_read', @@ -411,7 +404,59 @@ var StatementModel = BasicModel.extend({ return self._formatLine(self.statement.lines); }); }, - + _readAnalyticTags: function (params) { + var self = this; + this.analyticTags = {}; + if (!params || !params.res_ids || !params.res_ids.length) { + return $.when(); + } + var fields = (params && params.fields || []).concat(['id', 'display_name']); + return this._rpc({ + model: 'account.analytic.tag', + method: 'read', + args: [ + params.res_ids, + fields, + ], + }).then(function (tags) { + for (var i=0; i