From 86a2819697d5d9d1c32ba902d8a1089acf6110f2 Mon Sep 17 00:00:00 2001
From: "Andrea Grazioso (agr-odoo)" <agr@odoo.com>
Date: Fri, 7 May 2021 12:24:15 +0000
Subject: [PATCH] [FIX] account: avoid change of payment type on 0 amount

Create a draft payment with payment type and 0 amount.
Save.

The payment type will be overwritten

opw-2495461

closes odoo/odoo#70603

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
---
 addons/account/models/account_payment.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index 4d9988cf2036..46f04073bcd4 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -680,12 +680,15 @@ class AccountPayment(models.Model):
                 })
                 payment_vals_to_write.update({
                     'amount': abs(liquidity_amount),
-                    'payment_type': 'inbound' if liquidity_amount > 0.0 else 'outbound',
                     'partner_type': partner_type,
                     'currency_id': liquidity_lines.currency_id.id,
                     'destination_account_id': counterpart_lines.account_id.id,
                     'partner_id': liquidity_lines.partner_id.id,
                 })
+                if liquidity_amount > 0.0:
+                    payment_vals_to_write.update({'payment_type': 'inbound'})
+                elif liquidity_amount < 0.0:
+                    payment_vals_to_write.update({'payment_type': 'outbound'})
 
             move.write(move._cleanup_write_orm_values(move, move_vals_to_write))
             pay.write(move._cleanup_write_orm_values(pay, payment_vals_to_write))
-- 
GitLab