[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 <qdp@odoo.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user