From bbc2128ba18dd66418b21e73d504ad4181a0bf9b Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 22 Feb 2022 15:29:02 +0000 Subject: [PATCH] [FIX] base: Blacklist invoice specific reports in generic test Some reports are specific to invoices and are raising an UserError if called without the correct business objects. Since version 13.0, invoices have been merged into `account.move`. The test is making a `search` on `account.move` to test the report generation but there is no guarantee there are invoices. To prevent random failures in the futur, this commit allows custom domain to get the records in order to test these reports correctly. closes odoo/odoo#85150 Task: 2726507 Signed-off-by: Quentin De Paoli --- odoo/addons/base/tests/test_reports.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/odoo/addons/base/tests/test_reports.py b/odoo/addons/base/tests/test_reports.py index b783b4de671..7a550554736 100644 --- a/odoo/addons/base/tests/test_reports.py +++ b/odoo/addons/base/tests/test_reports.py @@ -12,16 +12,21 @@ _logger = logging.getLogger(__name__) @odoo.tests.tagged('post_install', '-at_install', 'post_install_l10n') class TestReports(odoo.tests.TransactionCase): def test_reports(self): - domain = [('report_type', 'like', 'qweb')] - for report in self.env['ir.actions.report'].search(domain): + invoice_domain = [('move_type', 'in', ('out_invoice', 'out_refund', 'out_receipt', 'in_invoice', 'in_refund', 'in_receipt'))] + specific_model_domains = { + 'account.report_original_vendor_bill': [('move_type', 'in', ('in_invoice', 'in_receipt'))], + 'account.report_invoice_with_payments': invoice_domain, + 'account.report_invoice': invoice_domain, + } + for report in self.env['ir.actions.report'].search([('report_type', 'like', 'qweb')]): report_model = 'report.%s' % report.report_name try: self.env[report_model] except KeyError: # Only test the generic reports here _logger.info("testing report %s", report.report_name) - report_model = self.env[report.model] - report_records = report_model.search([], limit=10) + report_model_domain = specific_model_domains.get(report.report_name, []) + report_records = self.env[report.model].search(report_model_domain, limit=10) if not report_records: _logger.info("no record found skipping report %s", report.report_name)