Odoo Help

0

0
1 Answer
0
SonnyV
2017/05/31 11:59

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

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now