From e776f114b20f4839cf33b6621b8a83151bcec361 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Wed, 5 Feb 2025 15:18:08 +0100 Subject: [PATCH] [FIX] ooops_l10n_it_delivery_note: better handling for _action_confirm --- .../models/stock_delivery_note.py | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/l10n_it_delivery_note/models/stock_delivery_note.py b/l10n_it_delivery_note/models/stock_delivery_note.py index a86b29a296a..9424f1ff5b4 100644 --- a/l10n_it_delivery_note/models/stock_delivery_note.py +++ b/l10n_it_delivery_note/models/stock_delivery_note.py @@ -603,25 +603,23 @@ def action_draft(self): def _action_confirm(self): for note in self: sequence = note.type_id.sequence_id - - note.state = DOMAIN_DELIVERY_NOTE_STATES[1] - if not note.date: - note.date = datetime.date.today() - + dt = note.date or datetime.date.today() + vals = {"state": "confirm", "date": dt} if not note.name: - note.name = sequence.next_by_id() # Avoid duplicates while True: - name = sequence.with_context( - ir_sequence_date=note.date - ).next_by_id() + name = sequence.with_context(ir_sequence_date=dt).next_by_id() if not self.search( - [("name", "=", name), ("company_id", "=", note.company_id.id)] + [ + ("name", "=", name), + ("company_id", "=", note.company_id.id), + ] ): break - note.name = name - note.sequence_id = sequence + vals.update({"name": name, "sequence_id": sequence.id}) + + note.write(vals) def action_confirm(self): for note in self: