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'))
本文介绍如何使用constrains装饰器对字段进行限制,例如在年龄字段上设置最小值为16岁,通过实例展示了具体实现方法。
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
448
436

被折叠的 条评论
为什么被折叠?