Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
=========================
Account - Manual Currency
=========================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b67beae0c60d4c938fc5bb23df9cfb7a3397a22096dc051c084302dac303b677
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_manual_currency
: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_manual_currency
: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|
This module allows users to update the currency manually for invoices
that are still in the draft stage. It offers flexibility to companies
when calculating currency rates for invoicing.
For example, if a company makes a deal with a vendor but the actual
purchase happens on a different day, this module lets them choose
whether to use the currency rate from the accounting date or a special
rate agreed upon during the deal. This ensures accurate currency rate
calculations for invoices, even when the purchase date and deal date
differ.
**Table of contents**
.. contents::
:local:
Usage
=====
To use this module, the company must have access rights for multiple
currencies.
Follow these steps to use manual currency:
1. Go to Invoicing > Create new invoice/bills.
2. If you need to change the currency to one other than the company's
default currency, you will see an option for 'Manual Currency'.
3. Check the 'Manual Currency' box to enable manual currency entry.
4. Specify the desired currency rate for the selected currency.
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_manual_currency%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
-------
* Ecosoft
Contributors
------------
- Saran Lim. <saranl@ecosoft.co.th>
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.
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/18.0/account_manual_currency>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from . import wizard

View File

@@ -0,0 +1,20 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Account - Manual Currency",
"version": "18.0.1.0.0",
"category": "Accounting & Finance",
"summary": "Allows to manual currency of Accounting",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"license": "AGPL-3",
"depends": ["account"],
"data": [
"data/decimal_data.xml",
"views/account_move_view.xml",
"wizard/account_payment_register_views.xml",
],
"installable": True,
"maintainer": ["Saran440"],
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="decimal_price" model="decimal.precision" forcecreate="True">
<field name="name">Manual Currency</field>
<field name="digits">12</field>
</record>
</odoo>

View File

@@ -0,0 +1,113 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_manual_currency
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/models/account_move.py:0
msgid "%(company_currency_name)s per 1 %(rate_currency_name)s"
msgstr ""
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/models/account_move.py:0
msgid "%(rate_currency_name)s per 1 %(company_currency_name)s"
msgstr ""
#. module: account_manual_currency
#: model_terms:ir.ui.view,arch_db:account_manual_currency.view_move_form
msgid "<i title=\"Update Currency\" class=\"fa fa-fw fa-refresh\"/>"
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__currency_diff
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__currency_diff
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__currency_diff
msgid "Currency Diff"
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__is_manual
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__is_manual
msgid "Is Manual"
msgstr ""
#. module: account_manual_currency
#: model:ir.model,name:account_manual_currency.model_account_move
msgid "Journal Entry"
msgstr ""
#. module: account_manual_currency
#: model:ir.model,name:account_manual_currency.model_account_move_line
msgid "Journal Item"
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__manual_currency
msgid "Manual Currency"
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__manual_currency_rate
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__manual_currency_rate
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__manual_currency_rate
msgid "Manual Currency Rate"
msgstr ""
#. module: account_manual_currency
#: model_terms:ir.ui.view,arch_db:account_manual_currency.view_move_form
msgid "Opened"
msgstr ""
#. module: account_manual_currency
#: model:ir.model,name:account_manual_currency.model_account_payment_register
msgid "Pay"
msgstr ""
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/models/account_move.py:0
msgid "Rate currency can refresh state draft only."
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,help:account_manual_currency.field_account_bank_statement_line__manual_currency_rate
#: model:ir.model.fields,help:account_manual_currency.field_account_move__manual_currency_rate
#: model:ir.model.fields,help:account_manual_currency.field_account_payment_register__manual_currency_rate
msgid ""
"Set new currency rate to apply on the invoice\n"
".This rate will be taken in order to convert amounts between the currency on the purchase order and last currency"
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__total_company_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__total_company_currency
msgid "Total Company Currency"
msgstr ""
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__type_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__type_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__type_currency
msgid "Type Currency"
msgstr ""
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/wizard/account_payment_register.py:0
msgid ""
"You can only register payments for moves with the same manual currency."
msgstr ""

