-
-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by rafaelbn
- Loading branch information
Showing
18 changed files
with
838 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
================================== | ||
Account Invoice Show Currency Rate | ||
================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/13.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-13-0/account-invoicing-13-0-account_invoice_show_currency_rate | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/95/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
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. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
Enable the option for multiple currencies in your instance: | ||
|
||
#. Go to Invoicing > Configuration > Settings > Currencies > Multi-Currencies | ||
#. Go to any draft invoice | ||
#. Change the invoice currency | ||
#. The proper currency rate, based on the invoice date and the selected currency, will be shown. | ||
#. Add any invoice line. | ||
#. 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. | ||
|
||
#. Go to Invoicing > Configuration > Currencies and go to EUR | ||
#. Go to Rates smart-button | ||
#. Update 01/01/2010 record and change rate to 1.5 | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to Invoicing > Customer > Invoice | ||
#. Create Invoice and set Currency distinct to company currency (EUR for example) | ||
#. 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 smashing it by providing a detailed and welcomed | ||
`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**>`_. | ||
|
||
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 | ||
|
||
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/13.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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "16.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"], | ||
} |
29 changes: 29 additions & 0 deletions
29
account_invoice_show_currency_rate/i18n/account_invoice_show_currency_rate.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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" | ||
"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 Entries" | ||
msgstr "" | ||
|
||
#. module: account_invoice_show_currency_rate | ||
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__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_move__show_currency_rate_amount | ||
msgid "Show Currency Rate Amount" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 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: 2021-07-09 13:09+0200\n" | ||
"Last-Translator: \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: \n" | ||
"X-Generator: Poedit 2.3\n" | ||
|
||
#. module: account_invoice_show_currency_rate | ||
#: model:ir.model,name:account_invoice_show_currency_rate.model_account_move | ||
msgid "Journal Entries" | ||
msgstr "Asientos contables" | ||
|
||
#. module: account_invoice_show_currency_rate | ||
#: model:ir.model.fields,field_description:account_invoice_show_currency_rate.field_account_move__currency_rate_amount | ||
msgid "Rate amount" | ||
msgstr "Valor de cambio de moneda" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2021 Tecnativa - Víctor Martínez | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
currency_rate_amount = fields.Float( | ||
string="Rate amount", | ||
compute="_compute_currency_rate_amount", | ||
digits=0, | ||
) | ||
show_currency_rate_amount = fields.Boolean( | ||
compute="_compute_show_currency_rate_amount", readonly=True | ||
) | ||
|
||
@api.depends( | ||
"state", | ||
"date", | ||
"line_ids.amount_currency", | ||
"company_id", | ||
"currency_id", | ||
"show_currency_rate_amount", | ||
) | ||
def _compute_currency_rate_amount(self): | ||
"""It's necessary to define value according to some cases: | ||
- Case A: Currency is equal to company currency (Value = 1) | ||
- Case B: Move exist previously (posted) and get real rate according to lines | ||
- Case C: Get expected rate (according to date) to show some value in creation. | ||
""" | ||
self.currency_rate_amount = 1 | ||
for item in self.filtered("show_currency_rate_amount"): | ||
lines = item.line_ids.filtered(lambda x: x.amount_currency > 0) | ||
if item.state == "posted" and lines: | ||
amount_currency_positive = sum(lines.mapped("amount_currency")) | ||
total_debit = sum(item.line_ids.mapped("debit")) | ||
item.currency_rate_amount = item.currency_id.round( | ||
amount_currency_positive / total_debit | ||
) | ||
else: | ||
rates = item.currency_id._get_rates(item.company_id, item.date) | ||
item.currency_rate_amount = rates.get(item.currency_id.id) | ||
|
||
@api.depends("currency_id", "currency_id.rate_ids", "company_id") | ||
def _compute_show_currency_rate_amount(self): | ||
for item in self: | ||
item.show_currency_rate_amount = ( | ||
item.currency_id and item.currency_id != item.company_id.currency_id | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Enable the option for multiple currencies in your instance: | ||
|
||
#. Go to Invoicing > Configuration > Settings > Currencies > Multi-Currencies | ||
#. Go to any draft invoice | ||
#. Change the invoice currency | ||
#. The proper currency rate, based on the invoice date and the selected currency, will be shown. | ||
#. Add any invoice line. | ||
#. 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. | ||
|
||
#. Go to Invoicing > Configuration > Currencies and go to EUR | ||
#. Go to Rates smart-button | ||
#. Update 01/01/2010 record and change rate to 1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Pedro M. Baeza | ||
* Víctor Martínez |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
To use this module, you need to: | ||
|
||
#. Go to Invoicing > Customer > Invoice | ||
#. Create Invoice and set Currency distinct to company currency (EUR for example) | ||
#. 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.
Oops, something went wrong.