diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py
index 290885bd8..02ddb6a65 100644
--- a/account_payment_order/__manifest__.py
+++ b/account_payment_order/__manifest__.py
@@ -8,7 +8,7 @@
{
"name": "Account Payment Order",
- "version": "13.0.1.1.0",
+ "version": "13.0.1.3.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, "
"Therp BV, "
diff --git a/account_payment_order/models/account_move_line.py b/account_payment_order/models/account_move_line.py
index e444ba2f7..2326d9bfe 100644
--- a/account_payment_order/models/account_move_line.py
+++ b/account_payment_order/models/account_move_line.py
@@ -2,7 +2,7 @@
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import fields, models
+from odoo import api, fields, models
from odoo.fields import first
@@ -12,6 +12,9 @@ class AccountMoveLine(models.Model):
partner_bank_id = fields.Many2one(
comodel_name="res.partner.bank",
string="Partner Bank Account",
+ compute="_compute_partner_bank_id",
+ readonly=False,
+ store=True,
help="Bank account on which we should pay the supplier",
)
bank_payment_line_id = fields.Many2one(
@@ -23,6 +26,23 @@ class AccountMoveLine(models.Model):
string="Payment lines",
)
+ @api.depends(
+ "move_id", "move_id.invoice_partner_bank_id", "move_id.payment_mode_id"
+ )
+ def _compute_partner_bank_id(self):
+ for ml in self:
+ if (
+ ml.move_id.type in ("in_invoice", "in_refund")
+ and not ml.reconciled
+ and ml.payment_mode_id.payment_order_ok
+ and ml.account_id.internal_type in ("receivable", "payable")
+ and not any(
+ p_state in ("draft", "open", "generated")
+ for p_state in ml.payment_line_ids.mapped("state")
+ )
+ ):
+ ml.partner_bank_id = ml.move_id.invoice_partner_bank_id.id
+
def _prepare_payment_line_vals(self, payment_order):
self.ensure_one()
assert payment_order, "Missing payment order"
diff --git a/account_payment_order/views/account_invoice_view.xml b/account_payment_order/views/account_invoice_view.xml
index 304497198..8a32eff9d 100644
--- a/account_payment_order/views/account_invoice_view.xml
+++ b/account_payment_order/views/account_invoice_view.xml
@@ -57,7 +57,6 @@
name="Add to Payment/Debit Order"
res_model="account.invoice.payment.line.multi"
binding_model="account.move"
- binding_views="form"
view_mode="form"
target="new"
id="account_invoice_create_account_payment_line_action"
diff --git a/account_payment_order/views/ir_attachment.xml b/account_payment_order/views/ir_attachment.xml
index 6fbc9c790..d5e2806a5 100644
--- a/account_payment_order/views/ir_attachment.xml
+++ b/account_payment_order/views/ir_attachment.xml
@@ -13,12 +13,7 @@
-
-
+