Skip to content

Commit 8bbbc7d

Browse files
committed
[ADD] purchase_supplierinfo_currency: module to split purchase orders by currency using supplierinfo currency
1 parent 123fb73 commit 8bbbc7d

File tree

8 files changed

+551
-0
lines changed

8 files changed

+551
-0
lines changed
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
==============================
2+
Purchase Supplierinfo 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:c7fae92837c36b4918773abd5bddadd19717db17447d868d651d29768ab93162
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-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/purchase-workflow/tree/16.0/purchase_supplierinfo_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_supplierinfo_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+
If a purchase order is created from a stock rule we create that purchase order with the supplierinfo currency.
32+
If no exist we create a new purchase order with that currency.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Bug Tracker
40+
===========
41+
42+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
43+
In case of trouble, please check there if your issue has already been reported.
44+
If you spotted it first, help us to smash it by providing a detailed and welcomed
45+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_supplierinfo_currency%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
46+
47+
Do not contact contributors directly about support or help with technical issues.
48+
49+
Credits
50+
=======
51+
52+
Authors
53+
~~~~~~~
54+
55+
* Jarsa
56+
57+
Contributors
58+
~~~~~~~~~~~~
59+
60+
* Alan Ramos <alan.ramos@jarsa.com>
61+
62+
Maintainers
63+
~~~~~~~~~~~
64+
65+
This module is maintained by the OCA.
66+
67+
.. image:: https://odoo-community.org/logo.png
68+
:alt: Odoo Community Association
69+
:target: https://odoo-community.org
70+
71+
OCA, or the Odoo Community Association, is a nonprofit organization whose
72+
mission is to support the collaborative development of Odoo features and
73+
promote its widespread use.
74+
75+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/purchase_supplierinfo_currency>`_ project on GitHub.
76+
77+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2023 Jarsa
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2023 Jarsa
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
{
5+
"name": "Purchase Supplierinfo Currency",
6+
"version": "16.0.1.0.0",
7+
"summary": "When a PO is created from an stock rule this module verifes "
8+
"the product supplier info of the product to create PO per currency",
9+
"author": "Jarsa, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/purchase-workflow",
11+
"category": "Purchase Management",
12+
"license": "LGPL-3",
13+
"depends": [
14+
"purchase_stock",
15+
],
16+
"installable": True,
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2023 Jarsa
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from . import stock_rule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2023 Jarsa
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from odoo import models
5+
6+
7+
class StockRule(models.Model):
8+
_inherit = "stock.rule"
9+
10+
def _make_po_get_domain(self, company_id, values, partner):
11+
domain = super()._make_po_get_domain(company_id, values, partner)
12+
supplier = values.get("supplier")
13+
if supplier and supplier.currency_id:
14+
domain += (("currency_id", "=", supplier.currency_id.id),)
15+
return domain
16+
17+
def _prepare_purchase_order(self, company_id, origins, values):
18+
res = super()._prepare_purchase_order(company_id, origins, values)
19+
values = values[0]
20+
seller = values.get("supplier")
21+
seller_currency_id = seller.currency_id.id
22+
company_currency_id = self.env.user.company_id.currency_id.id
23+
res["currency_id"] = seller_currency_id or company_currency_id
24+
return res
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Alan Ramos <alan.ramos@jarsa.com>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
If a purchase order is created from a stock rule we create that purchase order with the supplierinfo currency.
2+
If no exist we create a new purchase order with that currency.

0 commit comments

Comments
 (0)