diff options
| author | Laurent Smet <las@odoo.com> | 2021-02-12 09:13:40 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2021-02-18 11:53:42 +0000 |
| commit | 7a7dc212af7279544cffba362bce7daa4fc00865 (patch) | |
| tree | 9db73d64a7882e18e820de47c9632102fb19a320 | |
| parent | d3854dbf7a6e0c0f9ac00c11716908bc175808d7 (diff) | |
[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#66158
Co-author: nboulif <bon@odoo.com>
X-original-commit: 1027490318f3baa9bef382b3e54b20d05a40aa03
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
| -rw-r--r-- | addons/account/models/account_move.py | 4 | ||||
| -rw-r--r-- | addons/account/tests/test_account_move_in_invoice.py | 20 | ||||
| -rw-r--r-- | addons/account/tests/test_reconciliation_matching_rules.py | 12 |
3 files changed, 28 insertions, 8 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 0e3b3823aed..c4251614fbb 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -448,7 +448,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): @@ -963,7 +963,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, diff --git a/addons/account/tests/test_account_move_in_invoice.py b/addons/account/tests/test_account_move_in_invoice.py index c9df200825c..0245d22a722 100644 --- a/addons/account/tests/test_account_move_in_invoice.py +++ b/addons/account/tests/test_account_move_in_invoice.py @@ -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, + }) diff --git a/addons/account/tests/test_reconciliation_matching_rules.py b/addons/account/tests/test_reconciliation_matching_rules.py index cc9e9d73d7c..1529abfa896 100644 --- a/addons/account/tests/test_reconciliation_matching_rules.py +++ b/addons/account/tests/test_reconciliation_matching_rules.py @@ -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 |
