Skip to content

Commit 2d7aabe

Browse files
committed
[ADD] purchase_currency: Module added
1 parent c6856fc commit 2d7aabe

20 files changed

+793
-0
lines changed

purchase_currency/README.rst

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
=================
2+
Purchase Currency
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:d37288d0febe4e6faa7753303b3c57863c066034c774036b4fec2298fc0d8d2c
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-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/purchase-workflow/tree/16.0/purchase_currency
21+
:alt: OCA/purchase-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-purchase_currency
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Set default currency for the company purchase orders.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Use Cases / Context
39+
===================
40+
41+
This module is useful when a company operates in a muli-currency
42+
environment and most of the purchases are made in a currency other than
43+
that the main currency of the company.
44+
45+
Configuration
46+
=============
47+
48+
Go to the Settings -> Purchase:
49+
50+
- Set "Default Purchase Currency" with an available currency
51+
- Press the "Save" button to apply changes
52+
53+
Usage
54+
=====
55+
56+
Once module is configured, the default currency will be set:
57+
58+
1. As the default value for the "Currency" field in Requst For Quotation
59+
2. As the default Journal Currency in Vendor Bill.
60+
61+
Bug Tracker
62+
===========
63+
64+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
65+
In case of trouble, please check there if your issue has already been reported.
66+
If you spotted it first, help us to smash it by providing a detailed and welcomed
67+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_currency%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
68+
69+
Do not contact contributors directly about support or help with technical issues.
70+
71+
Credits
72+
=======
73+
74+
Authors
75+
~~~~~~~
76+
77+
* Cetmix
78+
79+
Contributors
80+
~~~~~~~~~~~~
81+
82+
* `Cetmix <http://cetmix.com>`_
83+
84+
* Ivan Sokolov
85+
* Mikhail Lapin
86+
* Maksim Shurupov
87+
* Dinar Gabbasov
88+
89+
Maintainers
90+
~~~~~~~~~~~
91+
92+
This module is maintained by the OCA.
93+
94+
.. image:: https://odoo-community.org/logo.png
95+
:alt: Odoo Community Association
96+
:target: https://odoo-community.org
97+
98+
OCA, or the Odoo Community Association, is a nonprofit organization whose
99+
mission is to support the collaborative development of Odoo features and
100+
promote its widespread use.
101+
102+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/purchase_currency>`_ project on GitHub.
103+
104+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

purchase_currency/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from . import models

purchase_currency/__manifest__.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Purchase Currency",
6+
"version": "16.0.1.0.0",
7+
"category": "Purchase",
8+
"license": "AGPL-3",
9+
"summary": "Select the default currency for purchases",
10+
"author": "Cetmix, Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/purchase-workflow",
12+
"depends": ["purchase", "sale", "stock"],
13+
"data": [
14+
"views/res_config_settings_views.xml",
15+
],
16+
"installable": True,
17+
}

purchase_currency/models/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from . import purchase_order
5+
from . import res_company
6+
from . import res_config_settings
7+
from . import sale_order_line
8+
from . import stock_rule
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class PurchaseOrder(models.Model):
8+
_inherit = "purchase.order"
9+
10+
currency_id = fields.Many2one(default=lambda self: self._default_currency_id())
11+
12+
def _default_currency_id(self):
13+
company = self.env.company
14+
return company.default_purchase_currency_id or company.currency_id
15+
16+
@api.onchange("partner_id", "company_id")
17+
def onchange_partner_id(self):
18+
default_currency_id = self.env.company.default_purchase_currency_id.id
19+
if not default_currency_id:
20+
return super().onchange_partner_id()
21+
return super(
22+
PurchaseOrder, self.with_context(default_currency_id=default_currency_id)
23+
).onchange_partner_id()
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResCompany(models.Model):
8+
_inherit = "res.company"
9+
10+
default_purchase_currency_id = fields.Many2one(
11+
comodel_name="res.currency", string="Default Purchase Currency"
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResConfigSettings(models.TransientModel):
8+
_inherit = "res.config.settings"
9+
10+
company_default_purchase_currency_id = fields.Many2one(
11+
related="company_id.default_purchase_currency_id",
12+
readonly=False,
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class SaleOrderLine(models.Model):
8+
_inherit = "sale.order.line"
9+
10+
def _purchase_service_prepare_order_values(self, supplierinfo):
11+
result = super()._purchase_service_prepare_order_values(supplierinfo)
12+
supplier_currency = supplierinfo.partner_id.property_purchase_currency_id
13+
default_purchase_currency = self.env.company.default_purchase_currency_id
14+
if not supplier_currency and default_purchase_currency:
15+
result.update(currency_id=default_purchase_currency.id)
16+
return result
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class StockRule(models.Model):
8+
_inherit = "stock.rule"
9+
10+
def _prepare_purchase_order(self, company_id, origins, values):
11+
result = super()._prepare_purchase_order(company_id, origins, values)
12+
values = values[0]
13+
partner = values["supplier"].partner_id
14+
supplier_currency = partner.with_company(
15+
company_id
16+
).property_purchase_currency_id
17+
default_purchase_currency = self.env.company.default_purchase_currency_id
18+
if not supplier_currency and default_purchase_currency:
19+
result.update(currency_id=default_purchase_currency.id)
20+
return result
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Go to the Settings -> Purchase:
2+
3+
- Set "Default Purchase Currency" with an available currency
4+
- Press the "Save" button to apply changes

purchase_currency/readme/CONTEXT.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This module is useful when a company operates in a muli-currency
2+
environment and most of the purchases are made in a currency other than
3+
that the main currency of the company.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* `Cetmix <http://cetmix.com>`_
2+
3+
* Ivan Sokolov
4+
* Mikhail Lapin
5+
* Maksim Shurupov
6+
* Dinar Gabbasov
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Set default currency for the company purchase orders.

purchase_currency/readme/USAGE.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Once module is configured, the default currency will be set:
2+
3+
1. As the default value for the "Currency" field in Requst For Quotation
4+
2. As the default Journal Currency in Vendor Bill.

0 commit comments

Comments
 (0)