Skip to content

Commit afab4d4

Browse files
[ADD] purchase_invoice_currency_custom_rate
Allows you to send rate values from a purchase when the invoice is issued in a currency other than the primary currency.
1 parent f0b3741 commit afab4d4

10 files changed

Lines changed: 564 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
=======================================
2+
Purchase Invoice - Currency Custom 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:6a578291debf966adc8b6cbf64ed683a996cbae61c2a77724a39ab81cafb9115
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-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-solvosci%2Fslv--purchase-lightgray.png?logo=github
20+
:target: https://github.com/solvosci/slv-purchase/tree/13.0/purchase_invoice_currency_custom_rate
21+
:alt: solvosci/slv-purchase
22+
23+
|badge1| |badge2| |badge3|
24+
25+
Allows you to send rate values from a purchase when the invoice is issued in a currency other than the primary currency.
26+
27+
**Table of contents**
28+
29+
.. contents::
30+
:local:
31+
32+
Bug Tracker
33+
===========
34+
35+
Bugs are tracked on `GitHub Issues <https://github.com/solvosci/slv-purchase/issues>`_.
36+
In case of trouble, please check there if your issue has already been reported.
37+
If you spotted it first, help us to smash it by providing a detailed and welcomed
38+
`feedback <https://github.com/solvosci/slv-purchase/issues/new?body=module:%20purchase_invoice_currency_custom_rate%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
39+
40+
Do not contact contributors directly about support or help with technical issues.
41+
42+
Credits
43+
=======
44+
45+
Authors
46+
~~~~~~~
47+
48+
* Solvos
49+
50+
Contributors
51+
~~~~~~~~~~~~
52+
53+
* Christian Santamaría <christian.santamaria@solvos.es>
54+
55+
Maintainers
56+
~~~~~~~~~~~
57+
58+
This module is part of the `solvosci/slv-purchase <https://github.com/solvosci/slv-purchase/tree/13.0/purchase_invoice_currency_custom_rate>`_ project on GitHub.
59+
60+
You are welcome to contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# © 2025 Solvos Consultoría Informática (<http://www.solvos.es>)
2+
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
3+
{
4+
"name": "Purchase Invoice - Currency Custom Rate",
5+
"summary": """
6+
Allows you to send rate values from a purchase when the invoice is issued in a currency other than the primary currency.
7+
""",
8+
"version": "13.0.1.0.0",
9+
"category": "Accounting & Finance",
10+
"website": "https://github.com/solvosci/slv-account",
11+
"author": "Solvos",
12+
"license": "LGPL-3",
13+
"depends": [
14+
"purchase",
15+
"account_invoice_currency_custom_rate",
16+
],
17+
"data": ["views/purchase_order_views.xml"],
18+
"installable": True,
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import purchase_order
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# © 2025 Solvos Consultoría Informática (<http://www.solvos.es>)
2+
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
3+
4+
from odoo import api, models, fields
5+
6+
7+
class PurchaseOrder(models.Model):
8+
_inherit = "purchase.order"
9+
10+
custom_rate = fields.Float(
11+
digits=(12, 6),
12+
default=1,
13+
help="Set new currency rate to apply on the invoice.\n"
14+
"This rate will be taken in order to convert amounts between the "
15+
"currency on the invoice and last currency",
16+
)
17+
is_custom_rate = fields.Boolean()
18+
19+
custom_rate_enabled_visible = fields.Boolean(
20+
string="Is 'Apply Custom Currency Rate' visible",
21+
compute="_compute_custom_rate_enabled_visible",
22+
)
23+
24+
@api.depends("state", "currency_id", "company_id")
25+
def _compute_custom_rate_enabled_visible(self):
26+
order_custom_rate_visible = self.browse([])
27+
if self.env.user.has_group(
28+
"account.group_account_manager"
29+
):
30+
order_custom_rate_visible = self.filtered(
31+
lambda x: (
32+
x.state not in ["draft", "done"]
33+
and x.currency_id != x.company_id.currency_id
34+
)
35+
)
36+
if order_custom_rate_visible:
37+
order_custom_rate_visible.custom_rate_enabled_visible = True
38+
(self - order_custom_rate_visible).custom_rate_enabled_visible = False
39+
40+
41+
def _prepare_invoice(self):
42+
res = super()._prepare_invoice()
43+
if self.is_custom_rate:
44+
res.update({
45+
"custom_rate": self.custom_rate,
46+
"is_custom_rate": self.is_custom_rate,
47+
})
48+
return res
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Christian Santamaría <christian.santamaria@solvos.es>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allows you to send rate values from a purchase when the invoice is issued in a currency other than the primary currency.
1.22 KB
Loading

0 commit comments

Comments
 (0)