开发¶
如果您正在阅读本文,那么您一定已经为Odoo的代码库做出不少贡献,或者十分有兴趣了解如何贡献Odoo。无论您出于何种目的,能偶然来到这里,我们都将为您提供所需的信息!
更多内容
当您准备好了,欢迎阅读 环境设置 部分,开始您的Odoo开发贡献之旅。
环境设置¶
以下说明将帮助您准备好环境,以便在本地修改代码库并将其推送到 GitHub。如果您已完成此步骤,请跳过本节,转到 做出您的第一个贡献。
首先,您需要 创建一个 GitHub 账户。Odoo 使用 GitHub 管理其产品的源代码,您将在这里进行更改并提交以供审核。
访问 github.com/odoo/odoo,点击右上角的 Fork 按钮,在您的账户中创建该仓库的分叉(您自己的副本)。如果您有权访问 github.com/odoo/enterprise,请对其执行相同的操作。这样会创建代码库的一个副本,您可以对其进行更改而不影响主代码库。如果您在 Odoo 工作,请跳过此步骤。
安装 Git。它是一款命令行(文本界面)工具,可以跟踪对文件所做更改的历史记录,更重要的是,可以同时处理该文件的不同版本。这意味着您在进行更改时,不必担心覆盖其他人尚未完成的工作。
验证 Git 的安装目录是否已包含在系统的
PATH变量中。参照 在 Linux 和 macOS 上更新 PATH 变量的指南,使用 Git 的安装路径(默认为
/usr/bin/git)。参照 在 Windows 上更新 PATH 变量的指南,使用 Git 的安装路径(默认为
C:\Program Files\Git)。配置 Git,以便在您未来的贡献中将您标识为作者。请输入您注册 GitHub 时使用的同一个电子邮件地址。
$ git config --global user.name "Your Name" $ git config --global user.email "youremail@example.com"
从源代码安装 Odoo。请确保通过 Git 使用 SSH 获取源代码。
配置 Git 将更改推送到您的分叉仓库,而不是主代码库。如果您在 Odoo 工作,请配置 Git 将更改推送到在 odoo-dev 账户上创建的共享分叉仓库。
在下面的命令中,将
<your_github_account>替换为您创建分叉仓库所用的 GitHub 账户名称。$ cd /CommunityPath $ git remote add dev git@github.com:<your_github_account>/odoo.git
如果您有权访问
odoo/enterprise,请同时配置相关的远程仓库。$ 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
大功告成!您已准备好 进行首次贡献。
做出您的第一个贡献¶
Important
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.
环境设置完成后,您就可以开始为代码库做贡献了。在终端中,进入您从源代码安装 Odoo 的目录,并按照下面的指南操作。
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 18, which corresponds to branch
18.0.Create a new branch starting from branch 18.0. Prefix the branch name with the base branch:
18.0-.... If you work at Odoo, suffix the branch name with your Odoo handle:18.0-...-xyz.Example
$ git switch -c 18.0-fix-invoices
$ git switch -c 18.0-fix-invoices-xyz
Sign the Odoo CLA if not already done. Skip this step if you work at Odoo.
对代码库进行所需的更改。处理代码库时,请遵循以下规则:
提交您的更改。按照 Git 规范 中的说明编写清晰的提交信息。
$ git add . $ git commit
将更改推送到您的分叉仓库,我们已为其添加远程别名
dev。Example
$ git push -u dev 18.0-fix-invoices-xyz
在 GitHub 上发起 PR(拉取请求),提交您的更改以供审核。
根据您的更改所针对的代码库,访问 odoo/odoo 代码库的比较页面 或 odoo/enterprise 代码库的比较页面。
Select 18.0 for the base.
点击 compare across forks。
为 head repository 选择 <your_github_account>/odoo 或 <your_github_account>/enterprise。将
<your_github_account>替换为您创建分叉的 GitHub 账户名称;如果您在 Odoo 工作,则替换为 odoo-dev。检查您的更改,然后点击 Create pull request 按钮。
勾选 Allow edits from maintainer 复选框。如果您在 Odoo 工作,请跳过此步骤。
填写描述,然后再次点击 Create pull request 按钮。
在页面底部,检查可合并状态并解决任何问题。
As soon as your PR is ready for merging, a member of the Odoo team is automatically assigned for review. If the reviewer has questions or remarks, they will post them as comments and you will be notified by email. Those comments must be resolved for the contribution to go forward.
更改获得批准后,审核人员会将其合并,这些更改将在下一次代码更新后对所有 Odoo 用户可用!