Skip to content

Commit

Permalink
[FIX] ooops_l10n_it_delivery_note: better handling for _action_confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
GSLabIt authored and Chionne27 committed Feb 5, 2025
1 parent ea8d2f5 commit 2a70bae
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions l10n_it_delivery_note/models/stock_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,24 +586,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:
# 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:
Expand Down

0 comments on commit 2a70bae

Please sign in to comment.