37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import models
|
|
|
|
|
|
class BankRecWidget(models.Model):
|
|
_inherit = "bank.rec.widget"
|
|
|
|
def _line_value_changed_ref(self, line):
|
|
"""
|
|
Persist the typed Reference as both:
|
|
- Journal Entry Reference (move.ref) so it shows on journal items
|
|
- Statement Line Reference (st_line.ref) so it remains visible after validation
|
|
Works for liquidity and non-liquidity lines in Manual Operations.
|
|
"""
|
|
self.ensure_one()
|
|
ref_val = line.ref or False
|
|
# Persist to the move (journal entry)
|
|
self.st_line_id.move_id.ref = ref_val
|
|
# Persist to the statement line so the OWL form keeps showing it after validation
|
|
# (bank_rec_form.xml shows Reference for liquidity based on line.data.ref which maps to st_line.ref)
|
|
self.st_line_id.ref = ref_val
|
|
# Reload liquidity line and the record to reflect the updated reference
|
|
self._action_reload_liquidity_line()
|
|
self.return_todo_command = {"reset_record": True, "reset_global_info": True}
|
|
|
|
def _action_validate(self):
|
|
"""
|
|
Ensure the typed Reference is flushed to the target move before reconciliation creates/replaces lines.
|
|
This covers the case when the user clicks Validate immediately after typing in Manual Operations.
|
|
"""
|
|
self.ensure_one()
|
|
line = self._lines_get_line_in_edit_form()
|
|
if line and getattr(line, "ref", False):
|
|
ref_val = line.ref
|
|
self.st_line_id.move_id.ref = ref_val
|
|
self.st_line_id.ref = ref_val
|
|
return super()._action_validate() |