Skip to content

Commit e7fcefa

Browse files
committed
Merge PR #1944 into 17.0
Signed-off-by pedrobaeza
2 parents 62a1ea9 + 6dc4535 commit e7fcefa

18 files changed

+993
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
==================================
2+
Account Invoice Show Currency Rate
3+
==================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:5acb08a666fe3c6633d55f8c7237a01bac7edabc47ee5291534a5431378d776f
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
20+
:target: https://github.com/OCA/account-invoicing/tree/17.0/account_invoice_show_currency_rate
21+
:alt: OCA/account-invoicing
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/account-invoicing-17-0/account-invoicing-17-0-account_invoice_show_currency_rate
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module shows the currency rate applied in invoices, so you can
32+
visually verify what is going to be applied for the exchange, or which
33+
one was applied once converted to company currency.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Configuration
41+
=============
42+
43+
Enable the option for multiple currencies in your instance:
44+
45+
1. Go to Invoicing > Configuration > Settings > Currencies >
46+
Multi-Currencies
47+
2. Go to any draft invoice
48+
3. Change the invoice currency
49+
4. The proper currency rate, based on the invoice date and the selected
50+
currency, will be shown.
51+
5. Add any invoice line.
52+
6. Odoo has already generated the journal item lines with the rate
53+
applied, so the currency rate shown is get from the division between
54+
the amount in currency by the amount in company currency.
55+
56+
Some rates must be defined (and be distinct to 1.0) for currencies
57+
different from the company default.
58+
59+
1. Go to Invoicing > Configuration > Currencies and go to EUR
60+
2. Go to Rates smart-button
61+
3. Update 01/01/2010 record and change rate to 1.5
62+
63+
Usage
64+
=====
65+
66+
To use this module, you need to:
67+
68+
1. Go to Invoicing > Customer > Invoice
69+
2. Create Invoice and set Currency distinct to company currency (EUR for
70+
example)
71+
3. Rate account show according to currency defined.
72+
73+
Bug Tracker
74+
===========
75+
76+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
77+
In case of trouble, please check there if your issue has already been reported.
78+
If you spotted it first, help us to smash it by providing a detailed and welcomed
79+
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_show_currency_rate%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
80+
81+
Do not contact contributors directly about support or help with technical issues.
82+
83+
Credits
84+
=======
85+
86+
Authors
87+
-------
88+
89+
* Tecnativa
90+
91+
Contributors
92+
------------
93+
94+
- `Tecnativa <https://www.tecnativa.com>`__:
95+
96+
- Pedro M. Baeza
97+
- Víctor Martínez
98+
99+
Maintainers
100+
-----------
101+
102+
This module is maintained by the OCA.
103+
104+
.. image:: https://odoo-community.org/logo.png
105+
:alt: Odoo Community Association
106+
:target: https://odoo-community.org
107+
108+
OCA, or the Odoo Community Association, is a nonprofit organization whose
109+
mission is to support the collaborative development of Odoo features and
110+
promote its widespread use.
111+
112+
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
113+
:target: https://github.com/victoralmau
114+
:alt: victoralmau
115+
116+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
117+
118+
|maintainer-victoralmau|
119+
120+
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/17.0/account_invoice_show_currency_rate>`_ project on GitHub.
121+
122+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2021 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
{
4+
"name": "Account Invoice Show Currency Rate",
5+
"summary": "Show currency rate in invoices.",
6+
"version": "17.0.1.0.0",
7+
"category": "Accounting & Finance",
8+
"website": "https://github.com/OCA/account-invoicing",
9+
"author": "Tecnativa, Odoo Community Association (OCA)",
10+
"license": "AGPL-3",
11+
"installable": True,
12+
"depends": ["account"],
13+
"maintainers": ["victoralmau"],
14+
"data": ["views/account_move_view.xml"],
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * account_invoice_show_currency_rate
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: account_invoice_show_currency_rate
17+
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move
18+
msgid "Journal Entry"
19+
msgstr ""
20+
21+
#. module: account_invoice_show_currency_rate
22+
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move_line
23+
msgid "Journal Item"
24+
msgstr ""
25+
26+
#. module: account_invoice_show_currency_rate
27+
#: model_terms:ir.ui.view,arch_db:account_invoice_show_currency_rate.account_move_form
28+
msgid "Rate"
29+
msgstr ""
30+
31+
#. module: account_invoice_show_currency_rate
32+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__currency_rate_amount
33+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
34+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__currency_rate_amount
35+
msgid "Rate amount"
36+
msgstr ""
37+
38+
#. module: account_invoice_show_currency_rate
39+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__show_currency_rate_amount
40+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
41+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__show_currency_rate_amount
42+
msgid "Show Currency Rate Amount"
43+
msgstr ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * account_invoice_show_currency_rate
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 13.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2021-07-09 11:07+0000\n"
10+
"PO-Revision-Date: 2023-08-14 09:11+0000\n"
11+
"Last-Translator: gelo joga Rodríguez <gelo.joga@factorlibre.com>\n"
12+
"Language-Team: \n"
13+
"Language: es\n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: 8bit\n"
17+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
18+
"X-Generator: Weblate 4.17\n"
19+
20+
#. module: account_invoice_show_currency_rate
21+
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move
22+
msgid "Journal Entry"
23+
msgstr "Asiento contable"
24+
25+
#. module: account_invoice_show_currency_rate
26+
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move_line
27+
msgid "Journal Item"
28+
msgstr ""
29+
30+
#. module: account_invoice_show_currency_rate
31+
#: model_terms:ir.ui.view,arch_db:account_invoice_show_currency_rate.account_move_form
32+
msgid "Rate"
33+
msgstr ""
34+
35+
#. module: account_invoice_show_currency_rate
36+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__currency_rate_amount
37+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
38+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__currency_rate_amount
39+
msgid "Rate amount"
40+
msgstr "Valor de cambio de moneda"
41+
42+
#. module: account_invoice_show_currency_rate
43+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__show_currency_rate_amount
44+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
45+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__show_currency_rate_amount
46+
msgid "Show Currency Rate Amount"
47+
msgstr "Mostrar importe en moneda"
48+
49+
#~ msgid "Journal Entries"
50+
#~ msgstr "Asientos contables"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * account_invoice_show_currency_rate
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2025-02-03 11:06+0000\n"
10+
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
11+
"Language-Team: none\n"
12+
"Language: it\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 5.6.2\n"
18+
19+
#. module: account_invoice_show_currency_rate
20+
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move
21+
msgid "Journal Entry"
22+
msgstr "Registrazione contabile"
23+
24+
#. module: account_invoice_show_currency_rate
25+
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move_line
26+
msgid "Journal Item"
27+
msgstr "Movimento contabile"
28+
29+
#. module: account_invoice_show_currency_rate
30+
#: model_terms:ir.ui.view,arch_db:account_invoice_show_currency_rate.account_move_form
31+
msgid "Rate"
32+
msgstr "Tasso"
33+
34+
#. module: account_invoice_show_currency_rate
35+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__currency_rate_amount
36+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
37+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__currency_rate_amount
38+
msgid "Rate amount"
39+
msgstr "Valore tasso"
40+
41+
#. module: account_invoice_show_currency_rate
42+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_bank_statement_line__show_currency_rate_amount
43+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
44+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_payment__show_currency_rate_amount
45+
msgid "Show Currency Rate Amount"
46+
msgstr "Visualizza valore tasso di cambio"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import account_move
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright 2021 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class AccountMove(models.Model):
8+
_inherit = "account.move"
9+
10+
currency_rate_amount = fields.Float(
11+
string="Rate amount",
12+
compute="_compute_currency_rate_amount",
13+
digits=0,
14+
)
15+
show_currency_rate_amount = fields.Boolean(
16+
compute="_compute_show_currency_rate_amount", readonly=True
17+
)
18+
19+
@api.depends(
20+
"state",
21+
"date",
22+
"line_ids.amount_currency",
23+
"line_ids.balance",
24+
"company_id",
25+
"currency_id",
26+
"show_currency_rate_amount",
27+
)
28+
def _compute_currency_rate_amount(self):
29+
"""It's necessary to define value according to some cases:
30+
- Case A: Currency is equal to company currency (Value = 1)
31+
- Case B: Move exist previously (posted) and get real rate according to lines
32+
- Case C: Get expected rate (according to date) to show some value in creation.
33+
"""
34+
self.currency_rate_amount = 1
35+
for item in self.filtered("show_currency_rate_amount"):
36+
lines = item.line_ids.filtered(lambda x: abs(x.amount_currency) > 0)
37+
if item.state == "posted" and lines:
38+
amount_currency_positive = sum(
39+
[abs(amc) for amc in lines.mapped("amount_currency")]
40+
)
41+
total_balance_positive = sum([abs(b) for b in lines.mapped("balance")])
42+
item.currency_rate_amount = (
43+
amount_currency_positive / total_balance_positive
44+
)
45+
else:
46+
rates = item.currency_id._get_rates(item.company_id, item.date)
47+
item.currency_rate_amount = rates.get(item.currency_id.id)
48+
49+
@api.depends("currency_id", "currency_id.rate_ids", "company_id")
50+
def _compute_show_currency_rate_amount(self):
51+
for item in self:
52+
item.show_currency_rate_amount = (
53+
item.currency_id and item.currency_id != item.company_id.currency_id
54+
)
55+
56+
57+
class AccountMoveLine(models.Model):
58+
_inherit = "account.move.line"
59+
60+
@api.depends(
61+
"currency_id",
62+
"move_id.company_id",
63+
"move_id.date",
64+
"move_id.state",
65+
"amount_currency",
66+
"balance",
67+
)
68+
def _compute_currency_rate(self):
69+
# If move is posted, get rate based on line amount
70+
res = super()._compute_currency_rate()
71+
for line in self:
72+
if line.move_id.state != "posted" or not line.amount_currency:
73+
continue
74+
line.currency_rate = (
75+
abs(line.amount_currency) / abs(line.balance) if line.balance else 0
76+
)
77+
return res
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Enable the option for multiple currencies in your instance:
2+
3+
1. Go to Invoicing \> Configuration \> Settings \> Currencies \>
4+
Multi-Currencies
5+
2. Go to any draft invoice
6+
3. Change the invoice currency
7+
4. The proper currency rate, based on the invoice date and the selected
8+
currency, will be shown.
9+
5. Add any invoice line.
10+
6. Odoo has already generated the journal item lines with the rate
11+
applied, so the currency rate shown is get from the division between
12+
the amount in currency by the amount in company currency.
13+
14+
Some rates must be defined (and be distinct to 1.0) for currencies
15+
different from the company default.
16+
17+
1. Go to Invoicing \> Configuration \> Currencies and go to EUR
18+
2. Go to Rates smart-button
19+
3. Update 01/01/2010 record and change rate to 1.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [Tecnativa](https://www.tecnativa.com):
2+
- Pedro M. Baeza
3+
- Víctor Martínez
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This module shows the currency rate applied in invoices, so you can
2+
visually verify what is going to be applied for the exchange, or which
3+
one was applied once converted to company currency.

0 commit comments

Comments
 (0)