From 3f50f9ce39d8b5864364cda0d0c8e69ed283ad49 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Fri, 30 Oct 2020 15:30:27 +0000 Subject: [PATCH] [FIX] account,point_of_sale: Set invoice 'paid' directly when fully reconciled wo payments When the invoice is fully reconciled but not using payments, set the 'paid' status on invoices. closes odoo/odoo#61339 X-original-commit: 052324cca4ec8682f065a4158e86fc113b0242e0 Related: odoo/enterprise#14590 Signed-off-by: Laurent Smet --- addons/account/models/account_move.py | 3 ++- addons/point_of_sale/models/account_move.py | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 559d06e6d1d..0aacbbdc5b5 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1270,7 +1270,8 @@ class AccountMove(models.Model): if move.is_invoice(include_receipts=True) and move.state == 'posted': if currency.is_zero(move.amount_residual): - if all(payment.is_matched for payment in move._get_reconciled_payments()): + reconciled_payments = move._get_reconciled_payments() + if not reconciled_payments or all(payment.is_matched for payment in reconciled_payments): new_pmt_state = 'paid' else: new_pmt_state = move._get_invoice_in_payment_state() diff --git a/addons/point_of_sale/models/account_move.py b/addons/point_of_sale/models/account_move.py index e66bc2e188d..bda9c411782 100644 --- a/addons/point_of_sale/models/account_move.py +++ b/addons/point_of_sale/models/account_move.py @@ -17,11 +17,6 @@ class AccountMove(models.Model): stock_moves += invoice.sudo().mapped('pos_order_ids.picking_ids.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') return stock_moves - def _compute_amount(self): - super(AccountMove, self)._compute_amount() - pos_invoices = self.filtered(lambda i: i.move_type in ['out_invoice', 'out_refund'] and i.pos_order_ids) - for invoice in pos_invoices: - invoice.payment_state = 'paid' def _get_invoiced_lot_values(self): self.ensure_one()