mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_purchase: Migration to 16.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Purchase",
|
||||
"version": "15.0.1.0.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"category": "Banking addons",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Adds Bank Account and Payment Mode on Purchase Orders",
|
||||
|
||||
@@ -25,11 +25,15 @@ class PurchaseOrder(models.Model):
|
||||
@api.model
|
||||
def _get_default_supplier_partner_bank(self, partner):
|
||||
"""This function is designed to be inherited"""
|
||||
return partner.bank_ids and partner.bank_ids[0].id or False
|
||||
return (
|
||||
partner.bank_ids
|
||||
and partner.bank_ids.sorted(lambda bank: not bank.allow_out_payment)[0].id
|
||||
or False
|
||||
)
|
||||
|
||||
@api.onchange("partner_id", "company_id")
|
||||
def onchange_partner_id(self):
|
||||
ret = super(PurchaseOrder, self).onchange_partner_id()
|
||||
ret = super().onchange_partner_id()
|
||||
if self.partner_id:
|
||||
self.supplier_partner_bank_id = self._get_default_supplier_partner_bank(
|
||||
self.partner_id
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import Form, TransactionCase, tagged
|
||||
from odoo.tests import TransactionCase, tagged
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install")
|
||||
class TestAccountPaymentPurchase(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAccountPaymentPurchase, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
cls.journal = cls.env["account.journal"].create(
|
||||
{"name": "Test journal", "code": "TEST", "type": "general"}
|
||||
)
|
||||
@@ -49,7 +50,7 @@ class TestAccountPaymentPurchase(TransactionCase):
|
||||
"name": "Test buy product",
|
||||
"uom_id": cls.uom_id,
|
||||
"uom_po_id": cls.uom_id,
|
||||
"seller_ids": [(0, 0, {"name": cls.partner.id})],
|
||||
"seller_ids": [(0, 0, {"partner_id": cls.partner.id})],
|
||||
}
|
||||
)
|
||||
cls.purchase = cls.env["purchase.order"].create(
|
||||
@@ -84,8 +85,8 @@ class TestAccountPaymentPurchase(TransactionCase):
|
||||
invoice = self.env["account.move"].create(
|
||||
{"partner_id": self.partner.id, "move_type": "in_invoice"}
|
||||
)
|
||||
with Form(invoice) as inv:
|
||||
inv.purchase_id = self.purchase
|
||||
invoice.purchase_id = self.purchase
|
||||
invoice._onchange_purchase_auto_complete()
|
||||
self.assertEqual(
|
||||
self.purchase.invoice_ids[0].payment_mode_id, self.payment_mode
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user