2015-12-28 124 views
0

我需要的OpenERP 7 Odoo 8Odoo 8替代_constraints

_constraints替代我有一个新的领域加入到res.partner,我想在保存前检查某些条件。

+0

请包括一些代码来显示你已经尝试过。 –

+0

“@ api.constraints”有什么问题? –

回答

1

您需要使用@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")