2015-12-28 130 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")