diff options
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/voucher.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index e176803d..a76d57e6 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -1,6 +1,7 @@ from .. import controller from odoo import http from odoo.http import request +from bs4 import BeautifulSoup class Voucher(controller.Controller): @@ -56,7 +57,6 @@ class Voucher(controller.Controller): continue voucher_info = voucher.apply(order_line) - voucher_tnc = voucher.terms_conditions or voucher.generate_tnc() voucher_discount = voucher_info['discount']['all'] valid_order = voucher_info['valid_order'] @@ -66,7 +66,10 @@ class Voucher(controller.Controller): voucher_res = voucher.format() voucher_res['can_apply'] = can_apply voucher_res['discount_voucher'] = voucher_discount - voucher_res['terms_conditions'] = voucher_tnc + + cleaned_tnc = BeautifulSoup(voucher.terms_conditions, "html.parser").get_text() + voucher_res['terms_conditions'] = voucher.terms_conditions if cleaned_tnc else voucher.generate_tnc() + results.append(voucher_res) sorted_results = sorted(results, key=lambda x: x['can_apply'], reverse=True) |