View File

@@ -0,0 +1,121 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_manual_currency
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-06-04 07:31+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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 5.10.4\n"
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/models/account_move.py:0
msgid "%(company_currency_name)s per 1 %(rate_currency_name)s"
msgstr "%(company_currency_name)s per 1 %(rate_currency_name)s"
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/models/account_move.py:0
msgid "%(rate_currency_name)s per 1 %(company_currency_name)s"
msgstr "%(rate_currency_name)s per 1 %(company_currency_name)s"
#. module: account_manual_currency
#: model_terms:ir.ui.view,arch_db:account_manual_currency.view_move_form
msgid "<i title=\"Update Currency\" class=\"fa fa-fw fa-refresh\"/>"
msgstr "<i title=\"Aggiorna valuta\" class=\"fa fa-fw fa-refresh\"/>"
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__currency_diff
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__currency_diff
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__currency_diff
msgid "Currency Diff"
msgstr "Diff. valuta"
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__is_manual
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__is_manual
msgid "Is Manual"
msgstr "È manuale"
#. module: account_manual_currency
#: model:ir.model,name:account_manual_currency.model_account_move
msgid "Journal Entry"
msgstr "Registrazione contabile"
#. module: account_manual_currency
#: model:ir.model,name:account_manual_currency.model_account_move_line
msgid "Journal Item"
msgstr "Movimento contabile"
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__manual_currency
msgid "Manual Currency"
msgstr "Valuta manuale"
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__manual_currency_rate
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__manual_currency_rate
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__manual_currency_rate
msgid "Manual Currency Rate"
msgstr "Tasso di cambio manuale"
#. module: account_manual_currency
#: model_terms:ir.ui.view,arch_db:account_manual_currency.view_move_form
msgid "Opened"
msgstr "Aperta"
#. module: account_manual_currency
#: model:ir.model,name:account_manual_currency.model_account_payment_register
msgid "Pay"
msgstr "Paga"
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/models/account_move.py:0
msgid "Rate currency can refresh state draft only."
msgstr "Il tasso di cambio può aggiornare solo lo stato bozza."
#. module: account_manual_currency
#: model:ir.model.fields,help:account_manual_currency.field_account_bank_statement_line__manual_currency_rate
#: model:ir.model.fields,help:account_manual_currency.field_account_move__manual_currency_rate
#: model:ir.model.fields,help:account_manual_currency.field_account_payment_register__manual_currency_rate
msgid ""
"Set new currency rate to apply on the invoice\n"
".This rate will be taken in order to convert amounts between the currency on the purchase order and last currency"
msgstr ""
"Imposta il nuovo tasso di cambio da applicare alla fattura. \n"
"Questo tasso verrà utilizzato per convertire gli importi tra la valuta "
"dell'ordine di acquisto e l'ultima valuta"
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__total_company_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__total_company_currency
msgid "Total Company Currency"
msgstr "Totale in valuta dell'azienda"
#. module: account_manual_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_bank_statement_line__type_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_move__type_currency
#: model:ir.model.fields,field_description:account_manual_currency.field_account_payment_register__type_currency
msgid "Type Currency"
msgstr "Tipo valuta"
#. module: account_manual_currency
#. odoo-python
#: code:addons/account_manual_currency/wizard/account_payment_register.py:0
msgid ""
"You can only register payments for moves with the same manual currency."
msgstr ""
"Si possono registrare pagamenti solo per movimenti con la stessa valuta "
"manuale."

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import account_move

View File

