From c8c5bc2c1b63dadf381f94b25b652e1057be18ec Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Sun, 15 Jul 2018 11:23:46 +0200 Subject: [PATCH] [FIX] account: test: prevent aged report to crash on july, 16th and after Before this commit, the test aged report crashed on date Year/07/16 (and probably after, too) because: - we create a partial reconcile today (create_date = Year/07/16) when making the payment to the invoice - the report date is set as Year/07/15, so, the partial reconciliation, if tested after that date, always appears in another period, which is not the use case we test, hence the crash of the test After this commit, we force the create date of the partial reconciliation to *before* the report is called, thus, no error occurs closes #25785 --- addons/account/tests/test_reconciliation.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index 5e4fa84b960..1e3602f1111 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -790,12 +790,19 @@ class TestReconciliation(AccountingTestCase): statement = self.make_payment(invoice, journal, 50) + # The report searches on the create_date to dispatch reconciled lines to report periods + # Also, in this case, there can be only 1 partial_reconcile + statement_partial_id = statement.move_line_ids.mapped(lambda l: l.matched_credit_ids + l.matched_debit_ids) + self.env.cr.execute('UPDATE account_partial_reconcile SET create_date = %(date)s WHERE id = %(partial_id)s', + {'date': report_date_to + ' 00:00:00', + 'partial_id': statement_partial_id.id}) + # Case 1: The invoice and payment are reconciled: Nothing should appear report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30) partner_lines = [line for line in report_lines if line['partner_id'] == partner.id] self.assertEqual(partner_lines, [], 'The aged receivable shouldn\'t have lines at this point') - self.assertFalse(partner.id in amls, 'The aged receivable should not have amls either') + self.assertFalse(amls.get(partner.id, False), 'The aged receivable should not have amls either') # Case 2: The invoice and payment are not reconciled: we should have one line on the report # and 2 amls