[FIX] account: keep statement line note

We keep the statement line note when changing
the partner in reconciliation widget

Steps:

- Create a Bank Statement, a Bank Statement
  Line BSL with a note (field narration)
- Save, edit, change partner on statement
  line and save.
-> The note on BSL is empty

With this commit we allow narration computation
only for sale documents.

opw-2832287

closes odoo/odoo#97125

X-original-commit: 19394d1971259933c5158139c56344c9c35bdaed
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Guillaume Vanleynseele (guva) <guva@odoo.com>
This commit is contained in:
Guillaume (guva)
2022-08-01 10:55:47 +02:00
parent fc2118f5c3
commit 63d44ffd35
2 changed files with 30 additions and 1 deletions
+3 -1
View File
@@ -3515,7 +3515,9 @@ class AccountMove(models.Model):
def _compute_narration(self):
use_invoice_terms = self.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms')
for move in self:
if not use_invoice_terms or not move.is_sale_document(include_receipts=True):
if not move.is_sale_document(include_receipts=True):
continue
if not use_invoice_terms:
move.narration = False
else:
lang = move.partner_id.lang or self.env.user.lang
@@ -927,3 +927,30 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
statement_line = statement.line_ids
self.assertRecordValues(statement_line, [{'is_reconciled': True, 'amount_residual': 0.0}])
def test_statement_line_note_onchange_partner(self):
"""
Check if narration field stays as it is when changing the partner
in reconciliation widget.
"""
bank_stmt = self.env['account.bank.statement'].create({
'company_id': self.env.company.id,
'journal_id': self.bank_journal_1.id,
'name': 'test',
})
bank_stmt_line = self.env['account.bank.statement.line'].create({
'payment_ref': 'testLine',
'statement_id': bank_stmt.id,
'narration': 'This is a note',
'amount': 100,
})
bank_stmt_line.partner_id = self.partner_b
self.assertRecordValues(bank_stmt_line, [{
'payment_ref': 'testLine',
'statement_id': bank_stmt.id,
'narration': '<p>This is a note</p>',
'amount': 100,
}])