From 52a3b61164252c20ac755d59a4347901821970a9 Mon Sep 17 00:00:00 2001
From: Jorge Pinna Puissant <jpp@odoo.com>
Date: Mon, 20 Jan 2020 12:30:36 +0000
Subject: [PATCH] [FIX] account: error when trying to match payments

Before this commit, when clicking into the 'Payment Matching' button
from a payment, sometimes an error is raised. This occurs because the
active_id is the one of the payment, and not the one of the journal, and
when performing the research with the id of the payment in the table of
the journals, sometimes the id is out of scope.

Now, we check before performing the research that the model of which the
id belongs is the journal.

opw-2166551

closes odoo/odoo#43563

Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
---
 .../static/src/js/reconciliation/reconciliation_action.js   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/addons/account/static/src/js/reconciliation/reconciliation_action.js b/addons/account/static/src/js/reconciliation/reconciliation_action.js
index 3c7969ed1b43..a5f58958b9c4 100644
--- a/addons/account/static/src/js/reconciliation/reconciliation_action.js
+++ b/addons/account/static/src/js/reconciliation/reconciliation_action.js
@@ -113,12 +113,14 @@ var StatementAction = AbstractAction.extend({
         var def = this.model.load(this.params.context).then(this._super.bind(this));
         return def.then(function () {
                 if (!self.model.context || !self.model.context.active_id) {
-                    self.model.context = {'active_id': self.params.context.active_id};
+                    self.model.context = {'active_id': self.params.context.active_id,
+                                          'active_model': self.params.context.active_model};
                 }
                 if (self.params.context.journal_id) {
                     self.model.context.active_id = self.params.context.journal_id;
+                    self.model.context.active_model = 'account.journal';
                 }
-                if (self.model.context.active_id) {
+                if (self.model.context.active_id && self.model.context.active_model === 'account.journal') {
                     var promise = self._rpc({
                             model: 'account.journal',
                             method: 'read',
-- 
GitLab