[FIX] account: Set memo to ref if not payment_reference
Issue - Install "Accounting" module - Create a new bill : - Set vendor - Set no payment reference - Set a bill reference - Add products to bill - Confirm and click on Register Payment Memo field has no value. Cause The memo field is based on lines name. Lines name is computed in `_onchange_payment_reference` and depends only on payment_referecence. Solution If no `payment_reference`, fallback on `ref` to set line name. opw-2440389 closes odoo/odoo#66491 Co-author: nboulif <bon@odoo.com> X-original-commit: 7a7dc212af7279544cffba362bce7daa4fc00865 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
@@ -466,7 +466,7 @@ class AccountMove(models.Model):
|
||||
@api.onchange('payment_reference', 'ref')
|
||||
def _onchange_payment_reference(self):
|
||||
for line in self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')):
|
||||
line.name = self.payment_reference or self.ref
|
||||
line.name = self.payment_reference or self.ref or ''
|
||||
|
||||
@api.onchange('invoice_vendor_bill_id')
|
||||
def _onchange_invoice_vendor_bill(self):
|
||||
@@ -970,7 +970,7 @@ class AccountMove(models.Model):
|
||||
# Create new line.
|
||||
create_method = in_draft_mode and self.env['account.move.line'].new or self.env['account.move.line'].create
|
||||
candidate = create_method({
|
||||
'name': self.payment_reference or '',
|
||||
'name': self.payment_reference or self.ref or '',
|
||||
'debit': balance < 0.0 and -balance or 0.0,
|
||||
'credit': balance > 0.0 and balance or 0.0,
|
||||
'quantity': 1.0,
|
||||
|
||||
@@ -1761,3 +1761,23 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
|
||||
{'amount_currency': 96.0, 'debit': 48.0, 'credit': 0.0, 'account_id': self.product_line_vals_2['account_id'], 'reconciled': False},
|
||||
{'amount_currency': -96.0, 'debit': 0.0, 'credit': 48.0, 'account_id': wizard.expense_accrual_account.id, 'reconciled': True},
|
||||
])
|
||||
|
||||
def test_in_invoice_payment_reference(self):
|
||||
''' Test the 'name' of the payable line fallbacks on the move's ref if the payment ref is empty. '''
|
||||
ref = 'VENDORBILL123456'
|
||||
with Form(self.invoice) as move_form:
|
||||
move_form.ref = ref
|
||||
|
||||
self.assertInvoiceValues(self.invoice, [
|
||||
self.product_line_vals_1,
|
||||
self.product_line_vals_2,
|
||||
self.tax_line_vals_1,
|
||||
self.tax_line_vals_2,
|
||||
{
|
||||
**self.term_line_vals_1,
|
||||
'name': ref,
|
||||
},
|
||||
], {
|
||||
**self.move_vals,
|
||||
'ref': ref,
|
||||
})
|
||||
|
||||
@@ -211,7 +211,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
self.rule_1.match_text_location_note = False
|
||||
self._check_statement_matching(self.rule_1, {
|
||||
self.bank_line_3.id: {'aml_ids': [self.invoice_line_5.id], 'model': self.rule_1, 'partner': self.bank_line_3.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_7.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_5.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_5.partner_id},
|
||||
}, statements=self.bank_st_2)
|
||||
|
||||
@@ -220,7 +220,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
self.rule_1.match_text_location_note = True
|
||||
self._check_statement_matching(self.rule_1, {
|
||||
self.bank_line_3.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_3.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_7.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_5.id: {'aml_ids': [self.invoice_line_5.id], 'model': self.rule_1, 'partner': self.bank_line_5.partner_id},
|
||||
}, statements=self.bank_st_2)
|
||||
|
||||
@@ -229,8 +229,8 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
self.rule_1.match_text_location_note = False
|
||||
self._check_statement_matching(self.rule_1, {
|
||||
self.bank_line_3.id: {'aml_ids': [self.invoice_line_5.id], 'model': self.rule_1, 'partner': self.bank_line_3.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_7.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_5.id: {'aml_ids': [self.invoice_line_7.id], 'model': self.rule_1, 'partner': self.bank_line_5.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_5.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_5.partner_id},
|
||||
}, statements=self.bank_st_2)
|
||||
|
||||
self.rule_1.match_text_location_label = True
|
||||
@@ -238,8 +238,8 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
self.rule_1.match_text_location_note = True
|
||||
self._check_statement_matching(self.rule_1, {
|
||||
self.bank_line_3.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_3.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_7.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_5.id: {'aml_ids': [self.invoice_line_7.id], 'model': self.rule_1, 'partner': self.bank_line_5.partner_id},
|
||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_4.partner_id},
|
||||
self.bank_line_5.id: {'aml_ids': [self.invoice_line_6.id], 'model': self.rule_1, 'partner': self.bank_line_5.partner_id},
|
||||
}, statements=self.bank_st_2)
|
||||
|
||||
self.rule_1.match_text_location_label = False
|
||||
|
||||
Reference in New Issue
Block a user