HowTo » History » Version 1
Version 1/22
-
Next » -
Current version
Alexander Blum, 10/05/2019 08:10 PM
HowTo¶
Tryton¶
Change Model Fields¶
If the fields of a model need some changes, you first might want to try to update the current database (if possible) until you are satisfied.
Nevertheless, always test a rebuild from scratch before a commit. Of course you could also skip the updating part, but a complete db setup needs more time.
Update database¶
Start the services once:
docker-compose up
While you are coding, apply changes to the database with
exec
(exec
executes the command on the running container instead of starting a new one, so it is faster):docker-compose exec tryton ado-do update -m collecting_society c3s
Fix all update/init errors until the update runs successfully.
Watch the logs for warnings, but be aware, that sometimes there is none - e.g. if you deleted a field/relation but still use it somewhere else,
the database will still contain that table/column and you won't notice the error until a complete rebuild of the database.Restart the tryton client with cache disabled and test the views and fields of the model (read/write):
tryton -d
Rebuild database¶
Stop the services and log into the tryton service:
docker-compose stop docker-compose run tryton bash ado-do pip-install tryton
Delete and setup a new database (
scenario_master_data.txt
only):ado-do db-delete c3s && ado-do db-setup --master --force c3s
Check the log, fix all update/init errors, until the update runs successfully.
Start a tryton (only) service on second terminal (to be able to rebuild the database on the first terminal, if neccessary):
docker-compose up tryton
Restart the tryton client with cache disabled (you might want to create an alias for that):
tryton -d
Create/Fix the tests, see HowTo
Commit
Change Model Functions¶
If you change some code within a model function, you just need to restart the tryton service for trytond to reread the function definitions:
tryton -d
Change XML Views¶
If you change the main XML (e.g. ado/src/collecting_society/collecting_society.xml
), you need to update the database (best with exec on a running container).
A restart of the tryton client is not neccessary:
docker-compose exec tryton ado-do update -m collecting_society c3s
If you change the XML views for a model (e.g. ado/src/collecting_society/view/creation_list.xml
), it is sufficient to close and reopen the list in the tryton client, if cache is disabled:
tryton -d
Change DB Tests¶
If you want/need to change the database tests (ado/etc/scenario_demo_data.txt
), you want to create and setup a new database template (e.g. c3s_template
) and use a copy of it as the starting point for the test/demo setup.
Log into a tryton (only) service
docker-compose run tryton bash ado-do pip-install tryton
Delete and setup a clean database template (
scenario_master_data.txt
only), if not already available:ado-do db-delete c3s_template && ado-do db-setup --master c3s_template
Delete the database, copy the database template and setup the data to test, pipe the output into a logfile:
ado-do db-delete c3s && ado-do db-copy c3s_template c3s && ado-do db-setup --demo --force c3s
Start with
debug = 1
in the configuration section to set all configuration variables to 1.
If that works, trydebug = 2
afterwards, as some objects might not be created due to the low sample size.
Don't forget to set it back todebug = False
, when you are finished.Check the log, fix all errors, until the setup runs successfully. If you get stuck, fire up an interactive console with interlude within your tests:
import interlude; interlude.interact(locals())
You can always find that command in the import section at the top of the scenario files, if you want to copy & paste it.
To validate the test data, start a tryton (only) service on second terminal (to be able to rebuild the database on the first terminal, if neccessary):
docker-compose up tryton
Restart the tryton client with cache disabled:
tryton -d
Set
debug = False
in the configuration section and do a final test run.
Errors in pyramid view¶
If you encounter tryton errors in a pyramid error feedback view, you might be able to get more specific information on the error:
- Open an interactive console, where one of the following keywords are passed as parameter: fieldname, error_args
- Type that variable name into the console to find out its value, which could point towards the source of the error.
Pyramid¶
2DO