Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] l10n_it_delivery_note: better handling for _action_confirm #4599

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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