From 5b37c40cacfe5254325d85fbdd3ffbc6b966c085 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 12 Feb 2019 16:27:51 +0000 Subject: [PATCH] [FIX] point_of_sale: reconcile cash returns rather than freight returns Revert commit 296c5a2106950b57445c4fd1cb6cac4cd4be15af which was half-right: the accounting logic is correct but it overlooked that it broke the reconciliation of cash returns i.e. the client gives more money, and you return the change Given that this latter use case may occur more frequently we focus on that while we break freight returns i.e. the client returns a product, and you give the money back It is not possible to support both use cases because ultimately we don't know from which order an account.move.line comes the related PR #23356 should support both use cases but adds a field on account.move.line OPW 1925607 closes odoo/odoo#31037 --- addons/point_of_sale/models/pos_order.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 4b405d3650a..21746b083ae 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -391,13 +391,11 @@ class PosOrder(models.Model): aml = order.statement_ids.mapped('journal_entry_ids').mapped('line_ids') | order.account_move.line_ids | order.invoice_id.move_id.line_ids aml = aml.filtered(lambda r: not r.reconciled and r.account_id.internal_type == 'receivable' and r.partner_id == order.partner_id.commercial_partner_id) - # Reconcile returns first - # to avoid mixing up the credit of a payment and the credit of a return - # in the receivable account - aml_returns = aml.filtered(lambda l: (l.journal_id.type == 'sale' and l.credit) or (l.journal_id.type != 'sale' and l.debit)) try: - aml_returns.reconcile() - (aml - aml_returns).reconcile() + # Cash returns will be well reconciled + # Whereas freight returns won't be + # "c'est la vie..." + aml.reconcile() except: # There might be unexpected situations where the automatic reconciliation won't # work. We don't want the user to be blocked because of this, since the automatic