Skip to content

Commit 6acdc22

Browse files
committed
Merge PR #1522 into 16.0
Signed-off-by rafaelbn
2 parents f33a4bd + cfa2ed4 commit 6acdc22

18 files changed

+838
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
==================================
2+
Account Invoice Show Currency Rate
3+
==================================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
17+
:target: https://github.com/OCA/account-invoicing/tree/13.0/account_invoice_show_currency_rate
18+
:alt: OCA/account-invoicing
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/account-invoicing-13-0/account-invoicing-13-0-account_invoice_show_currency_rate
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/95/13.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module shows the currency rate applied in invoices, so you can visually verify what is going to be applied for the exchange, or which one was applied once converted to company currency.
29+
30+
**Table of contents**
31+
32+
.. contents::
33+
:local:
34+
35+
Configuration
36+
=============
37+
38+
Enable the option for multiple currencies in your instance:
39+
40+
#. Go to Invoicing > Configuration > Settings > Currencies > Multi-Currencies
41+
#. Go to any draft invoice
42+
#. Change the invoice currency
43+
#. The proper currency rate, based on the invoice date and the selected currency, will be shown.
44+
#. Add any invoice line.
45+
#. 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.
46+
47+
Some rates must be defined (and be distinct to 1.0) for currencies different from the company default.
48+
49+
#. Go to Invoicing > Configuration > Currencies and go to EUR
50+
#. Go to Rates smart-button
51+
#. Update 01/01/2010 record and change rate to 1.5
52+
53+
Usage
54+
=====
55+
56+
To use this module, you need to:
57+
58+
#. Go to Invoicing > Customer > Invoice
59+
#. Create Invoice and set Currency distinct to company currency (EUR for example)
60+
#. Rate account show according to currency defined.
61+
62+
Bug Tracker
63+
===========
64+
65+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
66+
In case of trouble, please check there if your issue has already been reported.
67+
If you spotted it first, help us smashing it by providing a detailed and welcomed
68+
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_show_currency_rate%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
69+
70+
Do not contact contributors directly about support or help with technical issues.
71+
72+
Credits
73+
=======
74+
75+
Authors
76+
~~~~~~~
77+
78+
* Tecnativa
79+
80+
Contributors
81+
~~~~~~~~~~~~
82+
83+
* `Tecnativa <https://www.tecnativa.com>`_:
84+
85+
* Pedro M. Baeza
86+
* Víctor Martínez
87+
88+
Maintainers
89+
~~~~~~~~~~~
90+
91+
This module is maintained by the OCA.
92+
93+
.. image:: https://odoo-community.org/logo.png
94+
:alt: Odoo Community Association
95+
:target: https://odoo-community.org
96+
97+
OCA, or the Odoo Community Association, is a nonprofit organization whose
98+
mission is to support the collaborative development of Odoo features and
99+
promote its widespread use.
100+
101+
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
102+
:target: https://github.com/victoralmau
103+
:alt: victoralmau
104+
105+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
106+
107+
|maintainer-victoralmau|
108+
109+
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/13.0/account_invoice_show_currency_rate>`_ project on GitHub.
110+
111+
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": "16.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,29 @@
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+
"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 Entries"
19+
msgstr ""
20+
21+
#. module: account_invoice_show_currency_rate
22+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
23+
msgid "Rate amount"
24+
msgstr ""
25+
26+
#. module: account_invoice_show_currency_rate
27+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__show_currency_rate_amount
28+
msgid "Show Currency Rate Amount"
29+
msgstr ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: 2021-07-09 13:09+0200\n"
11+
"Last-Translator: \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: \n"
18+
"X-Generator: Poedit 2.3\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 Entries"
23+
msgstr "Asientos contables"
24+
25+
#. module: account_invoice_show_currency_rate
26+
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount
27+
msgid "Rate amount"
28+
msgstr "Valor de cambio de moneda"
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,51 @@
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+
"company_id",
24+
"currency_id",
25+
"show_currency_rate_amount",
26+
)
27+
def _compute_currency_rate_amount(self):
28+
"""It's necessary to define value according to some cases:
29+
- Case A: Currency is equal to company currency (Value = 1)
30+
- Case B: Move exist previously (posted) and get real rate according to lines
31+
- Case C: Get expected rate (according to date) to show some value in creation.
32+
"""
33+
self.currency_rate_amount = 1
34+
for item in self.filtered("show_currency_rate_amount"):
35+
lines = item.line_ids.filtered(lambda x: x.amount_currency > 0)
36+
if item.state == "posted" and lines:
37+
amount_currency_positive = sum(lines.mapped("amount_currency"))
38+
total_debit = sum(item.line_ids.mapped("debit"))
39+
item.currency_rate_amount = item.currency_id.round(
40+
amount_currency_positive / total_debit
41+
)
42+
else:
43+
rates = item.currency_id._get_rates(item.company_id, item.date)
44+
item.currency_rate_amount = rates.get(item.currency_id.id)
45+
46+
@api.depends("currency_id", "currency_id.rate_ids", "company_id")
47+
def _compute_show_currency_rate_amount(self):
48+
for item in self:
49+
item.show_currency_rate_amount = (
50+
item.currency_id and item.currency_id != item.company_id.currency_id
51+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Enable the option for multiple currencies in your instance:
2+
3+
#. Go to Invoicing > Configuration > Settings > Currencies > Multi-Currencies
4+
#. Go to any draft invoice
5+
#. Change the invoice currency
6+
#. The proper currency rate, based on the invoice date and the selected currency, will be shown.
7+
#. Add any invoice line.
8+
#. 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.
9+
10+
Some rates must be defined (and be distinct to 1.0) for currencies different from the company default.
11+
12+
#. Go to Invoicing > Configuration > Currencies and go to EUR
13+
#. Go to Rates smart-button
14+
#. Update 01/01/2010 record and change rate to 1.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `Tecnativa <https://www.tecnativa.com>`_:
2+
3+
* Pedro M. Baeza
4+
* Víctor Martínez
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module shows the currency rate applied in invoices, so you can visually verify what is going to be applied for the exchange, or which one was applied once converted to company currency.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To use this module, you need to:
2+
3+
#. Go to Invoicing > Customer > Invoice
4+
#. Create Invoice and set Currency distinct to company currency (EUR for example)
5+
#. Rate account show according to currency defined.
Loading

0 commit comments

Comments
 (0)