Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4 Antwoorden
2840 Weergaven

Hi!!

I want to controle a field if it contains a space (\t) in odoo v8.

Pleas, how can i do it help

Avatar
Annuleer

Elaborate your purpose little bit please !

Auteur

I have a field called project in which i wouldnt have empty string so i put it required= True and now i want it to NOT COTAIN a space.

Beste antwoord

You should define a python constraint

_constraints = [(_function_name, warning_string, list_of_relevant_attributes)]
ex :

_constraints = [(_check_empty_string, 'The name cannot contains only spaces", ['name'])
def _check_empty_string(self, cr, uid, ids, context=None) : (old API way)
    project = self.browse(cr,uid, ids, context=context)
    return not project.name.isspace()
Avatar
Annuleer
Beste antwoord


for v8 you can write constraint like to validate the space,

	@api.constrains('name')
def check_name(self):
if self.name.isspace():
raise ValidationError("Name can not be Empty")

name = fields.Char('Name', required=True)

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 25
1268
0
jan. 25
3324
1
aug. 23
14627
1
aug. 23
13266
1
jul. 23
10287