[FIX] point_of_sale: reconcile cash returns rather than freight returns

Revert commit 296c5a2106
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
This commit is contained in:
Lucas Perais (lpe)
2019-02-12 16:27:51 +00:00
parent 7dea5c418b
commit 5b37c40cac
+4 -6
View File
@@ -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