Skip to content

Commit 39fbd99

Browse files
committed
IMP remove try except
1 parent 7c501b2 commit 39fbd99

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

grap_qweb_report/models/account_invoice.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ class AccountInvoice(models.Model):
2020
@api.depends("fiscal_position_id")
2121
def _compute_price_unit_include_taxes(self):
2222
# Check if fiscal_position is w ou wo taxes (just checking first line)
23-
for invoice in self:
24-
# Check if there is a fiscal_position
25-
try:
26-
tax_dest = invoice.fiscal_position_id.tax_ids[0].tax_dest_id
27-
# No fiscal position → wo taxes
28-
except IndexError:
29-
invoice.price_unit_include_taxes = False
23+
# Default : no fiscal position → no taxes
24+
self.price_unit_include_taxes = False
25+
for invoice in self.filtered(lambda x: x.fiscal_position_id.tax_ids):
26+
if invoice.fiscal_position_id.tax_ids[0].tax_dest_id.price_include:
27+
invoice.price_unit_include_taxes = True
3028
else:
31-
if tax_dest.price_include:
32-
invoice.price_unit_include_taxes = True
33-
else:
34-
invoice.price_unit_include_taxes = False
29+
invoice.price_unit_include_taxes = False

0 commit comments

Comments
 (0)