Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2832 Zobrazení

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
Zrušit

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.

Autor

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 Odpovědi Zobrazení Aktivita
2
bře 24
5679
2
bře 24
8808
1
úno 24
1721
2
pro 23
3327
0
čvn 21
2660