<commit_before># -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request

class Website_coupon(http.Controller):

    @http.route(['/shop/apply_coupon'], type='json', auth="public", website=True)
    def shop_apply_coupon(self, promo_code, **post):
        order = request.website.sale_get_order()
        coupon_status = request.env['sale.coupon.apply.code'].apply_coupon(order, promo_code)
        return coupon_status
<commit_msg>[FIX] website_sale_coupon: Allow public users to use coupons on website<commit_after># -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request

class Website_coupon(http.Controller):

    @http.route(['/shop/apply_coupon'], type='json', auth="public", website=True)
    def shop_apply_coupon(self, promo_code, **post):
        order = request.website.sale_get_order()
        coupon_status = request.env['sale.coupon.apply.code'].sudo().apply_coupon(order, promo_code)
        return coupon_status

{'fraction_non_alphanumeric': 0.1344364012409514, 'fraction_numerical': 0.002068252326783868, 'mean_word_length': 4.468926553672317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2314169', 'n_tokens_mistral': 321, 'n_tokens_neox': 319, 'n_words': 65}