-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] integrate with odoo-module-migrator #53
Conversation
Hello @sebalix, after watching your clip on OCA channel about the tool, I started this work. Thank you for your amazing work and hope you review this 🙏 |
It is running fine!! However, it still prints the message to create the migration commit manually, which is not necessary when using this module. The user needs to know how to amend to the commit or rebase though, because pre-commit is just ignored (like doing the migration commit with --no-verify). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution, it was in the roadmap so I'm glad to see a PR about this!
About the implementation, I would prefer to make this dependency optional, so a method that could check if odoo-module-migrator
exists is welcome. Then this method could be used here and there to adapt the workflow (as said by @giarve , we could hide/replace some tips depending on this).
As it's an optional dependency, updating the Installing section in the README is welcome too for users that want to benefit from this tool.
oca_port/migrate_addon.py
Outdated
def _apply_code_pattern(self): | ||
print("Apply code pattern...") | ||
subprocess.run( | ||
f"odoo-module-migrate -i {self.app.source_version} -t {self.app.target_version} --modules {self.app.addon} --directory {self.app.repo_path} ", | ||
shell=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make odoo-module-migrator
dependency optional, if it's found in the runtime then oca-port
can leverage it.
I found out that odoo-module-migrator
is available only for Python 3.10+, and I prefer to stay compatible with older Python releases if possible.
Thanks so much for working on this! |
Hello @trisdoan , any news on this, do you need help? |
Hi @sebalix, I will try to push a patch by the end of this week Sorry, there were a lot on my plate |
@trisdoan no problem, no rush, I was just asking :) Thank you! |
d0ed219
to
e92ff3f
Compare
Hello @sebalix , I updated the code 🙏 |
@trisdoan thank you! Have to test it :) Code LG |
oca_port/migrate_addon.py
Outdated
def _apply_code_pattern(self): | ||
print("Apply code pattern...") | ||
subprocess.run( | ||
f"odoo-module-migrate -i {self.app.source_version} -t {self.app.target_version} --modules {self.app.addon} --directory {self.app.repo_path} ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be compatible with modules not only located at the root folder, I needed to change this:
f"odoo-module-migrate -i {self.app.source_version} -t {self.app.target_version} --modules {self.app.addon} --directory {self.app.repo_path} ", | |
f"odoo-module-migrate -i {self.app.source_version} -t {self.app.target_version} --modules {self.app.addon} --directory {self.app.addons_rootdir} ", |
self.app.addons_rootdir
= odoo/local-src
if your module is located in odoo/local-src/my_module/
. E.g the command I'm using in a private project:
$ oca-port origin/master origin/18.0 --source-version=14.0 odoo/local-src/my_module --upstream-org=camptocamp --verbose
Otherwise it is working really fine 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe another question: could we use instead the API of odoo-module-migrator
, by using directly the Migration
class like it's done by the CLI here: https://github.com/OCA/odoo-module-migrator/blob/master/odoo_module_migrate/__main__.py#L143-L156
So we avoid a call to subprocess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sebalix, it's actually a good idea, I updated the code
I spare the option Skip removing migration folder as I am not sure how to best implement it, thinking of adding new attribute skip_remove_migration_folder
in object App, how does it sound to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the defaults of OCA: we want to remove them. As it's a change commited, user can still revert it in case he wants to keep it. But it's an exception, we often want to remove them anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally agree, so current state is ready for review
e92ff3f
to
30cd128
Compare
No description provided.