diff options
| author | Nicolas (vin) <vin@odoo.com> | 2020-09-16 13:43:51 +0000 |
|---|---|---|
| committer | Nicolas (vin) <vin@odoo.com> | 2020-09-29 05:20:50 +0000 |
| commit | d3116ba7266270cb5ef8e018f65131003d0331ed (patch) | |
| tree | 63f6055f4a39febb207818a08c96188cbd15e6a2 | |
| parent | d4b2faae71ea81f18a3890be5f680ab149271ccf (diff) | |
[FIX] account_facturx: fix upload of pdf using facturx
There seems to be an issue with the import of factur-x pdf.
The unit price is being divided by the quantity resulting in wrong
values.
This commit will correct that by dividing the unit price by
the amount of products in one unit, instead of the amount of unit.
Task id #2341111
X-original-commit: bfaaf91628d8a4c268745e86d1c2b8f15fab2a54
| -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: |
