summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJoseph Caburnay <jcb@odoo.com>2020-03-30 08:06:24 +0000
committerJoseph Caburnay <jcb@odoo.com>2020-03-30 10:03:31 +0000
commit0de552c7c50d9c6cc90e7d95724fb87aca1ce455 (patch)
tree3b03b831ffcb750fa80b925f1060b98863c2c928 /addons
parente711dc08d462fdc635b1f803b792e52c2fb9b545 (diff)
[FIX] point_of_sale: closing session with zero-valued invoice
The problem is described in https://github.com/odoo/odoo/issues/48550. This is caused by reconciled receivable line in the invoice being reconciled with another reconciled receivable line in pos_session's move_id. The lines are already reconciled because their balance is zero. So to avoid trying to reconcile those reconciled lines, we do not include them in the list of lines to be reconciled. closes odoo/odoo#48587 X-original-commit: f24677098bec9b96108a901dde08bf75dc7d4c5f Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/point_of_sale/models/pos_session.py6
-rw-r--r--addons/point_of_sale/tests/test_pos_basic_config.py16
2 files changed, 20 insertions, 2 deletions
diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py
index 5998e98910f..dabe037d01d 100644
--- a/addons/point_of_sale/models/pos_session.py
+++ b/addons/point_of_sale/models/pos_session.py
@@ -415,7 +415,7 @@ class PosSession(models.Model):
else:
invoice_receivables[key] = self._update_amounts(invoice_receivables[key], {'amount': order.amount_total}, order.date_order)
# side loop to gather receivable lines by account for reconciliation
- for move_line in order.account_move.line_ids.filtered(lambda aml: aml.account_id.internal_type == 'receivable'):
+ for move_line in order.account_move.line_ids.filtered(lambda aml: aml.account_id.internal_type == 'receivable' and not aml.reconciled):
order_account_move_receivable_lines[move_line.account_id.id] |= move_line
else:
order_taxes = defaultdict(tax_amounts)
@@ -597,7 +597,9 @@ class PosSession(models.Model):
for receivable_account_id, amounts in invoice_receivables.items():
invoice_receivable_vals[receivable_account_id].append(self._get_invoice_receivable_vals(receivable_account_id, amounts['amount'], amounts['amount_converted']))
for receivable_account_id, vals in invoice_receivable_vals.items():
- invoice_receivable_lines[receivable_account_id] = MoveLine.create(vals)
+ receivable_line = MoveLine.create(vals)
+ if (not receivable_line.reconciled):
+ invoice_receivable_lines[receivable_account_id] = receivable_line
data.update({'invoice_receivable_lines': invoice_receivable_lines})
return data
diff --git a/addons/point_of_sale/tests/test_pos_basic_config.py b/addons/point_of_sale/tests/test_pos_basic_config.py
index 77365383caf..119d4c396ba 100644
--- a/addons/point_of_sale/tests/test_pos_basic_config.py
+++ b/addons/point_of_sale/tests/test_pos_basic_config.py
@@ -18,6 +18,7 @@ class TestPoSBasicConfig(TestPoSCommon):
def setUp(self):
super(TestPoSBasicConfig, self).setUp()
self.config = self.basic_config
+ self.product0 = self.create_product('Product 0', self.categ_basic, 0.0, 0.0)
self.product1 = self.create_product('Product 1', self.categ_basic, 10.0, 5)
self.product2 = self.create_product('Product 2', self.categ_basic, 20.0, 10)
self.product3 = self.create_product('Product 3', self.categ_basic, 30.0, 15)
@@ -278,6 +279,21 @@ class TestPoSBasicConfig(TestPoSCommon):
# matching number of the receivable lines should be the same
self.assertEqual(receivable_line.full_reconcile_id, invoice_receivable_line.full_reconcile_id)
+ def test_orders_with_zero_valued_invoiced(self):
+ """One invoiced order but with zero receivable line balance."""
+
+ self.open_new_session()
+ orders = [self.create_ui_order_data([(self.product0, 1)], payments=[(self.bank_pm, 0)], customer=self.customer, is_invoiced=True)]
+ self.env['pos.order'].create_from_ui(orders)
+ self.pos_session.action_pos_session_validate()
+
+ invoice = self.pos_session.order_ids.account_move
+ invoice_receivable_line = invoice.line_ids.filtered(lambda line: line.account_id == self.receivable_account)
+ receivable_line = self.pos_session.move_id.line_ids.filtered(lambda line: line.account_id == self.receivable_account)
+
+ self.assertTrue(invoice_receivable_line.reconciled)
+ self.assertTrue(receivable_line.reconciled)
+
def test_return_order(self):
""" Test return order