Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4566 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ย. 22
3401
0
มิ.ย. 21
5956
0
มี.ค. 21
2778
2
ม.ค. 20
21735
2
พ.ค. 18
4083