fix: prevent duplicate customer notes in pos order processing and ignore empty entries
This commit is contained in:
parent
164307b46d
commit
a628105429
@ -82,14 +82,21 @@ class PosOrder(models.Model):
|
||||
line_notes = []
|
||||
for line in order['lines']:
|
||||
if len(line) >= 3 and isinstance(line[2], dict) and line[2].get('customer_note'):
|
||||
line_notes.append(line[2]['customer_note'].strip())
|
||||
note = line[2]['customer_note'].strip()
|
||||
if note:
|
||||
line_notes.append(note)
|
||||
|
||||
if line_notes:
|
||||
combined_notes = " / ".join(line_notes)
|
||||
if order.get('general_customer_note'):
|
||||
order['general_customer_note'] = f"{order['general_customer_note']} / {combined_notes}"
|
||||
else:
|
||||
order['general_customer_note'] = combined_notes
|
||||
current_note = order.get('general_customer_note') or ""
|
||||
existing_parts = [p.strip() for p in current_note.split(" / ")] if current_note else []
|
||||
new_notes = [n for n in line_notes if n not in existing_parts]
|
||||
|
||||
if new_notes:
|
||||
combined_notes = " / ".join(new_notes)
|
||||
if current_note:
|
||||
order['general_customer_note'] = f"{current_note} / {combined_notes}"
|
||||
else:
|
||||
order['general_customer_note'] = combined_notes
|
||||
|
||||
return super(PosOrder, self)._process_order(order, existing_order)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user