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

I do the following experiment:

1. I add two constrains as below:

_sql_constraints = [
('check_positive', 'CHECK (expected_price> 0)', 'The price shall be positive!'), ('check_positive1', 'CHECK (garden_area> 0)', 'The area shall be positive!')
]

2. it works, both value set violating the rule get warned.

3 Then I remove check_positive1, that is

_sql_constraints = [('check_positive', 'CHECK (expected_price> 0)', 'The price shall be positive!'), ]

4. restart odoo server, I find check_positive is still working

5.I use psql command to check the data base, and I find the following:

"estate_estate_check_positive" CHECK (expected_price> 0 :: double precision)
"estate_estate_check_positve1" CHECK (garden_area> 0)
6. My assumption: odoo can add constraint, but if you remove a constraint, it does not inform psql to do so.

Is there any other people do successfully remove a constraint by changing the  content  of  _sql_constraints  statement, please let me know. Thank you in advance.

2.

아바타
취소

Did you upgrade your module so that the new code is reinterpreted and the schema is redefined? Changes to code that initializes Odoo (defines fields and models) and changes to files loaded only once into Odoo (csv, xml) will be ignored by restarting the server. You need to upgrade the module to force the server to look newly at those files.

작성자

Thank you very much for you answer. I use the following command -u to update

./odoo/odoo-bin --addons-path=./custom,./odoo/odoo/addons -d rd-demo -u my_model --dev xml

Is that enough? For other changes, this command works very well, only when _sql_constraints is modified I find the database setting does not change.

관련 게시물 답글 화면 활동
2
3월 24
5721
2
3월 24
8836
1
2월 24
1743
@api.constrains 해결 완료
2
12월 23
3370
0
6월 21
2672