Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2817 Weergaven

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
Annuleer

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.

Auteur

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.

Gerelateerde posts Antwoorden Weergaven Activiteit
2
mrt. 24
5668
2
mrt. 24
8797
1
feb. 24
1717
2
dec. 23
3305
0
jun. 21
2655