1-
2- .. _odoosh-gettingstarted-online-editor :
3-
41=============
5- Online Editor
2+ Online editor
63=============
74
8- Overview
9- ========
5+ The :guilabel: `Online Editor ` view allows editing the source code of your builds from a web browser.
6+ It also gives you the possibility to open terminals, Python consoles, Odoo shell consoles, and
7+ `Jupyter Notebooks <https://jupyterlab.readthedocs.io/en/stable/user/notebook.html >`_.
108
11- The online editor allows you to edit the source code of your builds from a web browser.
12- It also gives you the possibility to open terminals, Python consoles, Odoo Shell consoles and
13- `Notebooks <https://jupyterlab.readthedocs.io/en/stable/user/notebook.html >`_.
9+ .. image :: online-editor/online-editor.png
10+ :alt: Overview of the online editor
1411
15- .. image :: online-editor/interface-editor.png
16- :align: center
12+ You can access the editor of a build through :ref: `the branches tab <odoo-sh/branches/tabs >`,
13+ :ref: `the builds dropdown menu <odoo-sh/builds/stages/features >`, or by adding `/odoo-sh/editor ` to
14+ the build's URL (e.g., `https://odoo-addons-master-1.dev.odoo.com/odoo-sh/editor `).
1715
18- You can access the editor of a build through
19- :ref: `the branches tabs <odoo-sh/branches/tabs >`,
20- :ref: `the builds dropdown menu <odoo-sh/builds/stages/features >`
21- or by adding */odoo-sh/editor * to your build domain name
22- (e.g. *https://odoo-addons-master-1.dev.odoo.com/odoo-sh/editor *).
16+ .. _odoo-sh/editor/source :
2317
24- Edit the source code
25- ====================
18+ Editing the source code
19+ =======================
2620
27- The working directory is composed of the following folders :
21+ The working directory is composed of the following:
2822
2923::
3024
@@ -38,160 +32,169 @@ The working directory is composed of the following folders:
3832 │ │ ├── themes Odoo Themes source code
3933 │ │ └── user Your repository branch source code
4034 │ ├── data
41- │ │ ├── filestore database attachments, as well as the files of binary fields
42- │ │ └── sessions visitors and users sessions
35+ │ │ ├── filestore Database attachments, as well as the files of binary fields
36+ │ │ └── sessions Visitors and users sessions
4337 │ └── logs
4438 │ ├── install.log Database installation logs
4539 │ ├── odoo.log Running server logs
4640 │ ├── update.log Database updates logs
4741 │ └── pip.log Python packages installation logs
4842
49- You can edit the source code (files under */src *) in development and staging builds.
43+ You can edit the source code (files under `/src `) of development and staging builds. For production
44+ builds, the source code is read-only, because applying local changes on a production server is not a
45+ good practice.
5046
5147.. note ::
52- Your changes won't be propagated to a new build, you must commit them in your
53- source code if you want to make them persist.
48+ - Your changes won't be propagated to new builds. It is necessary to :ref: `commit them to the
49+ source code <odoo-sh/editor/commit>` if you want them to persist.
50+ - The source code of your GitHub repository is located under `/src/user `.
51+ - The source code of Odoo is located under:
5452
53+ - `/src/odoo ` (`<https://github.com/odoo/odoo >`_)
54+ - `/src/enterprise ` (`<https://github.com/odoo/enterprise >`_)
55+ - `/src/themes ` (`<https://github.com/odoo/design-themes >`_)
5556
56- For production builds, the source code is read-only, because applying local changes on a production
57- server is not a good practice.
57+ To open a file in the editor, double-click it in the file browser panel. You can then edit the file.
58+ To save your changes, go to :menuselection: `File --> Save ` or use the :kbd: `Ctrl + S ` keyboard
59+ shortcut.
5860
59- * The source code of your Github repository is located under * /src/user *,
60- * The source code of Odoo is located under
61+ If you save a Python file in your Odoo server's addons path, Odoo will detect it and reload
62+ automatically, meaning your changes are immediately visible.
6163
62- * */src/odoo * (`odoo/odoo <https://github.com/odoo/odoo >`_),
63- * */src/enterprise * (`odoo/enterprise <https://github.com/odoo/enterprise >`_),
64- * */src/themes * (`odoo/design-themes <https://github.com/odoo/design-themes >`_).
64+ .. image :: online-editor/auto-reload.gif
65+ :alt: Change to a Python file being immediately visible
6566
66- To open a file in the editor, just double-click on it in the file browser panel on the left.
67+ However, if your changes are stored in the database, such as a field's label or a view, it is
68+ necessary to update the related module to apply the changes. To update the module of the currently1
69+ open file, go to :menuselection: `Odoo --> Update current module `.
6770
68- .. image :: online-editor/interface-editor-open-file .png
69- :align: center
71+ .. image :: online-editor/update-module .png
72+ :alt: Using the editor to update the current module
7073
71- You can then begin to make your changes. You can save your changes with the menu
72- :menuselection: ` File --> Save .. File ` or by hitting the :kbd: ` Ctrl + S ` shortcut.
74+ .. tip ::
75+ You can also execute the following command in a terminal to update a module:
7376
74- .. image :: online-editor/interface-editor-save-file.png
75- :align: center
77+ .. code-block :: bash
7678
77- If you save a Python file which is under your Odoo server addons path,
78- Odoo will detect it and reload automatically so your changes are reflected immediately,
79- without having to restart the server manually.
79+ odoo-bin -u < comma-separated module names> --stop-after-init
8080
81- .. image :: online-editor/interface-editor-automaticreload.gif
82- :align: center
81+ .. _odoo-sh/editor/commit :
8382
84- However, if the change is a data stored in database, such as the label of a field, or a view,
85- you have to update the according module to apply the change.
86- You can update the module of the currently opened file by using the menu
87- :menuselection: `Odoo --> Update current module `. Note that the file considered as currently opened
88- is the file focused in the text editor, not the file highlighted in the file browser.
83+ Committing and pushing changes
84+ ==============================
8985
90- .. image :: online-editor/interface-editor-update-current-module.png
91- :align: center
86+ To commit and push changes to your GitHub repository:
9287
93- You can also open a terminal and execute the command:
88+ - Open a terminal by going to :menuselection: `File --> New --> Terminal `.
89+ - Change the directory to `~/src/user `.
9490
95- .. code-block :: bash
91+ .. code-block :: bash
9692
97- $ odoo-bin -u < comma-separated module names > --stop-after-init
93+ cd ~ /src/user
9894
99- .. _ odoosh-gettingstarted-online-editor-push :
95+ - State your identity.
10096
101- Commit & Push your changes
102- ==========================
97+ .. code-block :: bash
10398
104- You have the possibility to commit and push your changes to your Github repository.
99+ git config --global user.email " [email protected] " && git config --global user.name " Your Name " 105100
106- * Open a terminal (:menuselection: `File --> New --> Terminal `),
107- * Change the directory to *~/src/user * using :code: `cd ~/src/user `,
108- * Stage your changes using :code: `git add `,
109- * Commit your changes using :code: `git commit `,
110- * Push your changes using :code: `git push https HEAD:<branch> `.
101+ - Stage your changes.
111102
112- In this last command,
103+ .. code-block :: bash
113104
114- * *https * is the name of your *HTTPS * Github remote repository
115- (e.g. https://github.com/username/repository.git),
116- * HEAD is the reference to the latest revision you committed,
117- * <branch> must be replaced by the name of the branch to which you want to push the changes,
118- most-likely the current branch if you work in a development build.
105+ git add
119106
120- .. image :: online-editor/interface-editor-commit-push.png
121- :align: center
107+ - Commit your changes.
122108
123- .. note ::
124- The SSH Github remote is not used because your SSH private key
125- is not hosted in your build containers (for obvious security concerns)
126- nor forwarded through an SSH Agent (as you access this editor through a web browser)
127- and you therefore cannot authenticate yourself to Github using SSH.
128- You have to use the HTTPS remote of your Github repository to push your changes,
129- which is added automatically named as *https * in your Git remotes.
130- You will be prompted to enter your Github username and password.
131- If you activated the two-factor authentication on Github,
132- you can create a `personal access token
133- <https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/> `_
134- and use it as password. Granting the ``repo `` permission suffices.
109+ .. code-block :: bash
110+
111+ git commit
112+
113+ - Push your changes.
114+
115+ .. code-block :: bash
116+
117+ git push https HEAD:< branch>
118+
119+ In this command:
120+
121+ - `https ` is the name of your *HTTPS * GitHub remote repository (e.g.,
122+ `https://github.com/username/repository.git `).
123+ - `HEAD ` is the reference to the latest revision you committed.
124+ - `<branch> ` must be replaced by the name of the branch to which you want to push the changes,
125+ most likely the current branch if you work on a development build.
126+
127+ You will be prompted to input your GitHub username and password. After inputting your credentials,
128+ press enter.
129+
130+ .. image :: online-editor/commit-push.png
131+ :alt: The commands to commit and push changes
132+
133+ .. tip ::
134+ If you activate two-factor authentication for your GitHub account, you can create a `personal
135+ access token <https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token> `_
136+ and use it as a password. `Granting the repo permission <https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/repository-access-and-collaboration/inviting-collaborators-to-a-personal-repository >`_
137+ suffices.
135138
136139.. note ::
137- The Git source folder *~/src/user * is not checked out on a branch but rather on a detached revision:
138- This is because builds work on specific revisions rather than branches.
139- In other words, this means you can have multiple builds on the same branch, but on different revisions.
140+ - It is not possible to authenticate yourself using SSH, as your private SSH key is not hosted in
141+ your build containers for security reasons, nor forwarded through an SSH agent, as you access
142+ the editor through a web browser.
143+ - The source folder `~/src/user ` is not checked out on a branch but rather on a detached
144+ revision. This is because builds work on specific revisions rather than branches, meaning you
145+ can have multiple builds on the same branch, but on different revisions.
140146
141- Once your changes are pushed,
142- according to your :ref: `branch push behavior <odoo-sh/branches/tabs/settings >`,
143- a new build may be created. You can continue to work in the editor you pushed from,
144- as it will have the same revision as the new build that was created, but always make sure to be
145- in an editor of a build using the latest revision of your branch.
147+ Once your changes are pushed, according to your :ref: `branch push behavior
148+ <odoo-sh/branches/tabs/settings>`, a new build may be created. You can continue to work in the editor
149+ you pushed from, as it will have the same revision as the new build that was created. However,
150+ always make sure to be in the editor of a build using the latest revision of your branch.
151+
152+ .. _odoo-sh/editor/consoles :
146153
147154Consoles
148155========
149156
150- You can open Python consoles, which are
151- `IPython interactive shells <https://ipython.readthedocs.io/en/stable/interactive/tutorial.html >`_.
152- One of the most interesting addition to use a Python console
153- rather than a IPython shell within a terminal is the
154- `rich display <https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display >`_
155- capabilities.
156- Thanks to this, you will be able to display objects in HTML.
157+ You can open Python consoles, which are `IPython interactive shells
158+ <https://ipython.readthedocs.io/en/stable/interactive/tutorial.html> `_. Using these Python consoles
159+ (rather than IPython shells within a terminal) allows you to utilize their `rich display
160+ capabilities <https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display> `_ to
161+ display objects in HTML.
157162
158- You can for instance display cells of a CSV file using
159- ` pandas < https://pandas.pydata.org/pandas-docs/stable/tutorials.html >`_ .
163+ .. example ::
164+ The :code: ` Pretty ` class displays lists in a legible way .
160165
161- .. image :: online-editor/interface-editor-console-python-read-csv .png
162- :align: center
166+ .. image :: online-editor/pretty-class .png
167+ :alt: Pretty class example
163168
164- You can also open an Odoo Shell console to play around
165- with the Odoo registry and model methods of your database. You can also directly read or write
166- on your records.
169+ .. tip ::
170+ Using ` pandas < https://pandas.pydata.org/pandas-docs/stable/getting_started/tutorials.html >`_ you
171+ can display:
167172
168- .. warning ::
169- In an Odoo Console, transactions are automatically committed.
170- This means, for instance, that changes in records are applied effectively in the database.
171- If you change the name of a user, the name of the user is changed in your database as well.
172- You therefore should use Odoo consoles carefully on production databases.
173+ - Cells of a CSV file
173174
174- You can use *env * to invoke models of your database registry, e.g. :code: `env['res.users'] `.
175+ .. image :: online-editor/pandas-csv.png
176+ :alt: pandas CSV example
175177
176- .. code-block :: python
178+ - Graphs
179+
180+ .. image :: online-editor/pandas-graph.png
181+ :alt: pandas graph example
177182
178- env[' res.users' ].search_read([], [' name' , ' email' , ' login' ])
179- [{' id' : 2 ,
180- ' login' : ' admin' ,
181- ' name' : ' Administrator' ,
182- 183+ You can open Odoo shell consoles to experiment with the Odoo registry and model methods of your
184+ database. You can also read or write directly on your records.
183185
184- The class :code: `Pretty ` gives you the possibility
185- to easily display lists and dicts in a pretty way, using the
186- `rich display <https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display >`_
187- mentioned above.
186+ .. warning ::
187+ In an Odoo shell console, transactions are automatically committed. This means that changes made
188+ to records are applied to the database. For example, if you change a user's name, it will be
189+ updated in your database as well. Therefore, use Odoo shell consoles carefully on production
190+ databases.
188191
189- .. image :: online-editor/interface-editor-console-odoo-pretty.png
190- :align: center
192+ You can use `env ` to invoke models of your database registry, e.g., :code: `env['res.users'] `.
191193
192- You can also use
193- `pandas <https://pandas.pydata.org/pandas-docs/stable/tutorials.html >`_
194- to display graphs.
194+ .. code-block :: python
195195
196- .. image :: online-editor/interface-editor-console-odoo-graph.png
197- :align: center
196+ env[' res.users' ].search_read([], [' name' , ' email' , ' login' ])
197+ [{' id' : 2 ,
198+ ' login' : ' admin' ,
199+ ' name' : ' Administrator' ,
200+
0 commit comments