From df1e3443919209c95face6682e19febf30fad6af Mon Sep 17 00:00:00 2001 From: william-andre Date: Wed, 24 Aug 2022 11:27:58 +0000 Subject: [PATCH] [FIX] account: switch to refund an invoice with downpayment If you create a Downpayment invoice from a Sale Order with a fixed amount bigger than the amount of the SO, when you create the regular invoice it creates a credit note but all lines are "positive" when only the downpayment line should be. Based the implementation existing before d8d47f9ff8554f4b39487fd2f13c153c7d6f958d https://github.com/odoo/odoo/blob/3363e55cac2a121c29842a0b2463f940bdd866a4/addons/account/models/account_move.py#L3339 X-original-commit: 5432809bbb80c539ba11fb9aa6973669c30f5827 Part-of: odoo/odoo#101994 --- addons/account/models/account_move.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 1e66826f0c7..3551587776e 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3378,15 +3378,14 @@ class AccountMove(models.Model): 'partner_bank_id': False, 'currency_id': move.currency_id.id, }) - move.write({ - 'line_ids': [ - Command.update(line.id, { - 'quantity': -line.quantity, - }) - for line in move.line_ids - if line.display_type == 'product' and line.quantity < 0 - ] - }) + if move.amount_total < 0: + move.write({ + 'line_ids': [ + Command.update(line.id, {'quantity': -line.quantity}) + for line in move.line_ids + if line.display_type == 'product' + ] + }) def action_register_payment(self): ''' Open the account.payment.register wizard to pay the selected journal entries.