온라인 편집기

The Online Editor view allows editing 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 Jupyter Notebooks.

온라인 편집기 전체보기

You can access the editor of a build through the branches tab, the builds dropdown menu, or by adding /odoo-sh/editor to the build’s URL (e.g., https://odoo-addons-master-1.dev.odoo.com/odoo-sh/editor).

소스 코드 편집

다음과 같이 작업 디렉토리가 구성되어 있습니다:

.
├── 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

You can edit the source code (files under /src) of development and staging builds. For production builds, the source code is read-only, because applying local changes on a production server is not a good practice.

참고

To open a file in the editor, double-click it in the file browser panel. You can then edit the file. To save your changes, go to File ‣ Save or use the Ctrl+S keyboard shortcut.

If you save a Python file in your Odoo server’s addons path, Odoo will detect it and reload automatically, meaning your changes are immediately visible.

즉시 확인 가능한 Python 파일로 변경하기

However, if your changes are stored in the database, such as a field’s label or a view, it is necessary to update the related module to apply the changes. To update the module of the currently1 open file, go to Odoo ‣ Update current module.

편집기를 활용하여 현재 모듈 업데이트하기

You can also execute the following command in a terminal to update a module:

odoo-bin -u <comma-separated module names> --stop-after-init

변경 사항 커밋 및 푸시

To commit and push changes to your GitHub repository:

  • Open a terminal by going to File ‣ New ‣ Terminal.

  • 디렉토리를 ~/src/user 로 변경합니다.

    cd ~/src/user
    
  • 신원을 확인하세요.

    git config --global user.email "you@example.com" && git config --global user.name "Your Name"
    
  • 변경 사항을 준비하세요.

    git add
    
  • 변경 사항을 커밋하세요.

    git commit
    
  • 변경 사항을 푸시하세요.

    git push https HEAD:<branch>
    

    이 명령에서:

    • https is the name of your HTTPS GitHub remote repository (e.g., https://github.com/username/repository.git).

    • HEAD is 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.

변경 사항을 커밋하고 푸시하는 명령어

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.

참고

  • 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/user is 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.

콘솔

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.

클래스 예시

pandas 를 활용하여 다음과 같이 표시합니다:

  • CSV 파일에 있는 셀

    pandas CSV 예시
  • 그래프

    pandas 그래프 예시

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.

경고

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'}]