diff --git a/purchase_supplierinfo_currency/README.rst b/purchase_supplierinfo_currency/README.rst new file mode 100644 index 00000000000..e28682abacb --- /dev/null +++ b/purchase_supplierinfo_currency/README.rst @@ -0,0 +1,74 @@ +============================== +Purchase Supplierinfo Currency +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/15.0/purchase_supplierinfo_currency + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-15-0/purchase-workflow-15-0-purchase_supplierinfo_currency + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/142/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +If a purchase order is created from a stock rule we create that purchase order with the supplierinfo currency. +If no exist we create a new purchase order with that currency. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Jarsa + +Contributors +~~~~~~~~~~~~ + +* Alan Ramos + +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/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_supplierinfo_currency/__init__.py b/purchase_supplierinfo_currency/__init__.py new file mode 100644 index 00000000000..7327cd4f831 --- /dev/null +++ b/purchase_supplierinfo_currency/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2023 Jarsa +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from . import models diff --git a/purchase_supplierinfo_currency/__manifest__.py b/purchase_supplierinfo_currency/__manifest__.py new file mode 100644 index 00000000000..9e9005a0578 --- /dev/null +++ b/purchase_supplierinfo_currency/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2023 Jarsa +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Purchase Supplierinfo Currency", + "version": "15.0.1.0.0", + "summary": "When a PO is created from an stock rule this module verifes " + "the product supplier info of the product to create PO per currency", + "author": "Jarsa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/purchase-workflow", + "category": "Purchase Management", + "license": "LGPL-3", + "depends": [ + "purchase_stock", + ], + "installable": True, +} diff --git a/purchase_supplierinfo_currency/models/__init__.py b/purchase_supplierinfo_currency/models/__init__.py new file mode 100644 index 00000000000..11ac3852e50 --- /dev/null +++ b/purchase_supplierinfo_currency/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2023 Jarsa +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from . import stock_rule diff --git a/purchase_supplierinfo_currency/models/stock_rule.py b/purchase_supplierinfo_currency/models/stock_rule.py new file mode 100644 index 00000000000..fe8e5d8fae0 --- /dev/null +++ b/purchase_supplierinfo_currency/models/stock_rule.py @@ -0,0 +1,24 @@ +# Copyright 2023 Jarsa +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + def _make_po_get_domain(self, company_id, values, partner): + domain = super()._make_po_get_domain(company_id, values, partner) + supplier = values.get("supplier") + if supplier and supplier.currency_id: + domain += (("currency_id", "=", supplier.currency_id.id),) + return domain + + def _prepare_purchase_order(self, company_id, origins, values): + res = super()._prepare_purchase_order(company_id, origins, values) + values = values[0] + seller = values.get("supplier") + seller_currency_id = seller.currency_id.id + company_currency_id = self.env.user.company_id.currency_id.id + res["currency_id"] = seller_currency_id or company_currency_id + return res diff --git a/purchase_supplierinfo_currency/readme/CONTRIBUTORS.rst b/purchase_supplierinfo_currency/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..9c31b0ce2d1 --- /dev/null +++ b/purchase_supplierinfo_currency/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alan Ramos diff --git a/purchase_supplierinfo_currency/readme/DESCRIPTION.rst b/purchase_supplierinfo_currency/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..d76f5bd6ba7 --- /dev/null +++ b/purchase_supplierinfo_currency/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +If a purchase order is created from a stock rule we create that purchase order with the supplierinfo currency. +If no exist we create a new purchase order with that currency. diff --git a/purchase_supplierinfo_currency/static/description/index.html b/purchase_supplierinfo_currency/static/description/index.html new file mode 100644 index 00000000000..a0bc89ed474 --- /dev/null +++ b/purchase_supplierinfo_currency/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +Purchase Supplierinfo Currency + + + +
+

Purchase Supplierinfo Currency

+ + +

Beta License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

If a purchase order is created from a stock rule we create that purchase order with the supplierinfo currency. +If no exist we create a new purchase order with that currency.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Jarsa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/setup/purchase_supplierinfo_currency/odoo/addons/purchase_supplierinfo_currency b/setup/purchase_supplierinfo_currency/odoo/addons/purchase_supplierinfo_currency new file mode 120000 index 00000000000..d10b2d13407 --- /dev/null +++ b/setup/purchase_supplierinfo_currency/odoo/addons/purchase_supplierinfo_currency @@ -0,0 +1 @@ +../../../../purchase_supplierinfo_currency \ No newline at end of file diff --git a/setup/purchase_supplierinfo_currency/setup.py b/setup/purchase_supplierinfo_currency/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_supplierinfo_currency/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)