Skip to Content
Menu
This question has been flagged
1857 Views

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.

Avatar
Discard

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.

Author

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.

Related Posts Replies Views Activity
2
Mar 24
4124
2
Mar 24
7317
1
Feb 24
888
2
Dec 23
1137
0
Jun 21
1718