[MIG] account_payment_purchase v11 to v12

This commit is contained in:
Nikul-Chaudhary
2019-01-19 16:55:49 +05:30
committed by mreficent
parent 23ef4a85a1
commit 688248484e
7 changed files with 34 additions and 28 deletions

View File

@@ -95,6 +95,8 @@ Contributors
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
Maintainers
~~~~~~~~~~~

View File

@@ -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',

View File

@@ -1,6 +1,5 @@
# Copyright 2016 Akretion (<http://www.akretion.com>).
# 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

View File

@@ -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(

View File

@@ -7,3 +7,5 @@
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>

View File

@@ -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

View File

@@ -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,