From 688248484ee140322b03dbaf44a791bb40b2cecd Mon Sep 17 00:00:00 2001 From: Nikul-Chaudhary Date: Sat, 19 Jan 2019 16:55:49 +0530 Subject: [PATCH] [MIG] account_payment_purchase v11 to v12 --- account_payment_purchase/README.rst | 2 + account_payment_purchase/__manifest__.py | 6 +-- account_payment_purchase/models/__init__.py | 3 +- .../{procurement_rule.py => stock_rule.py} | 6 +-- .../readme/CONTRIBUTORS.rst | 2 + account_payment_purchase/tests/__init__.py | 1 - .../tests/test_account_payment_purchase.py | 42 ++++++++++--------- 7 files changed, 34 insertions(+), 28 deletions(-) rename account_payment_purchase/models/{procurement_rule.py => stock_rule.py} (84%) diff --git a/account_payment_purchase/README.rst b/account_payment_purchase/README.rst index 140059f7a..5d4c8f2ba 100644 --- a/account_payment_purchase/README.rst +++ b/account_payment_purchase/README.rst @@ -95,6 +95,8 @@ Contributors * Pedro M. Baeza * Vicent Cubells +* Nikul Chaudhary + Maintainers ~~~~~~~~~~~ diff --git a/account_payment_purchase/__manifest__.py b/account_payment_purchase/__manifest__.py index 0cb237613..83e6bd9a5 100644 --- a/account_payment_purchase/__manifest__.py +++ b/account_payment_purchase/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Account Payment Purchase', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': "Adds Bank Account and Payment Mode on Purchase Orders", @@ -13,8 +13,8 @@ "Odoo Community Association (OCA)", 'website': 'https://github.com/OCA/bank-payment', 'depends': [ - 'purchase', - 'account_payment_partner' + 'account_payment_partner', + 'purchase_stock', ], 'data': [ 'views/purchase_order_view.xml', diff --git a/account_payment_purchase/models/__init__.py b/account_payment_purchase/models/__init__.py index 8c3bb2f57..5488e5828 100644 --- a/account_payment_purchase/models/__init__.py +++ b/account_payment_purchase/models/__init__.py @@ -1,6 +1,5 @@ -# Copyright 2016 Akretion (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import account_invoice from . import purchase_order -from . import procurement_rule +from . import stock_rule diff --git a/account_payment_purchase/models/procurement_rule.py b/account_payment_purchase/models/stock_rule.py similarity index 84% rename from account_payment_purchase/models/procurement_rule.py rename to account_payment_purchase/models/stock_rule.py index a94adf3d4..07701cd09 100644 --- a/account_payment_purchase/models/procurement_rule.py +++ b/account_payment_purchase/models/stock_rule.py @@ -4,13 +4,13 @@ from odoo import models -class ProcurementRule(models.Model): - _inherit = "procurement.rule" +class StockRule(models.Model): + _inherit = "stock.rule" def _prepare_purchase_order(self, product_id, product_qty, product_uom, origin, values, partner): """Propagate payment mode on MTO/drop shipping.""" - values = super(ProcurementRule, self)._prepare_purchase_order( + values = super(StockRule, self)._prepare_purchase_order( product_id, product_qty, product_uom, origin, values, partner) if partner: values['payment_mode_id'] = partner.with_context( diff --git a/account_payment_purchase/readme/CONTRIBUTORS.rst b/account_payment_purchase/readme/CONTRIBUTORS.rst index a4a055436..5121c0e9a 100644 --- a/account_payment_purchase/readme/CONTRIBUTORS.rst +++ b/account_payment_purchase/readme/CONTRIBUTORS.rst @@ -7,3 +7,5 @@ * Pedro M. Baeza * Vicent Cubells + +* Nikul Chaudhary diff --git a/account_payment_purchase/tests/__init__.py b/account_payment_purchase/tests/__init__.py index 172df56fa..578d2d96b 100644 --- a/account_payment_purchase/tests/__init__.py +++ b/account_payment_purchase/tests/__init__.py @@ -1,4 +1,3 @@ -# Copyright 2013-2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import test_account_payment_purchase diff --git a/account_payment_purchase/tests/test_account_payment_purchase.py b/account_payment_purchase/tests/test_account_payment_purchase.py index 2f28e48c4..8939c48aa 100644 --- a/account_payment_purchase/tests/test_account_payment_purchase.py +++ b/account_payment_purchase/tests/test_account_payment_purchase.py @@ -10,12 +10,6 @@ class TestAccountPaymentPurchase(common.SavepointCase): @classmethod def setUpClass(cls): super(TestAccountPaymentPurchase, cls).setUpClass() - cls.bank = cls.env['res.partner.bank'].create( - {'bank_name': 'Test bank', - 'acc_number': '1234567890'}) - cls.bank2 = cls.env['res.partner.bank'].create( - {'bank_name': 'Test bank #2', - 'acc_number': '0123456789'}) cls.journal = cls.env['account.journal'].create( {'name': 'Test journal', 'code': 'TEST', @@ -29,7 +23,17 @@ class TestAccountPaymentPurchase(common.SavepointCase): cls.partner = cls.env['res.partner'].create( {'name': 'Test partner', 'supplier_payment_mode_id': cls.payment_mode.id}) - cls.uom_id = cls.env.ref('product.product_uom_unit').id + cls.bank = cls.env['res.partner.bank'].create( + {'bank_name': 'Test bank', + 'acc_number': '1234567890', + 'partner_id': cls.partner.id, + }) + cls.bank2 = cls.env['res.partner.bank'].create( + {'bank_name': 'Test bank #2', + 'acc_number': '0123456789', + 'partner_id': cls.partner.id, + }) + cls.uom_id = cls.env.ref('uom.product_uom_unit').id cls.mto_product = cls.env['product.product'].create( {'name': 'Test buy product', 'type': 'product', @@ -53,9 +57,9 @@ class TestAccountPaymentPurchase(common.SavepointCase): def test_purchase_order_invoicing(self): self.purchase.button_confirm() picking = self.purchase.picking_ids[0] - picking.force_assign() + picking.action_confirm() picking.move_lines.write({'quantity_done': 1.0}) - picking.do_transfer() + picking.button_validate() invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, @@ -74,9 +78,9 @@ class TestAccountPaymentPurchase(common.SavepointCase): self.purchase.order_line[0].product_id = stockable_product.id self.purchase.button_confirm() picking = self.purchase.picking_ids[0] - picking.force_assign() + picking.action_confirm() picking.move_lines.write({'quantity_done': 1.0}) - picking.do_transfer() + picking.button_validate() invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, @@ -90,9 +94,9 @@ class TestAccountPaymentPurchase(common.SavepointCase): purchase2.payment_mode_id = payment_mode2.id purchase2.button_confirm() picking = purchase2.picking_ids[0] - picking.force_assign() + picking.action_confirm() picking.move_lines.write({'quantity_done': 1.0}) - picking.do_transfer() + picking.button_validate() invoice.purchase_id = purchase2.id result = invoice.purchase_order_change() self.assertEqual(result['warning']['title'], 'Warning') @@ -107,9 +111,9 @@ class TestAccountPaymentPurchase(common.SavepointCase): self.purchase.supplier_partner_bank_id = self.bank.id self.purchase.button_confirm() picking = self.purchase.picking_ids[0] - picking.force_assign() + picking.action_confirm() picking.move_lines.write({'quantity_done': 1.0}) - picking.do_transfer() + picking.button_validate() invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, @@ -124,16 +128,16 @@ class TestAccountPaymentPurchase(common.SavepointCase): purchase2.supplier_partner_bank_id = self.bank2.id purchase2.button_confirm() picking = purchase2.picking_ids[0] - picking.force_assign() + picking.action_confirm() picking.move_lines.write({'quantity_done': 1.0}) - picking.do_transfer() + picking.button_validate() invoice.purchase_id = purchase2.id result = invoice.purchase_order_change() self.assertEqual(result['warning']['title'], 'Warning') def test_procurement_buy_payment_mode(self): - route = self.env.ref('purchase.route_warehouse0_buy') - rule = self.env['procurement.rule'].search( + route = self.env.ref('purchase_stock.route_warehouse0_buy') + rule = self.env['stock.rule'].search( [('route_id', '=', route.id)], limit=1) rule._run_buy( product_id=self.mto_product,