Skip to content

Commit

Permalink
[FIX] l10n_pt_account_invoicexpress: send total amount as euro in inv…
Browse files Browse the repository at this point in the history
…oice

[FIX] convert unit price in invoice lines to company currency.

[REF] convert currency to follow PEP8 guidelines when using multiple lines

Update l10n_pt_account_invoicexpress/models/account_move.py

Co-authored-by: Daniel Reis <dreis@opensourceintegrators.com>

[IMP] currency conversion date when converting other currencies to company currency
  • Loading branch information
fmartins-odoogap authored and dreispt committed Jan 27, 2024
1 parent 2b56e6e commit c711775
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion l10n_pt_account_invoicexpress/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,25 @@ def _prepare_invoicexpress_lines(self):
tax = line.tax_ids[:1]
# If not tax set, force zero VAT
tax_detail = {"name": tax.name or "IVA0", "value": tax.amount or 0.0}
# Because InvoiceXpress expects unit_price in EUR, check if we need to convert
# line currency to company currency (company should use EUR as default currency)
if line.currency_id == line.company_id.currency_id:
price_unit = line.price_unit
else:
price_unit = line.currency_id._convert(

Check warning on line 127 in l10n_pt_account_invoicexpress/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_pt_account_invoicexpress/models/account_move.py#L127

Added line #L127 was not covered by tests
line.price_unit,
line.company_id.currency_id,
line.company_id,
line.move_id.invoice_date
or line.move_id.date
or fields.Date.context_today(line),
)
items.append(
{
"name": line.product_id.default_code
or line.product_id.display_name,
"description": line._get_invoicexpress_descr(),
"unit_price": line.price_unit,
"unit_price": price_unit,
"quantity": line.quantity,
"discount": line.discount,
"tax": tax_detail,
Expand Down

0 comments on commit c711775

Please sign in to comment.