Trình soạn thảo online¶
Tổng quan¶
The online editor allows you to edit the source code of your builds from a web browser. It also gives you the possibility to open terminals, Python consoles, Odoo Shell consoles and Notebooks.

You can access the editor of a build through the branches tabs, the builds dropdown menu or by adding /odoo-sh/editor to your build domain name (e.g. https://odoo-addons-master-1.dev.odoo.com/odoo-sh/editor).
Chỉnh sửa mã nguồn¶
Thư mục làm việc bao gồm các thư mục sau:
.
├── 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
Bạn có thể chỉnh sửa mã nguồn (các tệp trong thư mục /src) trong bản dựng phát triển và bản dựng staging.
Ghi chú
Những thay đổi của bạn sẽ không được chuyển sang bản dựng mới, bạn phải commit chúng vào mã nguồn nếu muốn chúng được lưu lại.
Đối với bản dựng production, mã nguồn ở chế độ chỉ đọc vì không nên áp dụng các thay đổi cục bộ trên máy chủ production.
Mã nguồn của kho lưu trữ Github của bạn nằm trong /src/user,
Mã nguồn của Odoo nằm trong
/src/odoo (odoo/odoo),
/src/enterprise (odoo/enterprise),
/src/themes (odoo/design-themes).
Để mở một tệp trong trình soạn thảo, chỉ cần nhấp đúp vào tệp đó trong bảng duyệt tệp ở bên trái.

You can then begin to make your changes. You can save your changes with the menu
or by hitting the Ctrl+S shortcut.
Nếu bạn lưu tệp Python nằm trong đường dẫn addon máy chủ Odoo, thì Odoo sẽ phát hiện tệp đó và tự động tải lại để các thay đổi của bạn có hiệu lực ngay lập tức mà không cần phải khởi động lại máy chủ theo cách thủ công.

However, if the change is a data stored in database, such as the label of a field, or a view, you have to update the according module to apply the change. You can update the module of the currently opened file by using the menu
. Note that the file considered as currently opened is the file focused in the text editor, not the file highlighted in the file browser.
Bạn cũng có thể mở terminal và thực hiện lệnh:
$ odoo-bin -u <comma-separated module names> --stop-after-init
Commit & Push thay đổi của bạn¶
Bạn có thể commit và push những thay đổi của mình lên kho lưu trữ Github.
Open a terminal (
),Change the directory to ~/src/user using
cd ~/src/user
,Stage your changes using
git add
,Commit your changes using
git commit
,Push your changes using
git push https HEAD:<branch>
.
Trong lệnh cuối cùng này,
https is the name of your HTTPS Github remote repository (e.g. https://github.com/username/repository.git),
HEAD là tham chiếu đến bản sửa đổi mới nhất mà bạn đã commit,
<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 in a development build.

Ghi chú
The SSH Github remote is not used because your SSH private key
is not hosted in your build containers (for obvious security concerns)
nor forwarded through an SSH Agent (as you access this editor through a web browser)
and you therefore cannot authenticate yourself to Github using SSH.
You have to use the HTTPS remote of your Github repository to push your changes,
which is added automatically named as https in your Git remotes.
You will be prompted to enter your Github username and password.
If you activated the two-factor authentication on Github,
you can create a personal access token
and use it as password. Granting the repo
permission suffices.
Ghi chú
Thư mục nguồn Git ~/src/user không được checkout trên một nhánh mà trong một bản sửa đổi tách biệt: Điều này là do các bản dựng hoạt động trong những bản sửa đổi cụ thể mà không phải các nhánh. Nói cách khác, điều này có nghĩa là bạn có thể có nhiều bản dựng trên cùng một nhánh, nhưng nằm trong các bản sửa đổi khác nhau.
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, but always make sure to be in an editor of a build using the latest revision of your branch.
Bảng điều khiển¶
You can open Python consoles, which are IPython interactive shells. One of the most interesting addition to use a Python console rather than a IPython shell within a terminal is the rich display capabilities. Thanks to this, you will be able to display objects in HTML.
You can for instance display cells of a CSV file using pandas.

Bạn cũng có thể mở bảng điều khiển Odoo Shell để dùng thử Odoo registry và các phương pháp mô hình của cơ sở dữ liệu. Bạn cũng có thể trực tiếp đọc hoặc ghi vào bản ghi của mình.
Cảnh báo
Trong Bảng điều khiển Odoo, các giao dịch được tự động commit. Ví dự, điều này có nghĩa là các thay đổi trong bản ghi được áp dụng hiệu quả trong cơ sở dữ liệu. Nếu bạn thay đổi tên người dùng, thì tên người dùng cũng sẽ được thay đổi trong cơ sở dữ liệu của bạn. Do đó, bạn nên sử dụng bảng điều khiển Odoo thật cẩn thận trên cơ sở dữ liệu production.
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'}]
The class Pretty
gives you the possibility
to easily display lists and dicts in a pretty way, using the
rich display
mentioned above.

You can also use pandas to display graphs.
