fix: prevent duplicate customer notes in pos order processing and ignore empty entries

This commit is contained in:
Suherdy Yacob 2026-06-17 21:34:24 +07:00
parent 164307b46d
commit a628105429

View File

@ -82,12 +82,19 @@ class PosOrder(models.Model):
line_notes = [] line_notes = []
for line in order['lines']: for line in order['lines']:
if len(line) >= 3 and isinstance(line[2], dict) and line[2].get('customer_note'): 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: if line_notes:
combined_notes = " / ".join(line_notes) current_note = order.get('general_customer_note') or ""
if order.get('general_customer_note'): existing_parts = [p.strip() for p in current_note.split(" / ")] if current_note else []
order['general_customer_note'] = f"{order['general_customer_note']} / {combined_notes}" 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: else:
order['general_customer_note'] = combined_notes order['general_customer_note'] = combined_notes