跳至内容
菜单
此问题已终结
2 回复
4576 查看

The old API defined a unique field as follows:

_sql_constraints = [
('cne_unique', 'unique(cne)', 'cne already exists!')
]

The new API deprecates this, and recommends to use @api.constrains, but how can I code to check for uniqueness in an efficient way?














形象
丢弃
最佳答案

Hi

this is _constraints which is deprecated (python constraint), not _sql_constraints, see :


https://www.odoo.com/documentation/8.0/reference/orm.html

形象
丢弃
编写者 最佳答案

@Cyril: please read my question. I know it is deprecated, I need to know how to do this in v8. 

形象
丢弃

please read my answer and verify in link I gave, _constraints and and _sql_constraints are two different things, you talk about _sql_constraints and this is not deprecated, see after => copy/paste v8 doc (link I gave) : _constraints list of (constraint_function, message, fields) defining Python constraints. The fields list is indicative Deprecated since version 8.0: use constrains() _sql_constraints list of (name, sql_definition, message) triples defining SQL constraints to execute when generating the backing table

编写者

Cyril, I sincerely apologize. You were completely right. _sql_constraints is not deprecated. I just don't know how to read. Thanks.

Now you have your answer ^^, bye

相关帖文 回复 查看 活动
1
11月 22
3413
0
6月 21
5965
0
3月 21
2783
2
1月 20
21754
2
5月 18
4089