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

[18.0][MIG] account_invoice_show_currency_rate #1873

Open
wants to merge 34 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5d994b9
[ADD] account_invoice_show_currency_rate: Show currency rate in invoices
victoralmau Jul 9, 2021
5dc30cd
[UPD] Update account_invoice_show_currency_rate.pot
oca-travis Aug 5, 2021
2a1b071
[UPD] README.rst
OCA-git-bot Aug 5, 2021
ade5750
[IMP] account_invoice_show_currency_rate: Make sure the currency is c…
victoralmau Sep 28, 2021
0bae061
account_invoice_show_currency_rate 13.0.1.0.1
OCA-git-bot Sep 30, 2021
dce3ca5
[FIX] account_invoice_show_currency_rate: Use assertAlmostEqual in tests
Jan 14, 2022
972671d
[FIX] account_invoice_show_currency_rate: Round currency_rate_amount …
victoralmau Jan 18, 2022
a549518
account_invoice_show_currency_rate 13.0.1.0.2
OCA-git-bot Jan 18, 2022
d2d5bef
[IMP] account_invoice_show_currency_rate: pre-commit stuff
ACheung-FactorLibre Aug 3, 2023
f2ec94a
[MIG] account_invoice_show_currency_rate: Migration to 16.0
ACheung-FactorLibre Aug 3, 2023
5d3d2a3
[UPD] Update account_invoice_show_currency_rate.pot
Aug 13, 2023
006f726
[UPD] README.rst
OCA-git-bot Aug 13, 2023
15df77a
account_invoice_show_currency_rate 16.0.1.0.1
OCA-git-bot Aug 13, 2023
4de4dbf
Update translation files
weblate Aug 13, 2023
f02efa6
Translated using Weblate (Spanish)
Gelo-fl Aug 14, 2023
ab42b25
[UPD] README.rst
OCA-git-bot Sep 3, 2023
a724f3f
Added translation using Weblate (Italian)
mymage Feb 27, 2024
48b6e50
Translated using Weblate (Italian)
mymage Feb 27, 2024
458c275
[IMP] account_invoice_show_currency_rate: optional show journal items…
JordiMForgeFlow Jun 13, 2024
49c297e
[FIX] account_invoice_show_currency_rate: Use TransactionCase for tests
rousseldenis Jun 13, 2024
87242a7
[UPD] Update account_invoice_show_currency_rate.pot
Jun 13, 2024
0ea4325
[BOT] post-merge updates
OCA-git-bot Jun 13, 2024
c705350
Update translation files
weblate Jun 13, 2024
99e5b12
Translated using Weblate (Italian)
mymage Jun 15, 2024
3d1dd21
[BOT] post-merge updates
OCA-git-bot Jun 18, 2024
5ae6c58
[FIX] account_invoice_show_currency_rate: use only debit from currenc…
JordiMForgeFlow Nov 8, 2024
b8a23f4
[BOT] post-merge updates
OCA-git-bot Nov 8, 2024
59a287c
[IMP] : pre-commit auto fixes
jeer2234 Sep 1, 2024
1aaa5c6
[MIG] account_invoice_show_currency_rate: Migration to 17.0
jeer2234 Sep 4, 2024
9a86582
[IMP] account_invoice_show_currency_rate: add currency rate in journa…
JordiMForgeFlow Nov 11, 2024
1b8a138
[IMP] account_invoice_show_currency_rate: use absolute balance to get…
JordiMForgeFlow Nov 11, 2024
1770c98
[MIG] account_invoice_show_currency_rate: Migration to V18
JordiMForgeFlow Jan 3, 2025
81d1628
[IMP] account_invoice_show_currency_rate: prevent error when balance …
JordiMForgeFlow Feb 3, 2025
8ef45a8
[FIX] account_invoice_show_currency_rate: do not round currency rate
JordiMForgeFlow Feb 4, 2025
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
132 changes: 132 additions & 0 deletions account_invoice_show_currency_rate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
==================================
Account Invoice Show Currency Rate
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9f77ee0ab5b39a670d3a6f6162c64cf595c51ae2dd2782fa01f188cd0fa97dc2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/18.0/account_invoice_show_currency_rate
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-account_invoice_show_currency_rate
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Odoo computes the currency rate applied on invoices, as well as for
journal items. However, these rates are simply computed based on the
currency rates that are configured in the system.

This module ensures that for posted entries the currency rates are
computed taking into account the actual amounts in the specific
currency. This ensures that the correct rates are displayed when an
invoice was posted with a different rate configuration, or if the user
manually changed the amount in currency.

**Table of contents**

.. contents::
:local:

Configuration
=============

Enable the option for multiple currencies in your instance:

1. Go to Invoicing > Configuration > Settings > Currencies >
Multi-Currencies
2. Go to any draft invoice
3. Change the invoice currency
4. The proper currency rate, based on the invoice date and the selected
currency, will be shown.
5. Add any invoice line.
6. Odoo has already generated the journal item lines with the rate
applied, so the currency rate shown is get from the division between
the amount in currency by the amount in company currency.

Some rates must be defined (and be distinct to 1.0) for currencies
different from the company default.

1. Go to Invoicing > Configuration > Currencies and go to EUR
2. Go to Rates smart-button
3. Update 01/01/2010 record and change rate to 1.5

Usage
=====

To use this module, you need to:

1. Go to Invoicing > Customer > Invoice
2. Create Invoice and set Currency distinct to company currency (EUR for
example)
3. Rate account show according to currency defined.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_show_currency_rate%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza
- Víctor Martínez

- `ForgeFlow <https://www.forgeflow.com>`__:

