Online-Editor¶
Die Ansicht Online-Editor ermöglicht die Bearbeitung des Quellcodes Ihrer Builds über einen Webbrowser. Sie bietet zudem die Möglichkeit, Terminals, Python-Konsolen, Odoo-Shell-Konsolen und Jupyter Notebooks zu öffnen.
Sie können auf den Editor eines Builds über die Registerkarte Branches, das Dropdown-Menü für Builds oder durch Hinzufügen von /odoo-sh/editor zur URL des Builds zugreifen (z. B. https://odoo-addons-master-1.dev.odoo.com/odoo-sh/editor).
Bearbeiten des Quellcodes¶
Das Arbeitsverzeichnis setzt sich aus Folgendem zusammen:
.
├── home
│ └── odoo
│ ├── src
│ │ ├── odoo Odoo Community source code
│ │ │ └── odoo-bin Odoo server executable
│ │ ├── enterprise Odoo Enterprise source code
│ │ ├── themes Odoo Themes source code
│ │ └── user Your repository branch source code
│ ├── data
│ │ ├── filestore Database attachments, as well as the files of binary fields
│ │ └── sessions Visitors and users sessions
│ └── logs
│ ├── install.log Database installation logs
│ ├── odoo.log Running server logs
│ ├── update.log Database updates logs
│ └── pip.log Python packages installation logs
Sie können den Quellcode (Dateien unter /src) von Entwicklungs- und Staging-Builds bearbeiten. Bei Produktions-Builds ist der Quellcode schreibgeschützt, da das Anwenden lokaler Änderungen auf einem Produktionsserver keine gute Praxis ist.
Bemerkung
Ihre Änderungen werden nicht auf neue Builds übertragen. Es ist notwendig, sie im Quellcode zu committen, wenn sie dauerhaft bestehen bleiben sollen.
Der Quellcode Ihres GitHub-Repositorys befindet sich unter
/src/user.Der Quellcode von Odoo befindet sich unter:
/src/odoo(https://github.com/odoo/odoo)/src/enterprise(https://github.com/odoo/enterprise)/src/themes(https://github.com/odoo/design-themes)
Um eine Datei im Editor zu öffnen, doppelklicken Sie im Dateibrowser-Panel darauf. Sie können die Datei dann bearbeiten. Um Ihre Änderungen zu speichern, gehen Sie zu oder verwenden Sie die Tastenkombination Ctrl+S.
Wenn Sie eine Python-Datei im Addons-Pfad Ihres Odoo-Servers speichern, erkennt Odoo dies und lädt automatisch neu. Das bedeutet, dass Ihre Änderungen sofort sichtbar sind.
Wenn Ihre Änderungen jedoch in der Datenbank gespeichert sind, wie z. B. die Beschriftung eines Feldes oder eine Ansicht, muss das zugehörige Modul aktualisiert werden, um die Änderungen anzuwenden. Um das Modul der aktuell geöffneten Datei zu aktualisieren, gehen Sie zu .
Tipp
Sie können auch den folgenden Befehl in einem Terminal ausführen, um ein Modul zu aktualisieren:
odoo-bin -u <comma-separated module names> --stop-after-init
Änderungen committen und pushen¶
So committen und pushen Sie Änderungen in Ihr GitHub-Repository:
Öffnen Sie ein Terminal, indem Sie zu gehen.
Wechseln Sie zum Verzeichnis
~/src/user.cd ~/src/userGeben Sie Ihre Identität an.
git config --global user.email "you@example.com" && git config --global user.name "Your Name"
Stagen Sie Ihre Änderungen.
git add
Committen Sie Ihre Änderungen.
git commit
Pushen Sie Ihre Änderungen.
git push https HEAD:<branch>
In diesem Befehl:
httpsist der Name Ihres HTTPS-GitHub-Remote-Repositorys (z. B.https://github.com/username/repository.git).HEADis the reference to the latest revision you committed.<branch>must be replaced by the name of the branch to which you want to push the changes, most likely the current branch if you work on a development build.
You will be prompted to input your GitHub username and password. After inputting your credentials, press enter.
Tipp
If you activate two-factor authentication for your GitHub account, you can create a personal access token and use it as a password. Granting the repo permission suffices.
Bemerkung
It is not possible to authenticate yourself using SSH, as your private SSH key is not hosted in your build containers for security reasons, nor forwarded through an SSH agent, as you access the editor through a web browser.
The source folder
~/src/useris not checked out on a branch but rather on a detached revision. This is because builds work on specific revisions rather than branches, meaning you can have multiple builds on the same branch, but on different revisions.
Once your changes are pushed, according to your branch push behavior, a new build may be created. You can continue to work in the editor you pushed from, as it will have the same revision as the new build that was created. However, always make sure to be in the editor of a build using the latest revision of your branch.
Konsolen¶
You can open Python consoles, which are IPython interactive shells. Using these Python consoles (rather than IPython shells within a terminal) allows you to utilize their rich display capabilities to display objects in HTML.
Example
The Pretty class displays lists in a legible way.
You can open Odoo shell consoles to experiment with the Odoo registry and model methods of your database. You can also read or write directly on your records.
Warnung
In an Odoo shell console, transactions are automatically committed. This means that changes made to records are applied to the database. For example, if you change a user’s name, it will be updated in your database as well. Therefore, use Odoo shell consoles carefully on production databases.
You can use env to invoke models of your database registry, e.g., env['res.users'].
env['res.users'].search_read([], ['name', 'email', 'login'])
[{'id': 2,
'login': 'admin',
'name': 'Administrator',
'email': 'admin@example.com'}]