@@ -0,0 +1,180 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from lxml import etree
from odoo import api, fields, models
from odoo.exceptions import ValidationError
class AccountMove(models.Model):
_inherit = "account.move"
manual_currency = fields.Boolean()
is_manual = fields.Boolean(compute="_compute_currency")
type_currency = fields.Selection(
selection=lambda self: self._get_label_currency_name(),
default=lambda self: self._get_label_currency_name()[0][0],
)
manual_currency_rate = fields.Float(
digits="Manual Currency",
tracking=True,
help="Set new currency rate to apply on the invoice\n."
"This rate will be taken in order to convert amounts between the "
"currency on the purchase order and last currency",
)
total_company_currency = fields.Monetary(
compute="_compute_total_company_currency", currency_field="company_currency_id"
)
currency_diff = fields.Boolean(
compute="_compute_currency_diff",
store=True,
)
@api.depends("currency_id")
def _compute_currency_diff(self):
for rec in self:
rec.currency_diff = rec.company_currency_id != rec.currency_id
@api.depends("line_ids.balance")
def _compute_total_company_currency(self):
"""Convert total currency to company currency"""
for rec in self:
# check manual currency
if rec.manual_currency:
rate = (
rec.manual_currency_rate
if rec.type_currency == "inverse_company_rate"
else (1.0 / rec.manual_currency_rate)
)
rec.total_company_currency = rec.amount_total * rate
# default rate currency
else:
rec.total_company_currency = rec.currency_id._convert(
rec.amount_total,
rec.company_currency_id,
rec.company_id,
fields.Date.today(),
)
def _get_label_currency_name(self):
"""Get label related currency"""
names = {
"company_currency_name": (
self.env["res.company"].browse(self._context.get("company_id"))
or self.env.company
).currency_id.name,
"rate_currency_name": "Currency",
}
return [
[
"company_rate",
self.env._(
"%(rate_currency_name)s per 1 %(company_currency_name)s", **names
),
],
[
"inverse_company_rate",
self.env._(
"%(company_currency_name)s per 1 %(rate_currency_name)s", **names
),
],
]
@api.onchange("manual_currency", "type_currency", "currency_id", "date")
def _onchange_currency_change_rate(self):
today = fields.Date.today()
company_currency = self.env.company.currency_id
amount_currency = company_currency._get_conversion_rate(
company_currency,
self.currency_id,
self.company_id,
self.date or today,
)
if self.type_currency == "inverse_company_rate":
amount_currency = 1.0 / amount_currency
self.manual_currency_rate = amount_currency
@api.depends("currency_id")
def _compute_currency(self):
for rec in self:
rec.is_manual = rec.currency_id != rec.company_id.currency_id
def action_refresh_currency(self):
self.ensure_one()
if self.state != "draft":
raise ValidationError(
self.env._("Rate currency can refresh state draft only.")
)
self.with_context(check_move_validity=False)._onchange_currency_change_rate()
return True
@api.depends(
"currency_id",
"company_currency_id",
"company_id",
"invoice_date",
"manual_currency_rate",
)
def _compute_invoice_currency_rate(self):
res = super()._compute_invoice_currency_rate()
for move in self:
if not move.manual_currency:
continue
# Currency Rate on move use 'company_rate'
rate = (
move.manual_currency_rate
if move.type_currency == "company_rate"
else (1.0 / move.manual_currency_rate)
)
move.invoice_currency_rate = rate
return res
@api.model
def get_view(self, view_id=None, view_type="form", **options):
"""Change string name to company currency"""
result = super().get_view(view_id=view_id, view_type=view_type, **options)
if view_type == "form":
company_currency_name = (
self.env["res.company"].browse(self._context.get("company_id"))
or self.env.company
).currency_id.name
doc = etree.XML(result["arch"])
# Total company currency
node = doc.xpath("//field[@name='total_company_currency']")
if node:
node[0].set("string", f"Total ({company_currency_name})")
result["arch"] = etree.tostring(doc, encoding="unicode")
return result
@api.onchange("manual_currency_rate")
def _onchange_manual_currency_rate(self):
"""Refresh currency rate if manual currency rate is 0"""
for move in self:
if move.manual_currency and not move.manual_currency_rate:
move.action_refresh_currency()
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
@api.depends(
"currency_id",
"company_id",
"move_id.invoice_currency_rate",
"move_id.date",
"move_id.manual_currency_rate",
)
def _compute_currency_rate(self):
res = super()._compute_currency_rate()
for line in self:
if not line.move_id.manual_currency:
continue
# Currency Rate on move line use 'company_rate'
rate = (
line.move_id._origin.manual_currency_rate
if line.move_id.type_currency == "company_rate"
else (1.0 / line.move_id._origin.manual_currency_rate)
)
line.currency_rate = rate
return res

