[IMP] account_payment_order: Select first partner bank

This commit is contained in:
Carlos Dauden
2019-09-10 18:30:19 +02:00
committed by Carlos Roca
parent 183efec307
commit 22390eded5
2 changed files with 5 additions and 9 deletions

View File

@@ -8,7 +8,7 @@
{
'name': 'Account Payment Order',
'version': '12.0.1.0.1',
'version': '12.0.1.0.2',
'license': 'AGPL-3',
'author': "ACSONE SA/NV, "
"Therp BV, "

View File

@@ -3,7 +3,8 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from lxml import etree
from odoo import models, fields, api
from odoo import api, fields, models
from odoo.fields import first
from odoo.osv import orm
@@ -58,13 +59,8 @@ class AccountMoveLine(models.Model):
# in this case
if payment_order.payment_type == 'outbound':
amount_currency *= -1
partner_bank_id = False
if not self.partner_bank_id:
# Select partner bank account automatically if there is only one
if len(self.partner_id.bank_ids) == 1:
partner_bank_id = self.partner_id.bank_ids[0].id
else:
partner_bank_id = self.partner_bank_id.id
partner_bank_id = self.partner_bank_id.id or first(
self.partner_id.bank_ids).id
vals = {
'order_id': payment_order.id,
'partner_bank_id': partner_bank_id,