我有一个应该打印报告的方法。有两个报告使用相同的方法打印,但条件不同。我已经给了if-else条件,但是有些原因,其他部分没有被执行! 请帮助我这个问题一种方法的两个返回语句? Python
count = 80
a = 20
if a > count:
return xyz
else:
return abc
ABC和XYZ是两种不同类型的,我有报道。
编辑: 这是我的实际功能。在每一个我提取我的记录。
for inv_no in each:
if inv_no.invoice_date > '2017-06-30':
return {
'type': 'ir.actions.report.xml',
'report_name': 'gst_invoice_print',
'datas': datas,
}
else:
return {
'type': 'ir.actions.report.xml',
'report_name': 'invoice_print',
'datas': datas,
}
那么,它不会被执行,因为20不会大于80. –
@DanielRoseman,那么不应该执行else块'20> 80'为假 – corn3lius
我无法重现您的问题。 – yinnonsanders