From d3084979457abf11bbd2391bef936a7d36355b89 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Fri, 29 May 2026 17:05:42 +0700 Subject: [PATCH] feat: add getter and setter for _code_activated_coupon_ids to PosOrder model --- static/src/app/pos_loyalty_safe_coupon_patch.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/static/src/app/pos_loyalty_safe_coupon_patch.js b/static/src/app/pos_loyalty_safe_coupon_patch.js index 87e8ba3..a6524d3 100644 --- a/static/src/app/pos_loyalty_safe_coupon_patch.js +++ b/static/src/app/pos_loyalty_safe_coupon_patch.js @@ -52,6 +52,22 @@ patch(PosOrderline.prototype, { // ─── PosOrder patches ───────────────────────────────────────────────────────── patch(PosOrder.prototype, { + get _code_activated_coupon_ids() { + const ids = this.raw._code_activated_coupon_ids || []; + const result = []; + for (const id of ids) { + const coupon = this.models["loyalty.card"].get(id); + if (coupon && coupon.program_id) { + result.push(coupon); + } + } + return result; + }, + + set _code_activated_coupon_ids(values) { + this.update({ _code_activated_coupon_ids: values }); + }, + /** * getLoyaltyPoints reads coupon_id.id — guard undefined coupon_id. */