From 0bf3459767a0dd70f48bb7e476561263f29d5f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Tarroja=20Caubet?= Date: Sat, 22 Oct 2022 01:09:53 +0200 Subject: [PATCH] Display empty values on VAT Book report for None values issue11588 review443361003 (grafted from e1d799e2f866c5e3b950dc6bdfb3a84753a1f143) --HG-- branch : 6.0 --- reporting_tax.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reporting_tax.py b/reporting_tax.py index f3a472fc5f..c54469ede3 100644 --- a/reporting_tax.py +++ b/reporting_tax.py @@ -923,6 +923,8 @@ class VATBookReport(Report): @classmethod def format_decimal(cls, n): + if n is None: + return '' if not isinstance(n, Decimal): n = Decimal(n) sign = '-' if n < 0 else '' @@ -969,14 +971,15 @@ class VATBookReport(Report): (record.party_tax_identifier.es_code() if record.party_tax_identifier else ''), country_code(record), - record.party.name[:40], + record.party.name[:40] if record.party.name else '', '', cls.format_decimal(record.invoice.total_amount), cls.format_decimal(record.base_amount), - cls.format_decimal(record.tax.rate * 100), + (cls.format_decimal(record.tax.rate * 100) + if record.tax.rate is not None else ''), cls.format_decimal(record.tax_amount), (cls.format_decimal(record.surcharge_tax.rate * 100) - if record.surcharge_tax else ''), + if record.surcharge_tax is not None else ''), (cls.format_decimal(record.surcharge_tax_amount) if record.surcharge_tax else ''), '',