diff options
| -rw-r--r-- | addons/account_edi_facturx/models/account_edi_format.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/addons/account_edi_facturx/models/account_edi_format.py b/addons/account_edi_facturx/models/account_edi_format.py index d7a9483c2e8..a95677e9286 100644 --- a/addons/account_edi_facturx/models/account_edi_format.py +++ b/addons/account_edi_facturx/models/account_edi_format.py @@ -275,12 +275,19 @@ class AccountEdiFormat(models.Model): # Price Unit. line_elements = element.xpath('.//ram:GrossPriceProductTradePrice/ram:ChargeAmount', namespaces=tree.nsmap) if line_elements: - invoice_line_form.price_unit = float(line_elements[0].text) / invoice_line_form.quantity + quantity_elements = element.xpath('.//ram:GrossPriceProductTradePrice/ram:BasisQuantity', namespaces=tree.nsmap) + if quantity_elements: + invoice_line_form.price_unit = float(line_elements[0].text) / float(quantity_elements[0].text) + else: + invoice_line_form.price_unit = float(line_elements[0].text) else: line_elements = element.xpath('.//ram:NetPriceProductTradePrice/ram:ChargeAmount', namespaces=tree.nsmap) if line_elements: - invoice_line_form.price_unit = float(line_elements[0].text) / invoice_line_form.quantity - + quantity_elements = element.xpath('.//ram:NetPriceProductTradePrice/ram:BasisQuantity', namespaces=tree.nsmap) + if quantity_elements: + invoice_line_form.price_unit = float(line_elements[0].text) / float(quantity_elements[0].text) + else: + invoice_line_form.price_unit = float(line_elements[0].text) # Discount. line_elements = element.xpath('.//ram:AppliedTradeAllowanceCharge/ram:CalculationPercent', namespaces=tree.nsmap) if line_elements: |
