Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3732 Переглядів

Hello community

I currently have a webshop set-up. Defined a pricelist to give a 10%discount on some products.

I made the promocode 'ODOOISBEST'. Now, the people that will be using this won't always know it is case sensitive, so rather than displaying a message about the code being case-sensitive, I'd like to change the evaluation of input and value to evaluate lower-case values.

I looked in the code and js of website_sale but with no luck. I just can't seem to find what gets called when I click the confirm button to check for the pricelist.

I found that in main.py (controller) of website_sale there is a method called pricelist. But this does't do the comparison, just checks whether the prices should be updated or not. 

I need the specific code where the system does the comparison.

Any help would be greatly appreciated

Аватар
Відмінити
Автор Найкраща відповідь

I figured this out a while ago, but since this is still open I will update with an answer:

In website_sale/controllers/main there is a method called pricelist with route /shop/pricelist

I inherited this controller in a custom module and replaced the part

request.website.sale_get_order(code=promo, context=context)

with

request.website.sale_get_order(code=promo.upper, context=context)</code>

And then I inherited product.pricelist and its 'create' and 'write' method

 class product_pricelist(models.Model):
    _inherit = "product.pricelist"
    @api.model
    def create(self, values={}):
        '''
        Force the pricelist-codes (couponcodes) to be uppercase
        '''
        if values.get('code'):
            values['code'] = values.get('code').upper()
        res = super(product_pricelist, self).create(values)
        return res
    @api.multi
    def write(self, values={}):
        '''
        Force the pricelist-codes (couponcodes) to be uppercase
        '''
        if values.get('code'):
            values['code'] = values.get('code').upper()
        res = super(product_pricelist, self).write(values)
        return res

This makes sure that whatever you enter as a promocode in the backoffice when configuring, it will always be uppercase

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
3
черв. 19
4254
1
трав. 25
1288
0
лют. 25
1280
2
черв. 24
3542
0
черв. 23
2395