Skip to content

[Bug]: Coupon Management Screen Stabilization #236

@shuhain85

Description

@shuhain85

Issue Search Confirmation

  • I have searched existing open and closed issues and this is not a duplicate

Bug Description

Bug Report: Coupon Management Screen Stabilization

Issue Summary

The Coupon Management screen had two related issues causing instability in the coupon workflow.

1) 417 Query Failure

Opening the coupon management screen triggered:

417 EXPECTATION FAILED

Backend traceback:
frappe.exceptions.DataError: Field not permitted in query: disabled

Root Cause

Inside CouponManagement.vue, the Campaign lookup used:
filters: { disabled: 0 }

The Campaign DocType did not permit querying this field through frappe.client.get_list.

Fix Applied

Removed the invalid filter and replaced it with:
order_by: "name asc"


2) Translation-Based Dropdown / Filter Mismatch

Coupon edit form fields were using translated fallback values inside populateFormFromCoupon().

Examples:

  • __('Promotional')
  • __('Percentage')
  • __('Grand Total')

This caused:

  • dropdown mismatch
  • filter mismatch
  • incorrect save/update payload values
  • translated UI labels leaking into backend logic

Fix Applied

Replaced translated fallback values with raw backend-safe values:

  • "Promotional"
  • "Percentage"
  • "Grand Total"

Files Involved

1) CouponManagement.vue

Main production patch file containing:

  • Campaign query fix
  • translation fallback fix

2) PromotionCouponManagement.vue

Validation scope file used for:

  • coupon tab mounting validation
  • parent-child state sync checks
  • crash isolation and verification

No major production logic changes required.


Final Result

Coupon management screen is now stable.

Resolved:

  • 417 backend query crash
  • translated fallback mismatches
  • dropdown binding failures
  • coupon editor save/update inconsistencies

Steps to Reproduce

Bug Report: Coupon Management Screen

Steps to Reproduce

  1. Open Promotion & Coupon Management
  2. Go to the Coupons tab
  3. Open the coupon list or edit an existing coupon

Bug

  • Screen throws 417 EXPECTATION FAILED
  • Coupon dropdown values do not match correctly
  • Filters may fail
  • Save/update may use wrong values

Expected Behavior

Expected Behavior
Coupons tab opens without errors
Dropdown values match saved coupon data
Filters work correctly
Save and update use correct values

Actual Behavior

ctual Behavior
417 EXPECTATION FAILED error appears when opening the Coupons tab
Some dropdown values do not match the saved coupon record
Filters return incorrect or empty results
Save/update may send wrong values

Screenshots / Screen Recordings

error

Browser Console Errors

417 (EXPECTATION FAILED)
kg @ index-DiO78UqX.js:22
Ek @ index-DiO78UqX.js:45
(anonymous) @ index-DiO78UqX.js:46
(anonymous) @ index-DiO78UqX.js:2
Z @ index-DiO78UqX.js:2
(anonymous) @ index-DiO78UqX.js:46
(anonymous) @ index-DiO78UqX.js:22
(anonymous) @ index-DiO78UqX.js:2
Z @ index-DiO78UqX.js:2
s @ index-DiO78UqX.js:22
_e @ POSSale-Ccdte_QC.js:148
(anonymous) @ POSSale-Ccdte_QC.js:148
(anonymous) @ index-DiO78UqX.js:14
qa @ index-DiO78UqX.js:14
Vr @ index-DiO78UqX.js:14
Pu.t.__weh.t.__weh @ index-DiO78UqX.js:14
Oy @ index-DiO78UqX.js:14
Ay @ index-DiO78UqX.js:14
Promise.then
Cy @ index-DiO78UqX.js:14
kd @ index-DiO78UqX.js:14
Ue.Fe.scheduler @ index-DiO78UqX.js:14
trigger @ index-DiO78UqX.js:10
Cd @ index-DiO78UqX.js:10
notify @ index-DiO78UqX.js:10
trigger @ index-DiO78UqX.js:10
set value @ index-DiO78UqX.js:10
b.value.e.onClick._.<computed>._.<computed> @ POSSale-Ccdte_QC.js:148
qa @ index-DiO78UqX.js:14
Vr @ index-DiO78UqX.js:14
n @ index-DiO78UqX.js:18
index-DiO78UqX.js:45 Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 120, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 52, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 53, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1764, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/client.py", line 67, in get_list
    validate_args(args)
  File "apps/frappe/frappe/desk/reportview.py", line 93, in validate_args
    validate_filters(data, data.filters)
  File "apps/frappe/frappe/desk/reportview.py", line 158, in validate_filters
    raise_invalid_field(fieldname)
  File "apps/frappe/frappe/desk/reportview.py", line 180, in raise_invalid_field
    frappe.throw(_("Field not permitted in query") + f": {fieldname}", frappe.DataError)
  File "apps/frappe/frappe/__init__.py", line 619, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 584, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 535, in _raise_exception
    raise exc
