account: Keep partner_id from counterpart_vals if existing

In case an open balance needs to be created on a receivable or
payable account after reconciliation, but no partner was defined
on the statement line, we want to keep the partner from the
counterpart values that was identified through reference matching.

closes odoo/odoo#86752

X-original-commit: 8c4d6d362c096e9dc67562ecd7bad0ce08bc6697
Signed-off-by: Florian Gilbert <flg@odoo.com>
This commit is contained in:
Akim Juillerat
2022-03-21 14:01:17 +01:00
parent 8629eccb96
commit 25fa0a3833
@@ -716,7 +716,7 @@ class AccountBankStatementLine(models.Model):
**counterpart_vals,
'name': counterpart_vals.get('name', move_line.name if move_line else ''),
'move_id': self.move_id.id,
'partner_id': self.partner_id.id or (move_line.partner_id.id if move_line else False),
'partner_id': self.partner_id.id or counterpart_vals.get('partner_id', move_line.partner_id.id if move_line else False),
'currency_id': currency_id,
'account_id': counterpart_vals.get('account_id', move_line.account_id.id if move_line else False),
'debit': balance if balance > 0.0 else 0.0,