-
-
Notifications
You must be signed in to change notification settings - Fork 461
Migration to version 14.0
Pedro M. Baeza edited this page Apr 12, 2023
·
27 revisions
- Update yourself with the latest OCA Conventions: https://odoo-community.org/page/contributing
- Subscribe to the mailing list of the related project: https://odoo-community.org/groups
- On the corresponding GitHub issue named "Migration to version 14.0", announce which module(s) you want to migrate
- Install pre-commit
- Bump module version to
14.0.1.0.0
. - Remove any possible migration script from previous version.
- Squash administrative commits (if any) with the previous commit for reducing commit noise. Check https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests#mergesquash-the-commits-generated-by-bots-or-weblate for details.
- If you add new values in a selection field through
selection_add
, you have to define a newondelete=
attribute setting the value to assign for each previous value in case of uninstallation. More info at https://github.com/odoo/odoo/commit/f0481392c6501cae2c38359f526da1eefa451337. Example:selection_field = fields.Selection(selection_add=[("foo", "Foo")], ondelete={"foo": "set null"})
. - In the XML views, the
invisible
andreadonly
attributes no longer support dynamic expressions likestate=='draft'
. When using those, use theattrs
attribute instead. You can only use them for direct context queries likecontext.get('invisible')
. - XML shortcut tags
<act_window>
and<report>
are no longer valid, and must be replaced by its full definition through<record>
tag. Take into account that themodel
attribute of the<record>
tag was transferred to bothmodel
andbinding_model_id
fields before, so you should put both lines on the new<record>
tag. Check an example in https://github.com/odoo/odoo/commit/6835aeb0de6895f7f4d6b23e0b4654465ef21d6a#diff-3b18ee604f9c7367c3d380bcc92f09c390e896f511bbe563f19116297a8ab653L5-R17 - In this versión,
string
attribute of the<button>
elements are directly shown in the list views as text instead of being a tooltip, and thus, it takes a lot of space in screen. You may want to switch totitle
attribute to preserve the old behavior. Example: https://github.com/OCA/project/commit/23fee08ae43258effa39613ce76eb8f4e83650fe - If there are transient models, you have to add explicit security ACLs for them (and optionally record rules).
- If you were overriding
_compute_display_name
for getting a differentdisplay_name
, you should now overridename_get
method and add there the needed@api.depends
. This is not valid though if you want to makedisplay_name
stored for allowing a directname_search
. Other option is to overridename_search
instead. - Remove
size=X
attribute inChar
fields, as it's no longer valid for restricting the size of the strings. -
_name_search
is now returning ids instead of thename_get
style tuple (list of(id, display_name)
): https://github.com/odoo/odoo/commit/1f48130d2bd055835ee428a21922331d126285a3 - Remove
global
field assignation line in record rules, as it's a computed field. - Replace appearances of
.with_context(force_company=...)
with.with_company(...)
. - The access to
ir.actions.*
objects has been removed, so you need to usesudo
or interact via the /web/action/load controller. See odoo/odoo#53335 for more information. You can use_for_xml_id
method when reading an action dictionary. - If you are posting messages in the chatter with a subtype, now the description of the subtype is shown on the UI, so you don't need to repeat such text on the body, and also take this into account for putting good subtypes descriptions (from the functional perspective).
- Check tasks of previous versions if you are migrating from lower versions than v13. It's also recommended to check past migration guides for things not done in previous migrations.
- Add tests to increase code coverage.
- Do the rest of the changes you need to do for making the module works on new version.
-
$REPO
: the OCA repository hosting the module -
$MODULE
: the name of the module you want to migrate -
$USER_ORG
: your GitHub login or organization name
Full process
- On a shell command:
$ git clone https://github.com/OCA/$REPO -b 14.0 $ git checkout -b 14.0-mig-$MODULE origin/14.0 $ git format-patch --keep-subject --stdout origin/14.0..origin/13.0 -- $MODULE | git am -3 --keep $ pre-commit run -a # to run black, isort and prettier (ignore pylint errors at this stage) $ git add -A $ git commit -m "[IMP] $MODULE: black, isort, prettier" --no-verify # it is important to do all formatting in one commit the first time
- Check https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests for a procedure for reducing commits from "OCA Transbot...".
- Adapt the module to the 14.0 version following tasks to do.
- On a shell command, type this for uploading the content to GitHub:
$ git add --all $ git commit -m "[MIG] $MODULE: Migration to 14.0" $ git remote add $USER_ORG git@github.com:$USER_ORG/$REPO.git # This mode requires an SSH key in the GitHub account $ ... or .... $ git remote add $USER_ORG https://github.com/$USER_ORG/$REPO.git # This will required to enter user/password each time $ git push $USER_ORG 14.0-mig-$MODULE --set-upstream
- Follow the link on the command line or check in https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork how to create the pull request.
- For being easily searchable and avoiding to duplicate efforts, please name the pull request following this pattern:
[14.0][MIG] <module>: Migration to 14.0
.
Troubleshooting
Sometimes, when performing these operations, the process can hang due to conflicts on the patches being applied. One of the possible problems is because a patch removes entirely a file and git am
is not able to resolve this. It ends with a message error: ...: patch does not apply
.
If that's your case, you can add --ignore-whitespace
at the end of the git am
command for allowing the patch to be applied, although there will be still conflicts to be solved, but they will be doable through standard conflict resolution system. Starting from the previous situation, you will need to do:
git am --abort
git format-patch --keep-subject --stdout origin/14.0..origin/13.0 -- <module path> | git am -3 --keep --ignore-whitespace
# resolve conflicts (for example git rm <file>)
git add --all
git am --continue