View File

@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@@ -0,0 +1 @@
- Saran Lim. \<<saranl@ecosoft.co.th>\>

View File

@@ -0,0 +1,10 @@
This module allows users to update the currency manually for invoices
that are still in the draft stage. It offers flexibility to companies
when calculating currency rates for invoicing.
For example, if a company makes a deal with a vendor but the actual
purchase happens on a different day, this module lets them choose
whether to use the currency rate from the accounting date or a special
rate agreed upon during the deal. This ensures accurate currency rate
calculations for invoices, even when the purchase date and deal date
differ.

View File

@@ -0,0 +1,10 @@
To use this module, the company must have access rights for multiple
currencies.
Follow these steps to use manual currency:
1. Go to Invoicing \> Create new invoice/bills.
2. If you need to change the currency to one other than the company's
default currency, you will see an option for 'Manual Currency'.
3. Check the 'Manual Currency' box to enable manual currency entry.
4. Specify the desired currency rate for the selected currency.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,445 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Account - Manual Currency</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="account-manual-currency">
<h1 class="title">Account - Manual Currency</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b67beae0c60d4c938fc5bb23df9cfb7a3397a22096dc051c084302dac303b677
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoicing/tree/18.0/account_manual_currency"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-account_manual_currency"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to update the currency manually for invoices
that are still in the draft stage. It offers flexibility to companies
when calculating currency rates for invoicing.</p>
<p>For example, if a company makes a deal with a vendor but the actual
purchase happens on a different day, this module lets them choose
whether to use the currency rate from the accounting date or a special
rate agreed upon during the deal. This ensures accurate currency rate
calculations for invoices, even when the purchase date and deal date
differ.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To use this module, the company must have access rights for multiple
currencies.</p>
<p>Follow these steps to use manual currency:</p>
<ol class="arabic simple">
<li>Go to Invoicing &gt; Create new invoice/bills.</li>
<li>If you need to change the currency to one other than the companys
default currency, you will see an option for Manual Currency.</li>
<li>Check the Manual Currency box to enable manual currency entry.</li>
<li>Specify the desired currency rate for the selected currency.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoicing/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_manual_currency%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Ecosoft</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-invoicing/tree/18.0/account_manual_currency">OCA/account-invoicing</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from . import test_account_manual_currency

View File

