Replace getattr by hasattr in report

(grafted from 1a0574d67704d7acbd7c224d906a4be12aaf3423)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-06-09 13:01:23 +02:00
parent a86bc71a32
commit 35291a25e2
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -913,7 +913,7 @@
<text:p text:style-name="Table_20_Contents"><text:placeholder text:placeholder-type="text">&lt;line.description or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Lines.G6" office:value-type="string">
<text:p text:style-name="Table_20_Contents"><text:placeholder text:placeholder-type="text">&lt;getattr(line.origin, &apos;rec_name&apos;, &apos;&apos;)&gt;</text:placeholder></text:p>
<text:p text:style-name="Table_20_Contents"><text:placeholder text:placeholder-type="text">&lt;line.origin and line.origin.rec_name or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
</table:table-row>
<text:soft-page-break/>
+1 -1
View File
@@ -84,7 +84,7 @@ this repository contains the full copyright notices and license terms. -->
<py:def function="TaxCategory(tax)">
<cbc:ID py:if="tax.unece_category_code">${tax.unece_category_code}</cbc:ID>
<cbc:Percent py:if="tax.type == 'percentage'">${format((tax.rate * 100).normalize(), 'f')}</cbc:Percent>
<cbc:TaxExemptionReasonCode py:if="getattr(tax, 'vatex_code', None)">${tax.vatex_code}</cbc:TaxExemptionReasonCode>
<cbc:TaxExemptionReasonCode py:if="hasattr(tax, 'vatex_code') and tax.vatex_code">${tax.vatex_code}</cbc:TaxExemptionReasonCode>
<cbc:TaxExemptionReason py:if="tax.legal_notice">${tax.legal_notice}</cbc:TaxExemptionReason>
<cac:TaxScheme py:if="tax.unece_code">
<cbc:ID>${tax.unece_code}</cbc:ID>
@@ -45,7 +45,7 @@ this repository contains the full copyright notices and license terms. -->
<ram:ApplicableTradeTax>
<ram:CalculatedAmount py:if="amount" py:attrs="{'currencyID': this.invoice.currency.code}">${amount * this.type_sign}</ram:CalculatedAmount>
<ram:TypeCode py:if="tax.unece_code">${tax.unece_code}</ram:TypeCode>
<ram:ExemptionReasonCode py:if="getattr(tax, 'vatex_code', None)">${tax.vatex_code}</ram:ExemptionReasonCode>
<ram:ExemptionReasonCode py:if="hasattr(tax, 'vatex_code') and tax.vatex_code">${tax.vatex_code}</ram:ExemptionReasonCode>
<ram:ExemptionReason py:if="tax.legal_notice">${tax.legal_notice}</ram:ExemptionReason>
<ram:BasisAmount py:if="base">${base * this.type_sign}</ram:BasisAmount>
<ram:CategoryCode py:if="tax.unece_category_code">${tax.unece_category_code}</ram:CategoryCode>
@@ -710,7 +710,7 @@
<text:p text:style-name="Text_20_body">Date: <text:placeholder text:placeholder-type="text">&lt;format_date(shipment.effective_date or shipment.planned_date) if (shipment.effective_date or shipment.planned_date) else &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P54">Terms of Trade: <text:placeholder text:placeholder-type="text">&lt;shipment.incoterm.name if shipment.incoterm else &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P37">Reason for Export: <text:placeholder text:placeholder-type="text">&lt;get_reason(shipment)&gt;</text:placeholder></text:p>
<text:p text:style-name="P57">Carrier: <text:placeholder text:placeholder-type="text">&lt;shipment.carrier.rec_name if getattr(shipment, &apos;carrier&apos;, None) else &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P57">Carrier: <text:placeholder text:placeholder-type="text">&lt;shipment.carrier.rec_name if hasattr(shipment, &apos;carrier&apos;) and shipment.carrier else &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P57">Shipping reference: <text:placeholder text:placeholder-type="text">&lt;shipment.shipping_reference&gt;</text:placeholder></text:p>
</text:section>
<text:section text:style-name="Sect2" text:name="Section4">