콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
5674 화면

Hi,

 _sql_constraints = [('name_uniq', ...]  for work fine in a new database[empty], but for an existing db it didn't work, is there any way to applied it to an existing db


Regards,

아바타
취소
베스트 답변

Please refer to this one

https://www.odoo.com/forum/help-1/question/why-sql-constraints-not-working-39549

아바타
취소
베스트 답변

Well you have to add pre_init_hook function in the __init__ to sanitize your field before applying the sql constraint.

so in the python function be sure to check if all records meet the new condition and automate fixed for those who wont comply.

Then you gonna be able to apply the constrain

아바타
취소