diff --git a/addons/point_of_sale/models/pos_payment.py b/addons/point_of_sale/models/pos_payment.py index bd0ff002a10..08a4e7a685a 100644 --- a/addons/point_of_sale/models/pos_payment.py +++ b/addons/point_of_sale/models/pos_payment.py @@ -75,7 +75,7 @@ class PosPayment(models.Model): journal = pos_session.config_id.journal_id payment_move = self.env['account.move'].with_context(default_journal_id=journal.id).create({ 'journal_id': journal.id, - 'date': fields.Date.context_today(payment), + 'date': fields.Date.context_today(order, order.date_order), 'ref': _('Invoice payment for %s (%s) using %s', order.name, order.account_move.name, payment_method.name), 'pos_payment_ids': payment.ids, }) 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 75d72e7d45e..6759cdafcf6 100644 --- a/addons/point_of_sale/tests/test_pos_basic_config.py +++ b/addons/point_of_sale/tests/test_pos_basic_config.py @@ -934,5 +934,11 @@ class TestPoSBasicConfig(TestPoSCommon): order_to_invoice.write({'partner_id': test_customer.id}) order_to_invoice.action_pos_order_invoice() # check invoice - self.assertTrue(order_to_invoice.account_move, 'Invoice should be created.') - self.assertTrue(order_to_invoice.account_move.invoice_date != order_to_invoice.date_order.date(), 'Invoice date should not be the same as order date since the session was closed.') + invoice = order_to_invoice.account_move + self.assertTrue(invoice, 'Invoice should be created.') + self.assertNotEqual(invoice.invoice_date, order_to_invoice.date_order.date(), 'Invoice date should not be the same as order date since the session was closed.') + + # check that the payment date is set to the order date which + # is the real payment date and not to the invoice_date + payment = invoice.line_ids.full_reconcile_id.reconciled_line_ids.move_id - invoice + self.assertEqual(payment.date, order_to_invoice.date_order.date())