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

[12.0][BACKPORT] account_invoice_show_currency_rate #1848

Open
wants to merge 15 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
114 changes: 114 additions & 0 deletions account_invoice_show_currency_rate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
==================================
Account Invoice Show Currency Rate
==================================

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

.. |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/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=13.0
:alt: Try me on Runboat

|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 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:%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.
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
18 changes: 18 additions & 0 deletions account_invoice_show_currency_rate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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": "12.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",
"views/account_invoice_view.xml",
],
}
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 ""
33 changes: 33 additions & 0 deletions account_invoice_show_currency_rate/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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"

#. 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 ""
2 changes: 2 additions & 0 deletions account_invoice_show_currency_rate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move
from . import account_invoice
53 changes: 53 additions & 0 deletions account_invoice_show_currency_rate/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2021 Tecnativa - Víctor Martínez
JoanSForgeFlow marked this conversation as resolved.
Show resolved Hide resolved
# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class AccountInvoice(models.Model):
_inherit = "account.invoice"

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",
"amount_total_company_signed",
"amount_total_signed",
"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: Invoice exist previously (confirmed) and get real rate
according to amount
- Case C: Get expected rate (according to date)
to show some value in creation.
"""
for item in self:
item.currency_rate_amount = 1
if not item.show_currency_rate_amount:
continue
if item.state == 'open':
item.currency_rate_amount = item.currency_id.round(
item.amount_total_signed / item.amount_total_company_signed
)
else:
date = item.date or fields.Date.today()
item.currency_rate_amount = item.currency_id.with_context(
date=date).rate

@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
)
45 changes: 45 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,45 @@
# 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 AccountMoveLine(models.Model):
_inherit = "account.move.line"

currency_rate_amount = fields.Float(
string="Rate amount", compute="_compute_currency_rate_amount", digits=0,
)

@api.depends(
"move_id.state",
"move_id.date",
"amount_currency",
"balance",
"move_id.company_id",
"currency_id",
)
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.
"""
for item in self:
item.currency_rate_amount = 1
if (
not item.currency_id
or item.currency_id == item.move_id.company_id.currency_id
):
continue
amount_currency = abs(item.amount_currency)
if item.move_id.state == "posted" and amount_currency > 0:
item.currency_rate_amount = item.currency_id.round(
amount_currency / abs(item.balance)
)
else:
date = item.move_id.date or fields.Date.today()
item.currency_rate_amount = item.currency_id.with_context(
date=date).rate
14 changes: 14 additions & 0 deletions account_invoice_show_currency_rate/readme/CONFIGURE.rst
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
4 changes: 4 additions & 0 deletions account_invoice_show_currency_rate/readme/CONTRIBUTORS.rst
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
1 change: 1 addition & 0 deletions account_invoice_show_currency_rate/readme/DESCRIPTION.rst
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.
5 changes: 5 additions & 0 deletions account_invoice_show_currency_rate/readme/USAGE.rst
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.
Loading
Loading