def METHOD_NAME(form, field):
    if (
        DiscountCoupon.query.join(
            DiscountPolicy, DiscountCoupon.discount_policy_id == DiscountPolicy.id
        )
        .filter(
            DiscountPolicy.organization == form.edit_parent.organization,
            DiscountCoupon.code == field.data,
        )
        .notempty()
    ):
        raise forms.StopValidation(
            __(
                "This discount coupon code already exists. Please enter a different coupon code"
            )
        )