【转】Odoo 学习之: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 @ 2018-02-22 20:25  A·DONG  阅读(297)  评论(0)    收藏  举报