跳至内容
菜单
此问题已终结
2670 查看

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
5353
2
3月 24
8519
1
2月 24
1536
2
12月 23
2857
0
6月 21
2455