Skip to Content
मेन्यू
This question has been flagged

After adding the following code I was able to add a custom field to the customer/supplier creation form and also got to validate the value entered in the field to be only numeric.

While testing I tried to change the language for the current user and the constraint got triggered there as well , any idea on how to limit it only to the customer/supplier creation form ?

Thanks again for reading this post.

class cs_dni(osv.Model):

_inherit = 'res.partner'

_columns = {
    'x_dni': fields.char('DNI.', size=13, required=True)
} 
.......
def _check_value(self, cr, uid, ids, context=None):
    for val in self.browse(cr, uid, ids, context=context):
        if val.x_dni and isinstance(val.x_dni, int):
            return True
    return False

_constraints = [
    (_check_value, 'You cannot add value other than integer".', ['x_dni']),
]

Here is the screen shoot i57.tinypic.com/1zxbnfo.png

Avatar
Discard
Related Posts Replies Views Activity
1
मार्च 15
4469
3
मार्च 15
6160
0
मई 23
7468
1
मई 22
26371
8
मई 16
34199