@@ -0,0 +1,174 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import Command, fields
from odoo.exceptions import UserError, ValidationError
from odoo.tests import Form, TransactionCase
class TestAccountManualCurrency(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.inv_model = cls.env["account.move"]
cls.payment_model = cls.env["account.payment"]
cls.payment_register_model = cls.env["account.payment.register"]
cls.register_view_id = "account.view_account_payment_register_form"
# Activate Multi Currency
cls.usd_currency = cls.env.ref("base.USD")
cls.eur_currency = cls.env.ref("base.EUR")
cls.eur_currency.active = True
cls.partner1 = cls.env.ref("base.res_partner_3")
cls.cash = cls.env["account.journal"].create(
{"name": "Cash Test", "type": "cash", "code": "CT"}
)
def _create_invoice(
self,
partner,
invoice_type,
currency,
manual_currency=False,
manual_currency_rate=0.0,
type_currency="company_rate",
):
inv_line = [
Command.create(
{
"product_id": self.env.ref("product.product_product_8").id,
"name": "Test Invoice Line",
"quantity": 1.0,
"price_unit": 100.0,
"tax_ids": False,
},
)
]
invoice = self.inv_model.create(
{
"partner_id": partner.id,
"invoice_date": fields.Date.today(),
"move_type": invoice_type,
"currency_id": currency.id,
"manual_currency": manual_currency,
"type_currency": type_currency,
"manual_currency_rate": manual_currency_rate,
"invoice_line_ids": inv_line,
}
)
return invoice
def test_01_account_move_inverse_currency(self):
# Create invoice with custom rate: 10 USD = 1 EUR
invoice1 = self._create_invoice(
self.partner1,
"in_invoice",
self.eur_currency,
True,
10,
"inverse_company_rate",
)
invoice1.get_view()
self.assertTrue(invoice1.is_manual)
# Currency will recompute to default
self.assertTrue(invoice1.manual_currency)
self.assertAlmostEqual(invoice1.manual_currency_rate, 10)
self.assertAlmostEqual(invoice1.invoice_currency_rate, 0.1) # Inverse rate
invoice1.action_refresh_currency()
self.assertNotEqual(invoice1.manual_currency_rate, 10)
total_currency_not_manual = invoice1.total_company_currency
self.assertAlmostEqual(
total_currency_not_manual,
sum(
invoice1.line_ids.filtered(lambda line: line.balance > 0).mapped(
"balance"
)
),
)
# Use manual currency
with Form(invoice1) as inv:
inv.manual_currency = True
inv.type_currency = "inverse_company_rate"
inv.manual_currency_rate = 20 # Convert rate: 20 USD = 1 EUR
inv.save()
# After manual currency, total currency will recompute
self.assertNotEqual(invoice1.total_company_currency, total_currency_not_manual)
self.assertAlmostEqual(
invoice1.total_company_currency,
sum(
invoice1.line_ids.filtered(lambda line: line.balance > 0).mapped(
"balance"
)
),
)
invoice1.action_post()
self.assertEqual(invoice1.state, "posted")
# Can't refresh rate when state is not draft
with self.assertRaises(ValidationError):
invoice1.action_refresh_currency()
# Create invoice
invoice2 = self._create_invoice(self.partner1, "in_invoice", self.usd_currency)
invoice2.action_post()
self.assertEqual(invoice2.state, "posted")
# Register Payment
# Can't register payment with not same manual currency
ctx = {
"active_ids": (invoice1 + invoice2).mapped("line_ids").ids,
"active_model": "account.move.line",
}
with self.assertRaises(UserError):
Form(
self.payment_register_model.with_context(**ctx),
view=self.register_view_id,
).save()
ctx = {
"active_ids": [invoice1.id],
"active_model": "account.move",
}
with Form(
self.payment_register_model.with_context(**ctx),
view=self.register_view_id,
) as f:
f.amount = invoice1.amount_total
wiz = f.save()
wiz.action_create_payments()
def test_02_manual_currency_rate_on_inv_payment(self):
# Create invoice with custom rate: 10 EUR = 1 USD
invoice1 = self._create_invoice(
self.partner1,
"in_invoice",
self.eur_currency,
True,
10,
"company_rate",
)
invoice1.action_post()
self.assertTrue(invoice1.manual_currency)
self.assertAlmostEqual(invoice1.manual_currency_rate, 10.0)
self.assertAlmostEqual(invoice1.invoice_currency_rate, 10.0) # Inverse rate
self.assertAlmostEqual(invoice1.invoice_line_ids.balance, 10.0)
# Register with manual currency
# Convert rate: 20 EUR = 1 USD
ctx = {
"active_ids": [invoice1.id],
"active_model": "account.move",
}
with Form(
self.payment_register_model.with_context(**ctx),
view=self.register_view_id,
) as f:
f.amount = invoice1.amount_total
f.manual_currency = True
f.type_currency = "company_rate"
f.manual_currency_rate = 20
wiz = f.save()
action_payment = wiz.action_create_payments()
payment = self.payment_model.browse(action_payment["res_id"])
move_payment = payment.move_id
self.assertAlmostEqual(move_payment.manual_currency_rate, 20)
self.assertAlmostEqual(move_payment.invoice_currency_rate, 20)
self.assertAlmostEqual(abs(move_payment.line_ids[0].balance), 5)

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath
expr="//group[@id='header_right_group']/div[@name='journal_div']"
position="after"
>
<field name="is_manual" invisible="1" />
<label
for="manual_currency"
groups="base.group_multi_currency"
invisible="not is_manual"
/>
<div groups="base.group_multi_currency" invisible="not is_manual">
<field name="manual_currency" readonly="state != 'draft'" />
<label for="manual_currency_rate" invisible='1' />
<div class="o_row" invisible="not manual_currency">
<field
name="manual_currency_rate"
readonly="state != 'draft'"
/>
<field
name="type_currency"
required="manual_currency"
readonly="state != 'draft'"
/>
<button
aria-label="Opened"
type="object"
name="action_refresh_currency"
class="btn-link"
invisible="state != 'draft'"
>
<i title="Update Currency" class="fa fa-fw fa-refresh" />
</button>
</div>
</div>
</xpath>
<xpath expr="//field[@name='tax_totals']" position="before">
<field name="total_company_currency" invisible="not currency_diff" />
<field name="company_currency_id" invisible="1" />
<field name="currency_diff" invisible="1" />
</xpath>
<xpath expr="//field[@name='invoice_line_ids']/list" position="inside">
<field name="currency_rate" optional="show" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_payment_register

View File

@@ -0,0 +1,75 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
class AccountPaymentRegister(models.TransientModel):
_inherit = "account.payment.register"
currency_diff = fields.Boolean(
compute="_compute_currency_diff",
store=True,
)
manual_currency = fields.Boolean()
type_currency = fields.Selection(
selection=lambda self: self.line_ids.move_id._get_label_currency_name(),
)
manual_currency_rate = fields.Float(
digits="Manual Currency",
help="Set new currency rate to apply on the invoice\n."
"This rate will be taken in order to convert amounts between the "
"currency on the purchase order and last currency",
)
@api.depends("currency_id")
def _compute_currency_diff(self):
for rec in self:
rec.currency_diff = rec.company_currency_id != rec.currency_id
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
if self._context.get("active_model") == "account.move":
moves = self.env["account.move"].browse(self._context.get("active_ids", []))
elif self._context.get("active_model") == "account.move.line":
moves = (
self.env["account.move.line"]
.browse(self._context.get("active_ids", []))
.mapped("move_id")
)
# Check manual currency
if len(set(moves.mapped("manual_currency"))) != 1:
raise UserError(
_(
"You can only register payments for moves "
"with the same manual currency."
)
)
res["manual_currency"] = moves.mapped("manual_currency")[0]
if len(list(set(moves.mapped("manual_currency_rate")))) == 1:
res["manual_currency_rate"] = moves.mapped("manual_currency_rate")[0]
if len(list(set(moves.mapped("type_currency")))) == 1:
res["type_currency"] = moves.mapped("type_currency")[0]
return res
def _init_payments(self, to_process, edit_mode=False):
"""Update currency rate on move line payment"""
payments = super()._init_payments(to_process, edit_mode)
if self.manual_currency:
for vals in to_process:
payment = vals["payment"]
payment.move_id.write(
{
"manual_currency": self.manual_currency,
"type_currency": self.type_currency,
"manual_currency_rate": self.manual_currency_rate,
}
)
payment_ml = payment.move_id.line_ids
payment_ml._compute_currency_rate()
payment_ml.with_context(
check_move_validity=False
)._inverse_amount_currency()
return payments

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_account_payment_register_form" model="ir.ui.view">
<field name="name">account.payment.register.form</field>
<field name="model">account.payment.register</field>
<field name="inherit_id" ref="account.view_account_payment_register_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='group2']" position="inside">
<field name="currency_diff" invisible="1" />
<label
for="manual_currency"
groups="base.group_multi_currency"
invisible="not currency_diff"
/>
<div groups="base.group_multi_currency" invisible="not currency_diff">
<field name="manual_currency" />
<label for="manual_currency_rate" invisible='1' />
<div class="o_row" invisible="not manual_currency">
<field name="manual_currency_rate" />
<field name="type_currency" required="manual_currency" />
</div>
</div>
</xpath>
</field>
</record>
</odoo>