HowTo » History » Version 6

Thomas Mielke, 01/17/2020 06:29 PM

1 1 Alexander Blum
# HowTo
2 1 Alexander Blum
3 1 Alexander Blum
{{toc}}
4 1 Alexander Blum
5 1 Alexander Blum
## Tryton
6 1 Alexander Blum
7 1 Alexander Blum
### Change Model Fields
8 1 Alexander Blum
9 1 Alexander Blum
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.
10 1 Alexander Blum
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.
11 1 Alexander Blum
12 1 Alexander Blum
#### Update database
13 1 Alexander Blum
14 1 Alexander Blum
1. Start the services once:
15 1 Alexander Blum
16 1 Alexander Blum
        docker-compose up
17 1 Alexander Blum
18 1 Alexander Blum
2. 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):
19 1 Alexander Blum
20 4 Thomas Mielke
        docker-compose exec erpserver execute update -m collecting_society
21 1 Alexander Blum
22 1 Alexander Blum
3. Fix all update/init errors until the update runs successfully.
23 1 Alexander Blum
24 1 Alexander Blum
    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,
25 1 Alexander Blum
    the database will still contain that table/column and you won't notice the error until a complete rebuild of the database.
26 1 Alexander Blum
27 1 Alexander Blum
4. Restart the tryton client with cache disabled and test the views and fields of the model (read/write):
28 1 Alexander Blum
29 1 Alexander Blum
        tryton -d
30 1 Alexander Blum
31 1 Alexander Blum
    1. Create/Fix all XML views of that model, until everything works as expected, see [[HowTo#Change XML Views]].
32 1 Alexander Blum
33 1 Alexander Blum
    2. Fix all model functions of that model, until everything works as expected, see [[HowTo#Change Model Functions]].
34 1 Alexander Blum
35 1 Alexander Blum
#### Rebuild database
36 1 Alexander Blum
37 1 Alexander Blum
1. Stop the services and log into the tryton service:
38 1 Alexander Blum
39 1 Alexander Blum
        docker-compose stop
40 5 Thomas Mielke
        docker-compose run erpserver bash
41 1 Alexander Blum
42 6 Thomas Mielke
        execute pip-install tryton
43 1 Alexander Blum
44 1 Alexander Blum
2. Delete and setup a new database (`scenario_master_data.txt` only):
45 1 Alexander Blum
46 6 Thomas Mielke
        execute db-delete c3s && execute db-setup --master --force c3s
47 1 Alexander Blum
48 1 Alexander Blum
3. Check the log, fix all update/init errors, until the update runs successfully.
49 1 Alexander Blum
50 1 Alexander Blum
4. Start a tryton (only) service on second terminal (to be able to rebuild the database on the first terminal, if neccessary):
51 1 Alexander Blum
52 1 Alexander Blum
        docker-compose up tryton
53 1 Alexander Blum
54 1 Alexander Blum
5. Restart the tryton client with cache disabled (you might want to create an alias for that):
55 1 Alexander Blum
56 1 Alexander Blum
        tryton -d
57 1 Alexander Blum
58 1 Alexander Blum
    1. Create/Fix all XML views of that model, until everything works as expected, see [[HowTo#Change XML Views]].
59 1 Alexander Blum
60 1 Alexander Blum
    2. Fix all model functions of that model, until everything works as expected, see [[HowTo#Change Model Functions]].
61 1 Alexander Blum
62 1 Alexander Blum
11. Create/Fix the tests, see [[HowTo#Change DB Tests]]
63 1 Alexander Blum
64 1 Alexander Blum
12. Commit
65 1 Alexander Blum
66 1 Alexander Blum
### Change Model Functions
67 1 Alexander Blum
68 1 Alexander Blum
If you change some code within a model function, you just need to restart the tryton service for trytond to reread the function definitions:
69 1 Alexander Blum
70 1 Alexander Blum
    tryton -d
71 1 Alexander Blum
72 1 Alexander Blum
### Change XML Views
73 1 Alexander Blum
74 1 Alexander Blum
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).
75 1 Alexander Blum
A restart of the tryton client is not neccessary:
76 1 Alexander Blum
77 6 Thomas Mielke
    docker-compose exec erpserver execute update -m collecting_society c3s
78 1 Alexander Blum
79 1 Alexander Blum
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:
80 1 Alexander Blum
81 1 Alexander Blum
    tryton -d
82 1 Alexander Blum
83 1 Alexander Blum
### Change DB Tests
84 1 Alexander Blum
85 1 Alexander Blum
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.
86 1 Alexander Blum
87 1 Alexander Blum
1. Log into a tryton (only) service
88 1 Alexander Blum
89 5 Thomas Mielke
        docker-compose run erpserver bash
90 1 Alexander Blum
91 6 Thomas Mielke
        execute pip-install tryton
92 1 Alexander Blum
93 1 Alexander Blum
2. Delete and setup a clean database template (`scenario_master_data.txt` only), if not already available:
94 1 Alexander Blum
95 6 Thomas Mielke
        execute db-delete c3s_template && execute db-setup --master c3s_template
96 1 Alexander Blum
97 1 Alexander Blum
3. Delete the database, copy the database template and setup the data to test, pipe the output into a logfile:
98 1 Alexander Blum
99 6 Thomas Mielke
        execute db-delete c3s && execute db-copy c3s_template c3s && execute db-setup --demo --force c3s
100 1 Alexander Blum
101 1 Alexander Blum
    Start with `debug = 1` in the configuration section to set all configuration variables to 1.
102 1 Alexander Blum
    If that works, try `debug = 2` afterwards, as some objects might not be created due to the low sample size.
103 1 Alexander Blum
    Don't forget to set it back to `debug = False`, when you are finished.
104 1 Alexander Blum
105 1 Alexander Blum
4. 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:
106 1 Alexander Blum
107 1 Alexander Blum
        import interlude; interlude.interact(locals())
108 1 Alexander Blum
109 1 Alexander Blum
    You can always find that command in the import section at the top of the scenario files, if you want to copy & paste it.
110 1 Alexander Blum
111 1 Alexander Blum
5. 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):
112 1 Alexander Blum
113 1 Alexander Blum
        docker-compose up tryton
114 1 Alexander Blum
115 1 Alexander Blum
    Restart the tryton client with cache disabled:
116 1 Alexander Blum
117 1 Alexander Blum
        tryton -d
118 1 Alexander Blum
119 1 Alexander Blum
6. Set `debug = False` in the configuration section and do a final test run.
120 1 Alexander Blum
121 1 Alexander Blum
### Errors in pyramid view
122 1 Alexander Blum
123 1 Alexander Blum
If you encounter tryton errors in a pyramid error feedback view, you might be able to get more specific information on the error:
124 1 Alexander Blum
125 1 Alexander Blum
1. Open an interactive console, where one of the following keywords are passed as parameter: fieldname, error_args
126 1 Alexander Blum
2. Type that variable name into the console to find out its value, which could point towards the source of the error.
127 1 Alexander Blum
128 3 Thomas Mielke
### Errors in Protheus
129 1 Alexander Blum
130 1 Alexander Blum
... are sometimes cryptic. See here for Englisch and German translations:
131 1 Alexander Blum
132 2 Thomas Mielke
http://hg.tryton.org/trytond/file/tip/trytond/ir/locale/de.po
133 3 Thomas Mielke
134 3 Thomas Mielke
## Pyramid
135 3 Thomas Mielke
136 3 Thomas Mielke
2DO