From b6e5c0e49bad42e49d8bbc8ef59fd45b1f84c025 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 9 Aug 2021 12:53:54 +0200 Subject: [PATCH] Use zero as VAT Book taxes amount when empty issue10617 review373141002 --- reporting_tax.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/reporting_tax.py b/reporting_tax.py index c19b9712aa..82596befd0 100644 --- a/reporting_tax.py +++ b/reporting_tax.py @@ -780,7 +780,10 @@ class ESVATBook(ModelSQL, ModelView): surcharge_tax = fields.Many2One('account.tax', "Surcharge Tax") surcharge_tax_amount = fields.Numeric("Surcharge Tax Amount", digits=(16, Eval('currency_digits', 2)), - depends=['currency_digits']) + states={ + 'invisible': ~(Eval('surcharge_tax', None)), + }, + depends=['currency_digits', 'surcharge_tax']) currency_digits = fields.Function(fields.Integer("Currency Digits"), 'get_currency_digits') @@ -874,9 +877,9 @@ class ESVATBook(ModelSQL, ModelView): Min(tax.id, filter_=(tax.es_reported_with != Null)).as_( 'surcharge_tax'), - Sum(tax_line.amount, - filter_=((tax_line.type == 'tax') - & (tax.es_reported_with != Null))).as_( + Coalesce(Sum(tax_line.amount, + filter_=((tax_line.type == 'tax') + & (tax.es_reported_with != Null))), 0).as_( 'surcharge_tax_amount'), where=where, group_by=[