Odoo 8 替代_constraints
Odoo 8 alternative to _constraints
我需要一个 Odoo 8 的 Openerp 7 中 _constraints
的替代品。
我在 res.partner
中添加了一个新字段,我想在保存之前检查某些条件。
您需要使用 @api.constraints
装饰器。
@api.one
@api.constrains('new_field')
def _check_description(self):
if self.new_field < 0: # Test new_field
raise ValidationError("new_field should be positive")
我需要一个 Odoo 8 的 Openerp 7 中 _constraints
的替代品。
我在 res.partner
中添加了一个新字段,我想在保存之前检查某些条件。
您需要使用 @api.constraints
装饰器。
@api.one
@api.constrains('new_field')
def _check_description(self):
if self.new_field < 0: # Test new_field
raise ValidationError("new_field should be positive")