diff --git a/account_payment_purchase/README.rst b/account_payment_purchase/README.rst index 869dfefc6..1075b636c 100644 --- a/account_payment_purchase/README.rst +++ b/account_payment_purchase/README.rst @@ -44,7 +44,7 @@ Installation This module depends on : -- purchase_stock +- purchase - account_payment_partner This module is part of the OCA/bank-payment suite. @@ -97,6 +97,7 @@ Contributors * Nikul Chaudhary * Miquel Raïch +* Andrea Stirpe Maintainers ~~~~~~~~~~~ diff --git a/account_payment_purchase/__init__.py b/account_payment_purchase/__init__.py index af735bf88..83e553ac4 100644 --- a/account_payment_purchase/__init__.py +++ b/account_payment_purchase/__init__.py @@ -1,4 +1,3 @@ -# Copyright 2016 Akretion (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/account_payment_purchase/__manifest__.py b/account_payment_purchase/__manifest__.py index ce4a618ba..090741a04 100644 --- a/account_payment_purchase/__manifest__.py +++ b/account_payment_purchase/__manifest__.py @@ -10,7 +10,7 @@ "summary": "Adds Bank Account and Payment Mode on Purchase Orders", "author": "Akretion, Tecnativa, Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-payment", - "depends": ["account_payment_partner", "purchase_stock"], + "depends": ["account_payment_partner", "purchase"], "data": ["views/purchase_order_view.xml"], "installable": True, "auto_install": True, diff --git a/account_payment_purchase/models/__init__.py b/account_payment_purchase/models/__init__.py index 4a3b74aaf..fbd9ff8ae 100644 --- a/account_payment_purchase/models/__init__.py +++ b/account_payment_purchase/models/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import account_invoice, purchase_order, stock_rule +from . import account_invoice, purchase_order diff --git a/account_payment_purchase/readme/CONTRIBUTORS.rst b/account_payment_purchase/readme/CONTRIBUTORS.rst index 3a09c62d4..2cecd6336 100644 --- a/account_payment_purchase/readme/CONTRIBUTORS.rst +++ b/account_payment_purchase/readme/CONTRIBUTORS.rst @@ -10,3 +10,4 @@ * Nikul Chaudhary * Miquel Raïch +* Andrea Stirpe diff --git a/account_payment_purchase/readme/INSTALL.rst b/account_payment_purchase/readme/INSTALL.rst index c1b712414..09b853841 100644 --- a/account_payment_purchase/readme/INSTALL.rst +++ b/account_payment_purchase/readme/INSTALL.rst @@ -1,6 +1,6 @@ This module depends on : -- purchase_stock +- purchase - account_payment_partner This module is part of the OCA/bank-payment suite. diff --git a/account_payment_purchase/static/description/index.html b/account_payment_purchase/static/description/index.html index 10310f191..fd81d2242 100644 --- a/account_payment_purchase/static/description/index.html +++ b/account_payment_purchase/static/description/index.html @@ -393,7 +393,7 @@ modules in the banking addons conflict with account_payment_extension).

Installation

This module depends on :

    -
  • purchase_stock
  • +
  • purchase
  • account_payment_partner

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

