Odoo Help

0

0
4 Answers
0
Damby Green
2018/11/11 21:35

raise ValidationError(_("Your record is too small: %s") % record.value)

try this one. It's correct form

0
Bharat Parmar (bhp)
2017/01/24 7:41

Try this,

from openerp import models, fields, api

from openerp.exceptions import ValidationError

class HelloWorld(models.Model):

     _name = 'helloworld.test'

    name = fields.Char("Name", required=True, size=20)

    value = fields.Integer("Value", required=True)


    @api.onchange('value')

    def _onchange_value(self)

        if self.value < 20:

            raise ValidationError("Your record is too small: %s" % self.value)

@api.constrains('value')

def _check_value(self)

        if self.value < 20:

            raise ValidationError("Your record is too small: %s" % self.value)

0

hello Andrew,

try this

@api.constrains('value')   

def _onchange_value(self):
        if (len(self.value) < 20):
            raise exceptions.ValidationError("Your record is too small: %s" % self.value)

I hope this is  help you

Thank you


0
Grf
2017/01/24 4:43

There was a typo... problem solved

Ask a Question
Writer
Tags
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