Loading

Odoo 8.0 new API 之constrains装饰

constrains装饰用于对字段进行限制

应用举例:

定义列:

age = fields.Integer(string="age")    

方法:

@api.constrains('age')
def _check_age(self):
    if self.age<16:
        raise ValueError(_('Age must be older than 16'))

 

posted @ 2014-08-06 16:18  青岛欧姆网络科技  阅读(870)  评论(0编辑  收藏  举报