HowTo » History » Version 12

Udo Spallek, 01/19/2020 01:41 AM
Add clarification

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 10 Thomas Mielke
        execute db-delete && execute db-setup --master --force
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 11 Udo Spallek
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) and restart the client. A restart of the tryton server is usually not neccessary,
75 1 Alexander Blum
76 1 Alexander Blum
    docker-compose exec erpserver execute update -m collecting_society
77 7 Thomas Mielke
78 11 Udo Spallek
WARNING: If you have fixed view errors in the XML and it seems that the view cache is not cleared or the changes in the XML definitions are not propagated to the application,
79 11 Udo Spallek
do the following:
80 1 Alexander Blum
81 11 Udo Spallek
1. Check the `name` tag in the corresponding `ir.ui.view` record model entries in the **main XML**. The `name` must correspond to a file name in the `view` path, but plus ".xml".
82 11 Udo Spallek
1. Temporarily delete the corresponding definitions of the broken view (usually at least the record models `ir.ui.view, ir.action.act_window, ir.action.act_window.view` and `menuitem`)
83 11 Udo Spallek
1. Update the database: `docker-compose exec erpserver execute update -m collecting_society`
84 11 Udo Spallek
1. Insert the corresponding definitions of the broken view again (undo the deletion)
85 11 Udo Spallek
1. Again update the database: `docker-compose exec erpserver execute update -m collecting_society`
86 12 Udo Spallek
1. Restart the Tryton Client
87 11 Udo Spallek
88 11 Udo Spallek
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 view in the tryton client, if cache is disabled:
89 11 Udo Spallek
90 11 Udo Spallek
    tryton --dev
91 1 Alexander Blum
92 1 Alexander Blum
### Change DB Tests
93 1 Alexander Blum
94 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.
95 1 Alexander Blum
96 1 Alexander Blum
1. Log into a tryton (only) service
97 1 Alexander Blum
98 5 Thomas Mielke
        docker-compose run erpserver bash
99 1 Alexander Blum
100 6 Thomas Mielke
        execute pip-install tryton
101 1 Alexander Blum
102 1 Alexander Blum
2. Delete and setup a clean database template (`scenario_master_data.txt` only), if not already available:
103 1 Alexander Blum
104 6 Thomas Mielke
        execute db-delete c3s_template && execute db-setup --master c3s_template
105 1 Alexander Blum
106 1 Alexander Blum
3. Delete the database, copy the database template and setup the data to test, pipe the output into a logfile:
107 1 Alexander Blum
108 8 Thomas Mielke
        execute db-delete c3s && execute db-copy c3s_template c3s && execute db-setup --demo --force
109 1 Alexander Blum
110 1 Alexander Blum
    Start with `debug = 1` in the configuration section to set all configuration variables to 1.
111 1 Alexander Blum
    If that works, try `debug = 2` afterwards, as some objects might not be created due to the low sample size.
112 1 Alexander Blum
    Don't forget to set it back to `debug = False`, when you are finished.
113 1 Alexander Blum
114 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:
115 1 Alexander Blum
116 1 Alexander Blum
        import interlude; interlude.interact(locals())
117 1 Alexander Blum
118 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.
119 1 Alexander Blum
120 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):
121 1 Alexander Blum
122 1 Alexander Blum
        docker-compose up tryton
123 1 Alexander Blum
124 1 Alexander Blum
    Restart the tryton client with cache disabled:
125 1 Alexander Blum
126 1 Alexander Blum
        tryton -d
127 1 Alexander Blum
128 1 Alexander Blum
6. Set `debug = False` in the configuration section and do a final test run.
129 1 Alexander Blum
130 1 Alexander Blum
### Errors in pyramid view
131 1 Alexander Blum
132 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:
133 1 Alexander Blum
134 1 Alexander Blum
1. Open an interactive console, where one of the following keywords are passed as parameter: fieldname, error_args
135 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.
136 1 Alexander Blum
137 3 Thomas Mielke
### Errors in Protheus
138 1 Alexander Blum
139 1 Alexander Blum
... are sometimes cryptic. See here for Englisch and German translations:
140 1 Alexander Blum
141 2 Thomas Mielke
http://hg.tryton.org/trytond/file/tip/trytond/ir/locale/de.po
142 3 Thomas Mielke
143 3 Thomas Mielke
## Pyramid
144 3 Thomas Mielke
145 3 Thomas Mielke
2DO