Skip to content

Commit 41b28f2

Browse files
committed
IMP remove try except
1 parent ce6d2db commit 41b28f2

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
@@ -17,15 +17,10 @@ class AccountInvoice(models.Model):
1717
@api.depends("fiscal_position_id")
1818
def _compute_price_unit_include_taxes(self):
1919
# Check if fiscal_position is w ou wo taxes (just checking first line)
20-
for invoice in self:
21-
# Check if there is a fiscal_position
22-
try:
23-
tax_dest = invoice.fiscal_position_id.tax_ids[0].tax_dest_id
24-
# No fiscal position → wo taxes
25-
except IndexError:
26-
invoice.price_unit_include_taxes = False
20+
# Default : no fiscal position → no taxes
21+
self.price_unit_include_taxes = False
22+
for invoice in self.filtered(lambda x: x.fiscal_position_id.tax_ids):
23+
if invoice.fiscal_position_id.tax_ids[0].tax_dest_id.price_include:
24+
invoice.price_unit_include_taxes = True
2725
else:
28-
if tax_dest.price_include:
29-
invoice.price_unit_include_taxes = True
30-
else:
31-
invoice.price_unit_include_taxes = False
26+
invoice.price_unit_include_taxes = False

0 commit comments

Comments
 (0)