diff --git a/account_payment_purchase_stock/README.rst b/account_payment_purchase_stock/README.rst new file mode 100644 index 000000000000..81daa22c7b9e --- /dev/null +++ b/account_payment_purchase_stock/README.rst @@ -0,0 +1,106 @@ +============================== +Account Payment Purchase Stock +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b15b891b0bc8f4e16bbc3795eb9be106e590b320ec98df4f82f32d3139731ebc + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fbank--payment-lightgray.png?logo=github + :target: https://github.com/OCA/bank-payment/tree/18.0/account_payment_purchase_stock + :alt: OCA/bank-payment +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/bank-payment-18-0/bank-payment-18-0-account_payment_purchase_stock + :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/bank-payment&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module combines the *account_payment_purchase* module with +*purchase_stock*. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module depends on : + +- purchase_stock +- account_payment_purchase + +This module is part of the OCA/bank-payment suite. + +Usage +===== + +This module doesn't add any feature, but it is used by several other +modules. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Akretion +* Tecnativa + +Contributors +------------ + +- Alexis de Lattre +- Alexandre Fayolle +- Danimar Ribeiro +- Raphaël Valyi +- Abraham Anes +- `Tecnativa `__: + + - Pedro M. Baeza + - Vicent Cubells + +- Nikul Chaudhary +- Miquel Raïch +- Andrea Stirpe + +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/bank-payment `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_purchase_stock/__init__.py b/account_payment_purchase_stock/__init__.py new file mode 100644 index 000000000000..83e553ac462c --- /dev/null +++ b/account_payment_purchase_stock/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/account_payment_purchase_stock/__manifest__.py b/account_payment_purchase_stock/__manifest__.py new file mode 100644 index 000000000000..c6ad4d28d454 --- /dev/null +++ b/account_payment_purchase_stock/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2016 Akretion (). +# Copyright 2017 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Account Payment Purchase Stock", + "version": "18.0.1.0.0", + "category": "Banking addons", + "license": "AGPL-3", + "summary": "Integrate Account Payment Purchase with Stock", + "author": "Akretion, Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/bank-payment", + "depends": ["account_payment_purchase", "purchase_stock"], + "installable": True, + "auto_install": True, +} diff --git a/account_payment_purchase_stock/i18n/account_payment_purchase_stock.pot b/account_payment_purchase_stock/i18n/account_payment_purchase_stock.pot new file mode 100644 index 000000000000..ff79ba993a35 --- /dev/null +++ b/account_payment_purchase_stock/i18n/account_payment_purchase_stock.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "" diff --git a/account_payment_purchase_stock/i18n/ca.po b/account_payment_purchase_stock/i18n/ca.po new file mode 100644 index 000000000000..9606e4c2a13c --- /dev/null +++ b/account_payment_purchase_stock/i18n/ca.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-29 20:37+0000\n" +"Last-Translator: Santiago Payà \n" +"Language-Team: none\n" +"Language: ca\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 4.17\n" + +#. module: account_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "Regla d’estoc" diff --git a/account_payment_purchase_stock/i18n/es.po b/account_payment_purchase_stock/i18n/es.po new file mode 100644 index 000000000000..73af41393806 --- /dev/null +++ b/account_payment_purchase_stock/i18n/es.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-21 09:11+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\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 4.17\n" + +#. module: account_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "Regla de existencias" diff --git a/account_payment_purchase_stock/i18n/es_AR.po b/account_payment_purchase_stock/i18n/es_AR.po new file mode 100644 index 000000000000..dd37f3d02680 --- /dev/null +++ b/account_payment_purchase_stock/i18n/es_AR.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-04-01 03:48+0000\n" +"Last-Translator: Ignacio Buioli \n" +"Language-Team: none\n" +"Language: es_AR\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 4.3.2\n" + +#. module: account_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "Regla de Inventario" + +#~ msgid "Display Name" +#~ msgstr "Mostrar Nombre" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Última modificación en" diff --git a/account_payment_purchase_stock/i18n/fr.po b/account_payment_purchase_stock/i18n/fr.po new file mode 100644 index 000000000000..a6bf699d17aa --- /dev/null +++ b/account_payment_purchase_stock/i18n/fr.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-29 12:08+0000\n" +"Last-Translator: Rémi \n" +"Language-Team: none\n" +"Language: fr\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 4.17\n" + +#. module: account_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "Règle de stock" diff --git a/account_payment_purchase_stock/i18n/fr_FR.po b/account_payment_purchase_stock/i18n/fr_FR.po new file mode 100644 index 000000000000..8c301fee50a4 --- /dev/null +++ b/account_payment_purchase_stock/i18n/fr_FR.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-04-10 14:47+0000\n" +"Last-Translator: Yves Le Doeuff \n" +"Language-Team: none\n" +"Language: fr_FR\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 4.3.2\n" + +#. module: account_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "Règle de stockage" + +#~ msgid "Display Name" +#~ msgstr "Nom affiché" + +#~ msgid "Last Modified on" +#~ msgstr "Dernière modification" diff --git a/account_payment_purchase_stock/i18n/it.po b/account_payment_purchase_stock/i18n/it.po new file mode 100644 index 000000000000..bf4905162de1 --- /dev/null +++ b/account_payment_purchase_stock/i18n/it.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_purchase_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-07 13:15+0000\n" +"Last-Translator: mymage \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 4.17\n" + +#. module: account_payment_purchase_stock +#: model:ir.model,name:account_payment_purchase_stock.model_stock_rule +msgid "Stock Rule" +msgstr "Regola di giacenza" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/account_payment_purchase_stock/models/__init__.py b/account_payment_purchase_stock/models/__init__.py new file mode 100644 index 000000000000..7d44ef73318e --- /dev/null +++ b/account_payment_purchase_stock/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import stock_rule diff --git a/account_payment_purchase_stock/models/stock_rule.py b/account_payment_purchase_stock/models/stock_rule.py new file mode 100644 index 000000000000..d03a3fc8a6e6 --- /dev/null +++ b/account_payment_purchase_stock/models/stock_rule.py @@ -0,0 +1,22 @@ +# Copyright 2015 Tecnativa - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + def _prepare_purchase_order(self, company_id, origins, values): + """Propagate payment mode on MTO/drop shipping.""" + res = super()._prepare_purchase_order(company_id, origins, values) + values = values[0] + partner = values["supplier"].partner_id + if partner: + res["payment_mode_id"] = partner.with_company( + self.company_id.id + ).supplier_payment_mode_id.id + res["supplier_partner_bank_id"] = self.env[ + "purchase.order" + ]._get_default_supplier_partner_bank(partner) + return res diff --git a/account_payment_purchase_stock/pyproject.toml b/account_payment_purchase_stock/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/account_payment_purchase_stock/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_payment_purchase_stock/readme/CONTRIBUTORS.md b/account_payment_purchase_stock/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..9d34ae947144 --- /dev/null +++ b/account_payment_purchase_stock/readme/CONTRIBUTORS.md @@ -0,0 +1,11 @@ +- Alexis de Lattre +- Alexandre Fayolle +- Danimar Ribeiro +- Raphaël Valyi +- Abraham Anes \<\> +- [Tecnativa](https://www.tecnativa.com): + - Pedro M. Baeza \<\> + - Vicent Cubells \<\> +- Nikul Chaudhary \<\> +- Miquel Raïch \<\> +- Andrea Stirpe \<\> diff --git a/account_payment_purchase_stock/readme/DESCRIPTION.md b/account_payment_purchase_stock/readme/DESCRIPTION.md new file mode 100644 index 000000000000..d8089c2f5b07 --- /dev/null +++ b/account_payment_purchase_stock/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module combines the *account_payment_purchase* module with +*purchase_stock*. diff --git a/account_payment_purchase_stock/readme/INSTALL.md b/account_payment_purchase_stock/readme/INSTALL.md new file mode 100644 index 000000000000..6aac06e8e147 --- /dev/null +++ b/account_payment_purchase_stock/readme/INSTALL.md @@ -0,0 +1,6 @@ +This module depends on : + +- purchase_stock +- account_payment_purchase + +This module is part of the OCA/bank-payment suite. diff --git a/account_payment_purchase_stock/readme/USAGE.md b/account_payment_purchase_stock/readme/USAGE.md new file mode 100644 index 000000000000..2e014d1c5931 --- /dev/null +++ b/account_payment_purchase_stock/readme/USAGE.md @@ -0,0 +1,2 @@ +This module doesn't add any feature, but it is used by several other +modules. diff --git a/account_payment_purchase_stock/static/description/icon.png b/account_payment_purchase_stock/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/account_payment_purchase_stock/static/description/icon.png differ diff --git a/account_payment_purchase_stock/static/description/index.html b/account_payment_purchase_stock/static/description/index.html new file mode 100644 index 000000000000..f1f6c1f9cdbe --- /dev/null +++ b/account_payment_purchase_stock/static/description/index.html @@ -0,0 +1,453 @@ + + + + + +Account Payment Purchase Stock + + + +
+

