Skip to content

Commit 6b909e0

Browse files
committed
[FIX] account_payment_pro: include to_pay_move_line_ids in _compute_to_pay_amount dependency
1 parent 0559ab7 commit 6b909e0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

account_payment_pro/models/account_payment.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,13 @@ def _inverse_to_pay_amount(self):
565565
):
566566
rec.unreconciled_amount = rec.to_pay_amount - rec.selected_debt
567567

568+
@api.onchange("to_pay_move_line_ids")
569+
def _onchange_to_pay_move_line_ids(self):
570+
"""Evitar que se recompute automáticamente cuando el usuario edita manualmente
571+
el campo many2many desde la UI"""
572+
for rec in self.filtered(lambda x: x.partner_id and x.state == "draft"):
573+
rec.to_pay_move_line_ids = rec.to_pay_move_line_ids.filtered("partner_id")
574+
568575
# We dont set 'is_internal_transfer' as a dependencies as it could leed to recompute to_pay_move_line_ids
569576
@api.depends("partner_id", "partner_type", "company_id")
570577
def _compute_to_pay_move_lines(self):
@@ -598,6 +605,7 @@ def _get_filter_payments(self, records, extra_fields):
598605

599606
def _get_to_pay_move_lines_domain(self):
600607
self.ensure_one()
608+
601609
domain = [
602610
("partner_id", "=", self.partner_id.commercial_partner_id.id),
603611
("company_id", "=", self.company_id.id),
@@ -611,7 +619,7 @@ def _get_to_pay_move_lines_domain(self):
611619
"asset_receivable" if self.partner_type == "customer" else "liability_payable",
612620
),
613621
]
614-
# TODO revisar bien estos, no debería ser necesario, ver el blame porque se agrego lo del active_ids
622+
# Solo agregar active_ids si estamos en contexto de seleccionar líneas específicas
615623
if self.env.context.get("active_ids") and self.env.context.get("active_model") == "account.move.line":
616624
domain.append(("move_id.line_ids", "in", self.env.context.get("active_ids")))
617625
return domain
@@ -628,6 +636,7 @@ def action_add_all(self):
628636

629637
def remove_all(self):
630638
self.to_pay_move_line_ids = False
639+
self.to_pay_amount = 0.0
631640

632641
@api.constrains("partner_id", "to_pay_move_line_ids")
633642
def check_to_pay_lines(self):

0 commit comments

Comments
 (0)