@@ -441,6 +441,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Nikul Chaudhary <nikulchaudhary2112@gmail.com>
  • Miquel Raïch <miquel.raich@forgeflow.com>
  • +
  • Andrea Stirpe <a.stirpe@onestein.nl>
  • diff --git a/account_payment_purchase/tests/test_account_payment_purchase.py b/account_payment_purchase/tests/test_account_payment_purchase.py index f882e5111..46d0f57b9 100644 --- a/account_payment_purchase/tests/test_account_payment_purchase.py +++ b/account_payment_purchase/tests/test_account_payment_purchase.py @@ -44,7 +44,6 @@ class TestAccountPaymentPurchase(SavepointCase): cls.mto_product = cls.env["product.product"].create( { "name": "Test buy product", - "type": "product", "uom_id": cls.uom_id, "uom_po_id": cls.uom_id, "seller_ids": [(0, 0, {"name": cls.partner.id})], @@ -77,10 +76,6 @@ class TestAccountPaymentPurchase(SavepointCase): def test_purchase_order_invoicing(self): self.purchase.button_confirm() - picking = self.purchase.picking_ids[0] - picking.action_confirm() - picking.move_lines.write({"quantity_done": 1.0}) - picking.button_validate() invoice = self.env["account.move"].create( {"partner_id": self.partner.id, "type": "in_invoice"} @@ -91,17 +86,11 @@ class TestAccountPaymentPurchase(SavepointCase): self.purchase.invoice_ids[0].payment_mode_id, self.payment_mode ) - def test_picking_from_purchase_order_invoicing(self): + def test_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 + product = self.env["product.product"].create({"name": "Test product"}) + self.purchase.order_line[0].product_id = product self.purchase.button_confirm() - picking = self.purchase.picking_ids[0] - picking.action_confirm() - picking.move_lines.write({"quantity_done": 1.0}) - picking.button_validate() invoice = self.env["account.move"].create( {"partner_id": self.partner.id, "type": "in_invoice"} @@ -113,29 +102,20 @@ class TestAccountPaymentPurchase(SavepointCase): payment_mode2 = self.payment_mode.copy() purchase2.payment_mode_id = payment_mode2 purchase2.button_confirm() - picking = purchase2.picking_ids[0] - picking.action_confirm() - picking.move_lines.write({"quantity_done": 1.0}) - 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): + def test_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 + product = self.env["product.product"].create({"name": "Test product"}) + self.purchase.order_line[0].product_id = product self.purchase.payment_mode_id = False self.purchase.supplier_partner_bank_id = self.bank self.purchase.button_confirm() - picking = self.purchase.picking_ids[0] - picking.action_confirm() - picking.move_lines.write({"quantity_done": 1.0}) - picking.button_validate() invoice = self.env["account.move"].create( {"partner_id": self.partner.id, "type": "in_invoice"} @@ -146,38 +126,9 @@ class TestAccountPaymentPurchase(SavepointCase): purchase2 = self.purchase.copy() purchase2.supplier_partner_bank_id = self.bank2 purchase2.button_confirm() - picking = purchase2.picking_ids[0] - picking.action_confirm() - picking.move_lines.write({"quantity_done": 1.0}) - 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_procurement_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) diff --git a/account_payment_purchase_stock/README.rst b/account_payment_purchase_stock/README.rst new file mode 100644 index 000000000..a85ab0df4 --- /dev/null +++ b/account_payment_purchase_stock/README.rst @@ -0,0 +1,101 @@ +============================== +Account Payment Purchase Stock +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-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/13.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-13-/bank-payment-13--account_payment_purchase_stock + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/97/13.0 + :alt: Try me on Runbot + +|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 smashing 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 000000000..83e553ac4 --- /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 000000000..bb38d439d --- /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": "13.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/models/__init__.py b/account_payment_purchase_stock/models/__init__.py new file mode 100644 index 000000000..7d44ef733 --- /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/models/stock_rule.py b/account_payment_purchase_stock/models/stock_rule.py similarity index 86% rename from account_payment_purchase/models/stock_rule.py rename to account_payment_purchase_stock/models/stock_rule.py index 51ef93038..17ccc5581 100644 --- a/account_payment_purchase/models/stock_rule.py +++ b/account_payment_purchase_stock/models/stock_rule.py @@ -9,9 +9,7 @@ class StockRule(models.Model): def _prepare_purchase_order(self, company_id, origins, values): """Propagate payment mode on MTO/drop shipping.""" - res = super(StockRule, self)._prepare_purchase_order( - company_id, origins, values - ) + res = super()._prepare_purchase_order(company_id, origins, values) values = values[0] partner = values["supplier"].name if partner: diff --git a/account_payment_purchase_stock/readme/CONTRIBUTORS.rst b/account_payment_purchase_stock/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..2cecd6336 --- /dev/null +++ b/account_payment_purchase_stock/readme/CONTRIBUTORS.rst @@ -0,0 +1,13 @@ +* 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 diff --git a/account_payment_purchase_stock/readme/DESCRIPTION.rst b/account_payment_purchase_stock/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e2f5e2891 --- /dev/null +++ b/account_payment_purchase_stock/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module combines the *account_payment_purchase* module with *purchase_stock*. diff --git a/account_payment_purchase_stock/readme/INSTALL.rst b/account_payment_purchase_stock/readme/INSTALL.rst new file mode 100644 index 000000000..6aac06e8e --- /dev/null +++ b/account_payment_purchase_stock/readme/INSTALL.rst @@ -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.rst b/account_payment_purchase_stock/readme/USAGE.rst new file mode 100644 index 000000000..de3e7fa6b --- /dev/null +++ b/account_payment_purchase_stock/readme/USAGE.rst @@ -0,0 +1 @@ +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 000000000..3a0328b51 Binary files /dev/null and b/account_payment_purchase_stock/static/description/icon.png differ diff --git a/account_payment_purchase_stock/tests/__init__.py b/account_payment_purchase_stock/tests/__init__.py new file mode 100644 index 000000000..96311fcd9 --- /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 000000000..a6599ba4a --- /dev/null +++ b/account_payment_purchase_stock/tests/test_account_payment_purchase_stock.py @@ -0,0 +1,119 @@ +# 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.tests import Form + +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.button_confirm() + picking = self.purchase.picking_ids[0] + picking.action_confirm() + picking.move_lines.write({"quantity_done": 1.0}) + picking.button_validate() + + invoice = self.env["account.move"].create( + {"partner_id": self.partner.id, "type": "in_invoice"} + ) + with Form(invoice) as inv: + inv.purchase_id = self.purchase + 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.move_lines.write({"quantity_done": 1.0}) + picking.button_validate() + + invoice = self.env["account.move"].create( + {"partner_id": self.partner.id, "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.move_lines.write({"quantity_done": 1.0}) + 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.payment_mode_id = False + self.purchase.supplier_partner_bank_id = self.bank + self.purchase.button_confirm() + picking = self.purchase.picking_ids[0] + picking.action_confirm() + picking.move_lines.write({"quantity_done": 1.0}) + picking.button_validate() + + invoice = self.env["account.move"].create( + {"partner_id": self.partner.id, "type": "in_invoice"} + ) + invoice.purchase_id = self.purchase + invoice._onchange_purchase_auto_complete() + self.assertEqual(invoice.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.move_lines.write({"quantity_done": 1.0}) + 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)