Account Payment Purchase Stock

+ + +

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runboat

+

This module combines the account_payment_purchase module with +purchase_stock.

+

Table of contents

+ +
+

Installation

+

This module depends on :

+
    +
  • purchase_stock
  • +
  • account_payment_purchase
  • +
+

This module is part of the OCA/bank-payment suite.

+
+
+

Usage

+

This module doesn’t add any feature, but it is used by several other +modules.

+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Tecnativa
  • +
+
+
+

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/bank-payment project on GitHub.

+

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

+
+
+
+ + diff --git a/account_payment_purchase_stock/tests/__init__.py b/account_payment_purchase_stock/tests/__init__.py new file mode 100644 index 000000000000..96311fcd9709 --- /dev/null +++ b/account_payment_purchase_stock/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import test_account_payment_purchase_stock diff --git a/account_payment_purchase_stock/tests/test_account_payment_purchase_stock.py b/account_payment_purchase_stock/tests/test_account_payment_purchase_stock.py new file mode 100644 index 000000000000..de03f378db17 --- /dev/null +++ b/account_payment_purchase_stock/tests/test_account_payment_purchase_stock.py @@ -0,0 +1,113 @@ +# Copyright 2013-2015 Tecnativa - Pedro M. Baeza +# Copyright 2017 Tecnativa - Vicent Cubells +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import fields + +from odoo.addons.account_payment_purchase.tests.test_account_payment_purchase import ( + TestAccountPaymentPurchase, +) + + +class TestAccountPaymentPurchaseStock(TestAccountPaymentPurchase): + def test_purchase_stock_order_invoicing(self): + self.purchase.onchange_partner_id() + self.purchase.button_confirm() + picking = self.purchase.picking_ids[0] + picking.action_confirm() + picking.button_validate() + + invoice = self.env["account.move"].create( + {"partner_id": self.partner.id, "move_type": "in_invoice"} + ) + invoice.purchase_id = self.purchase + invoice._onchange_purchase_auto_complete() + self.assertEqual( + self.purchase.invoice_ids[0].payment_mode_id, self.payment_mode + ) + + def test_picking_from_purchase_order_invoicing(self): + # Test payment mode + stockable_product = self.env["product.product"].create( + {"name": "Test stockable product", "type": "product"} + ) + self.purchase.order_line[0].product_id = stockable_product + self.purchase.button_confirm() + picking = self.purchase.picking_ids[0] + picking.action_confirm() + picking.button_validate() + + invoice = self.env["account.move"].create( + {"partner_id": self.partner.id, "move_type": "in_invoice"} + ) + invoice.purchase_id = self.purchase + invoice._onchange_purchase_auto_complete() + self.assertEqual(invoice.payment_mode_id, self.payment_mode) + purchase2 = self.purchase.copy() + payment_mode2 = self.payment_mode.copy() + purchase2.payment_mode_id = payment_mode2 + purchase2.button_confirm() + picking = purchase2.picking_ids[0] + picking.action_confirm() + picking.button_validate() + invoice.purchase_id = purchase2 + result = invoice._onchange_purchase_auto_complete() + self.assertEqual( + result and result.get("warning", {}).get("title", False), "Warning" + ) + + def test_picking_from_purchase_order_invoicing_bank(self): + # Test partner_bank + stockable_product = self.env["product.product"].create( + {"name": "Test stockable product", "type": "product"} + ) + self.purchase.order_line[0].product_id = stockable_product + self.purchase.supplier_partner_bank_id = self.bank + self.purchase.button_confirm() + picking = self.purchase.picking_ids[0] + picking.action_confirm() + picking.button_validate() + + invoice = self.env["account.move"].create( + {"partner_id": self.partner.id, "move_type": "in_invoice"} + ) + invoice.purchase_id = self.purchase + invoice._onchange_purchase_auto_complete() + self.assertEqual(invoice.partner_bank_id, self.bank) + purchase2 = self.purchase.copy() + purchase2.supplier_partner_bank_id = self.bank2 + purchase2.button_confirm() + picking = purchase2.picking_ids[0] + picking.action_confirm() + picking.button_validate() + invoice.purchase_id = purchase2 + result = invoice._onchange_purchase_auto_complete() + self.assertEqual( + result and result.get("warning", {}).get("title", False), "Warning" + ) + + def test_stock_rule_buy_payment_mode(self): + route = self.env.ref("purchase_stock.route_warehouse0_buy") + rule = self.env["stock.rule"].search([("route_id", "=", route.id)], limit=1) + rule._run_buy( + procurements=[ + ( + self.env["procurement.group"].Procurement( + self.mto_product, + 1, + self.mto_product.uom_id, + self.env["stock.location"].search([], limit=1), + "Procurement order test", + "Test", + rule.company_id, + { + "company_id": rule.company_id, + "date_planned": fields.Datetime.now(), + }, + ), + rule, + ) + ] + ) + purchase = self.env["purchase.order"].search([("origin", "=", "Test")]) + self.assertEqual(purchase.payment_mode_id, self.payment_mode)