Skip to content
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

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

trisdoan
Copy link
Contributor

No description provided.

@trisdoan
Copy link
Contributor Author

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 🙏

@giarve
Copy link

giarve commented Oct 29, 2024

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).

Copy link
Collaborator

@sebalix sebalix left a 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.

Comment on lines 246 to 272
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,
)
Copy link
Collaborator

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.

@sebalix sebalix added enhancement New feature or request needs fixing labels Nov 5, 2024
@bosd
Copy link

bosd commented Nov 5, 2024

Thanks so much for working on this!

@sebalix
Copy link
Collaborator

sebalix commented Nov 20, 2024

Hello @trisdoan , any news on this, do you need help?

@trisdoan
Copy link
Contributor Author

Hi @sebalix, I will try to push a patch by the end of this week

Sorry, there were a lot on my plate

@sebalix
Copy link
Collaborator

sebalix commented Nov 20, 2024

@trisdoan no problem, no rush, I was just asking :) Thank you!

@trisdoan trisdoan force-pushed the leverage-odoo-module-migrator branch from d0ed219 to e92ff3f Compare November 25, 2024 07:32
@trisdoan trisdoan requested a review from sebalix November 25, 2024 07:37
@trisdoan
Copy link
Contributor Author

Hello @sebalix , I updated the code 🙏

@sebalix
Copy link
Collaborator

sebalix commented Nov 25, 2024

@trisdoan thank you! Have to test it :) Code LG

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} ",
Copy link
Collaborator

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:

Suggested change
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 👍

Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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

@sebalix sebalix added this to the 0.18 milestone Nov 29, 2024
@trisdoan trisdoan force-pushed the leverage-odoo-module-migrator branch from e92ff3f to 30cd128 Compare December 5, 2024 10:45
@trisdoan trisdoan requested a review from sebalix December 5, 2024 10:51
@sebalix sebalix merged commit e7579cc into OCA:main Dec 16, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants