Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] send total amount as euro in invoice #94

Closed
wants to merge 5 commits into from
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion l10n_pt_account_invoicexpress/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
}.get(doctype)

def _prepare_invoicexpress_lines(self):
date_today = fields.Date.today()
# FIXME: set user lang, based on country?
lines = self.invoice_line_ids.filtered(
lambda l: l.display_type not in ("line_section", "line_note")
Expand All @@ -119,12 +120,23 @@
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 128 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#L128

Added line #L128 was not covered by tests
line.price_unit,
line.company_id.currency_id,
line.company_id,
date_today,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why today, shouldn't it be the Invoice Date?
What date is used to convert the amount used for the accounting entries?

Copy link

@cpintofonseca cpintofonseca Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dreispt invoice date seems more reasonable. I checked the way Odoo is calculating the currency rate for the invoice line and did the same, new commit is available to improve this.

)
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