- Jordi Masvidal

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/18.0/account_invoice_show_currency_rate>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_invoice_show_currency_rate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
15 changes: 15 additions & 0 deletions account_invoice_show_currency_rate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Invoice Show Currency Rate",
"summary": "Show currency rate in invoices.",
"version": "18.0.1.0.0",
"category": "Accounting & Finance",
"website": "https://github.com/OCA/account-invoicing",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["account"],
"maintainers": ["victoralmau"],
"data": ["views/account_move_view.xml"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_show_currency_rate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_invoice_show_currency_rate
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: account_invoice_show_currency_rate
#: model_terms:ir.ui.view,arch_db:account_invoice_show_currency_rate.account_move_form
msgid "Rate"
msgstr ""

#. module: account_invoice_show_currency_rate
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__currency_rate_amount
msgid "Rate amount"
msgstr ""

#. module: account_invoice_show_currency_rate
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__show_currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__show_currency_rate_amount
msgid "Show Currency Rate Amount"
msgstr ""
45 changes: 45 additions & 0 deletions account_invoice_show_currency_rate/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_show_currency_rate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-09 11:07+0000\n"
"PO-Revision-Date: 2023-08-14 09:11+0000\n"
"Last-Translator: gelo joga Rodríguez <[email protected]>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: account_invoice_show_currency_rate
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move
msgid "Journal Entry"
msgstr "Asiento contable"

#. module: account_invoice_show_currency_rate
#: model_terms:ir.ui.view,arch_db:account_invoice_show_currency_rate.account_move_form
msgid "Rate"
msgstr ""

#. module: account_invoice_show_currency_rate
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__currency_rate_amount
msgid "Rate amount"
msgstr "Valor de cambio de moneda"

#. module: account_invoice_show_currency_rate
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__show_currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__show_currency_rate_amount
msgid "Show Currency Rate Amount"
msgstr "Mostrar importe en moneda"

#~ msgid "Journal Entries"
#~ msgstr "Asientos contables"
41 changes: 41 additions & 0 deletions account_invoice_show_currency_rate/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_show_currency_rate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-06-15 19:34+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: account_invoice_show_currency_rate
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move
msgid "Journal Entry"
msgstr "Registrazione contabile"

#. module: account_invoice_show_currency_rate
#: model_terms:ir.ui.view,arch_db:account_invoice_show_currency_rate.account_move_form
msgid "Rate"
msgstr "Tasso"

#. module: account_invoice_show_currency_rate
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__currency_rate_amount
msgid "Rate amount"
msgstr "Valore tasso"

#. module: account_invoice_show_currency_rate
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__show_currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__show_currency_rate_amount
msgid "Show Currency Rate Amount"
msgstr "Visualizza valore tasso valuta"
1 change: 1 addition & 0 deletions account_invoice_show_currency_rate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move
57 changes: 57 additions & 0 deletions account_invoice_show_currency_rate/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class AccountMove(models.Model):
_inherit = "account.move"

@api.depends(
"currency_id",
"company_currency_id",
"company_id",
"invoice_date",
"state",
"line_ids.amount_currency",
"line_ids.balance",
)
def _compute_invoice_currency_rate(self):
# If move is posted, get rate based on line amount
res = super()._compute_invoice_currency_rate()
for move in self:
lines = move.line_ids.filtered(lambda x: abs(x.amount_currency) > 0)
if move.state != "posted" or not lines or not move.currency_id:
continue
amount_currency_positive = sum(
[abs(amc) for amc in lines.mapped("amount_currency")]
)
total_balance_positive = sum([abs(b) for b in lines.mapped("balance")])
move.invoice_currency_rate = (
amount_currency_positive / total_balance_positive
)
return res


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

@api.depends(
"currency_id",
"company_id",
"move_id.invoice_currency_rate",
"move_id.date",
"move_id.state",
"amount_currency",
"balance",
)
def _compute_currency_rate(self):
# If move is posted, get rate based on line amount
res = super()._compute_currency_rate()
for line in self:
if line.move_id.state != "posted" or not line.amount_currency:
continue
line.currency_rate = (
abs(line.amount_currency) / abs(line.balance) if line.balance else 0
)
return res
3 changes: 3 additions & 0 deletions account_invoice_show_currency_rate/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
19 changes: 19 additions & 0 deletions account_invoice_show_currency_rate/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Enable the option for multiple currencies in your instance:

1. Go to Invoicing \> Configuration \> Settings \> Currencies \>
Multi-Currencies
2. Go to any draft invoice
3. Change the invoice currency
4. The proper currency rate, based on the invoice date and the selected
currency, will be shown.
5. Add any invoice line.
6. Odoo has already generated the journal item lines with the rate
applied, so the currency rate shown is get from the division between
the amount in currency by the amount in company currency.

Some rates must be defined (and be distinct to 1.0) for currencies
different from the company default.

1. Go to Invoicing \> Configuration \> Currencies and go to EUR
2. Go to Rates smart-button
3. Update 01/01/2010 record and change rate to 1.5
5 changes: 5 additions & 0 deletions account_invoice_show_currency_rate/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- Víctor Martínez
- [ForgeFlow](https://www.forgeflow.com):
- Jordi Masvidal
8 changes: 8 additions & 0 deletions account_invoice_show_currency_rate/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Odoo computes the currency rate applied on invoices, as well as for journal
items. However, these rates are simply computed based on the currency rates
that are configured in the system.

This module ensures that for posted entries the currency rates are computed
taking into account the actual amounts in the specific currency. This ensures
that the correct rates are displayed when an invoice was posted with a different
rate configuration, or if the user manually changed the amount in currency.
6 changes: 6 additions & 0 deletions account_invoice_show_currency_rate/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To use this module, you need to:

1. Go to Invoicing \> Customer \> Invoice
2. Create Invoice and set Currency distinct to company currency (EUR
for example)
3. Rate account show according to currency defined.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading