跳至內容
選單
此問題已被標幟
4 回覆
2861 瀏覽次數

Hi!!

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

Pleas, how can i do it help

頭像
捨棄

Elaborate your purpose little bit please !

作者

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.

最佳答案

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()
頭像
捨棄
最佳答案


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)

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 25
1287
0
1月 25
3386
1
8月 23
14680
1
8月 23
13311
1
7月 23
10340