【转】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'))
原文地址:https://www.cnblogs.com/KKSoft/p/8460013.html