odoo开发笔记 -- 字段增加唯一约束


前台违反约束效果:

 

后台模型中定义代码:

    name = fields.Char(string="Name", copy=False)  # 流水号   
    _sql_constraints = [('dec_name_uniq', 'unique(name)', 'error message dec name uniq')]

 

posted @ 2018-06-15 17:23  hello-Jesson  阅读(1639)  评论(0编辑  收藏  举报