[FIX] account: avoid invoice name reset when we change the name manually

Before:
- Create a new sales journal
- Create a new first invoice
- Do not put an invoice date yet
- Change the name from 2023/000001 to e.g. 2023/000010
- Confirm the invoice
- The name will change back to 2023/000001 (which is not the wanted behaviour)

After:
We avoid the change back by adding a condition in the _compute_name, which
is triggered by the invoice_date being set while confirming.

X-original-commit: e31c5767c894a92d22fa8201bc1ccf34b052a336
Part-of: odoo/odoo#111294
This commit is contained in:
Josse Colpaert
2023-01-29 03:41:52 +01:00
parent 3844833a74
commit 46e6ae2941
+1 -1
View File
@@ -667,7 +667,7 @@ class AccountMove(models.Model):
highest_name = self[0]._get_last_sequence(lock=False) if self else False
for move in self:
if not highest_name and move == self[0] and not move.posted_before and move.date:
if not highest_name and move == self[0] and not move.posted_before and move.date and (not move.name or move.name == '/'):
# In the form view, we need to compute a default sequence so that the user can edit
# it. We only check the first move as an approximation (enough for new in form view)
move._set_next_sequence()