Development¶
If you are reading this, chances are that you are interested in learning how to contribute to the codebase of Odoo. Whether that's the case or you landed here by accident, we've got you covered!
When you feel ready, jump to the Thiết lập môi trường section to begin your journey in contributing to the development of Odoo.
Thiết lập môi trường¶
The instructions below help you prepare your environment for making local changes to the codebase and then push them to GitHub. Skip this section and go to Make your first contribution if you have already completed this step.
First, you need to create a GitHub account. Odoo uses GitHub to manage the source code of its products, and this is where you will make your changes and submit them for review.
Tạo một khóa SSH mới và đăng ký nó vào tài khoản GitHub của bạn.
Go to github.com/odoo/odoo and click on the Fork button in the top right corner to create a fork (your own copy) of the repository on your account. Do the same with github.com/odoo/enterprise if you have access to it. This creates a copy of the codebase to which you can make changes without affecting the main codebase. Skip this step if you work at Odoo.
Cài đặt Git. Đây là một công cụ dòng lệnh (a text interface) cho phép theo dõi lịch sử các thay đổi được thực hiện đối với một tệp và, quan trọng hơn, làm việc trên nhiều phiên bản khác nhau của tệp đó cùng một lúc. Điều này có nghĩa là bạn không cần phải lo lắng về việc ghi đè lên công việc đang chờ xử lý của người khác khi thực hiện thay đổi.
Kiểm tra rằng thư mục cài đặt của Git đã được thêm vào biến
PATHcủa hệ thống.Làm theo hướng dẫn cập nhật biến PATH trên Linux và macOS với đường dẫn cài đặt của Git (mặc định là
/usr/bin/git).Làm theo hướng dẫn cập nhật biến PATH trên Windows với đường dẫn cài đặt của Git (mặc định là
C:\Program Files\Git).Cấu hình Git để xác định bạn là tác giả của những đóng góp trong tương lai. Nhập cùng địa chỉ email mà bạn đã sử dụng để đăng ký trên GitHub.
$ git config --global user.name "Your Name" $ git config --global user.email "youremail@example.com"
Install Odoo from the sources. Make sure to fetch the sources through Git with SSH.
Configure Git to push changes to your fork(s) rather than to the main codebase. If you work at Odoo, configure Git to push changes to the shared forks created on the account odoo-dev.
In the command below, replace
<your_github_account>with the name of the GitHub account on which you created the fork(s).$ cd /CommunityPath $ git remote add dev git@github.com:<your_github_account>/odoo.git
If you have access to
odoo/enterprise, configure the related remote too.$ cd /EnterprisePath $ git remote add dev git@github.com:<your_github_account>/enterprise.git
$ cd /CommunityPath $ git remote add dev git@github.com:odoo-dev/odoo.git $ git remote set-url --push origin you_should_not_push_on_this_repository $ cd /EnterprisePath $ git remote add dev git@github.com:odoo-dev/enterprise.git $ git remote set-url --push origin you_should_not_push_on_this_repository
That's it! You are ready to make your first contribution.
Make your first contribution¶
Quan trọng
Odoo development can be challenging for beginners. We recommend you to be knowledgeable enough to code a small module before contributing. If that is not the case, take some time to go through the developer tutorials to fill in the gaps.
Một số bước trong hướng dẫn này yêu cầu bạn phải quen thuộc với Git. Dưới đây là một số hướng dẫn và một khóa đào tạo tương tác nếu bạn gặp khó khăn ở bước nào đó.
Now that your environment is set up, you can start contributing to the codebase. In a terminal, navigate to the directory where you installed Odoo from sources and follow the guide below.
Choose the version of Odoo to which you want to make changes. Keep in mind that contributions targeting an unsupported version of Odoo are not accepted. This guide assumes that the changes target Odoo 17, which corresponds to branch
17.0.Tạo một branch mới bắt đầu từ branch 17.0. Thêm tiền tố branch cơ sở vào tên branch:
17.0-.... Nếu bạn làm việc tại Odoo, thêm hậu tố là tên viết tắt Odoo của bạn vào tên branch:17.0-...-xyz.Example
$ git switch -c 17.0-fix-invoices
$ git switch -c 17.0-fix-invoices-xyz
Sign the Odoo CLA if not already done. Skip this step if you work at Odoo.
Make the desired changes to the codebase. When working on the codebase, follow these rules:
Keep your changes focused and specific. It is best to work on one particular feature or bug fix at a time rather than tackle multiple unrelated changes simultaneously.
Respect the stable policy when working in another branch than
master.Follow the coding guidelines.
Test your changes thoroughly and write tests to ensure that everything is working as expected and that there are no regressions or unintended consequences.
Commit các thay đổi của bạn. Viết một commit message rõ ràng theo hướng dẫn trong nguyên tắc Git.
$ git add . $ git commit
Push your change to your fork, for which we added the remote alias
dev.Example
$ git push -u dev 17.0-fix-invoices-xyz
Mở một PR trên GitHub để gửi các thay đổi của bạn để xem xét.
Go to the compare page of the odoo/odoo codebase, or the compare page of the odoo/enterprise codebase, depending on which codebase your changes target.
Chọn 17.0 làm base.
Nhấp vào compare across forks.
Select <your_github_account>/odoo or <your_github_account>/enterprise for the head repository. Replace
<your_github_account>with the name of the GitHub account on which you created the fork or by odoo-dev if you work at Odoo.Xem lại các thay đổi của bạn và nhấp vào nút Create pull request.
Đánh dấu vào ô Allow edits from maintainer. Bỏ qua bước này nếu bạn làm việc tại Odoo.
Hoàn thành phần mô tả và nhấp lại vào nút Create pull request.
Ở cuối trang, kiểm tra trạng thái khả năng merge và xử lý mọi vấn đề phát sinh.
Ngay khi PR của bạn sẵn sàng để merge, một thành viên của đội ngũ Odoo sẽ tự động được phân công để xem xét. Nếu người xem xét có câu hỏi hoặc nhận xét, họ sẽ đăng chúng dưới dạng bình luận và bạn sẽ được thông báo qua email. Những bình luận đó phải được giải quyết thì đóng góp mới có thể tiếp tục.
Once your changes are approved, the review merges them and they become available for all Odoo users after the next code update!