frappe.exceptions.DataError: Field not permitted in query: disabled

index-DiO78UqX.js:45 Uncaught (in promise) Error: /api/method/frappe.client.get_list DataError
    at index-DiO78UqX.js:45:2585
    at Generator.next (<anonymous>)
    at s (index-DiO78UqX.js:2:940)
(anonymous) @ index-DiO78UqX.js:45
s @ index-DiO78UqX.js:2
Promise.then
a @ index-DiO78UqX.js:2
(anonymous) @ index-DiO78UqX.js:2
Z @ index-DiO78UqX.js:2
transformResponse @ index-DiO78UqX.js:45
(anonymous) @ index-DiO78UqX.js:22
Promise.then
kg @ index-DiO78UqX.js:22
Ek @ index-DiO78UqX.js:45
(anonymous) @ index-DiO78UqX.js:46
(anonymous) @ index-DiO78UqX.js:2
Z @ index-DiO78UqX.js:2
(anonymous) @ index-DiO78UqX.js:46
(anonymous) @ index-DiO78UqX.js:22
(anonymous) @ index-DiO78UqX.js:2
Z @ index-DiO78UqX.js:2
s @ index-DiO78UqX.js:22
_e @ POSSale-Ccdte_QC.js:148
(anonymous) @ POSSale-Ccdte_QC.js:148
(anonymous) @ index-DiO78UqX.js:14
qa @ index-DiO78UqX.js:14
Vr @ index-DiO78UqX.js:14
Pu.t.__weh.t.__weh @ index-DiO78UqX.js:14
Oy @ index-DiO78UqX.js:14
Ay @ index-DiO78UqX.js:14
Promise.then
Cy @ index-DiO78UqX.js:14
kd @ index-DiO78UqX.js:14
Ue.Fe.scheduler @ index-DiO78UqX.js:14
trigger @ index-DiO78UqX.js:10
Cd @ index-DiO78UqX.js:10
notify @ index-DiO78UqX.js:10
trigger @ index-DiO78UqX.js:10
set value @ index-DiO78UqX.js:10
b.value.e.onClick._.<computed>._.<computed> @ POSSale-Ccdte_QC.js:148
qa @ index-DiO78UqX.js:14
Vr @ index-DiO78UqX.js:14
n @ index-DiO78UqX.js:18

POS Next Version

Development/Custom build

Exact Version (if known)

No response

Frappe Framework Version

15.0

ERPNext Version

15.0

Browser

Chrome

Browser Version

chromw

Operating System

Windows 11

Deployment Type

Self-hosted (Production)

Bug Frequency

Always (100% reproducible)

Offline Mode

No - Online mode only

Additional Context

No response

Server Logs (if applicable)

Pre-submission Checklist

  • I have provided screenshots showing the issue
  • I have included my application version information
  • I have provided clear steps to reproduce the issue
  • I have checked browser console for errors and included them if present

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions