-
Notifications
You must be signed in to change notification settings - Fork 1
Fix category_id import by properly handling many2many relationships a… #134
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
Conversation
Summary of ChangesHello @bosd, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the Odoo data import process, specifically addressing how many-to-many relationships are managed. It introduces a more robust mechanism to determine relational table and field names by first querying Odoo's internal metadata, then falling back to conventional derivation. Crucially, it updates the import logic to correctly use Odoo's ORM Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request significantly improves the import logic for many-to-many relationships by using Odoo's standard ORM write method, which is a great enhancement. The changes also add robustness by querying Odoo for relation metadata and handling field/id column name conventions. My review identified a few issues with the new implementation: a bug in determining the owning model's foreign key, a regression in the fallback logic for deriving relation table names, and a logical error in DataFrame processing within the _create_relational_records function. I have provided specific code suggestions to address these points.
| original_links_df = original_links_df.with_columns( | ||
| pl.col(field).str.split(",") | ||
| ).explode(field) | ||
| original_links_df = original_links_df.rename({field: "related_external_id"}) | ||
| pl.col(actual_field_name).str.split(",") | ||
| ).explode(actual_field_name) | ||
| original_links_df = original_links_df.rename( | ||
| {actual_field_name: "related_external_id"} | ||
| ) |
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.
The link_df DataFrame passed into this function has already been processed by _prepare_link_dataframe, which includes splitting and exploding the comma-separated IDs from the source file. Therefore, the actual_field_name column in link_df already contains single, individual external IDs, not comma-separated strings.
The code here incorrectly attempts to split and explode this column again. While this might not crash, it is redundant and logically incorrect, as it's based on a wrong assumption about the DataFrame's schema at this point. This should be simplified to just rename the columns.
original_links_df = link_df.select(["external_id", actual_field_name]).rename(
{"external_id": "parent_external_id", actual_field_name: "related_external_id"}
)f3ed0ac to
8361c56
Compare
|
/gemini review |
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.
Code Review
This pull request introduces significant improvements for handling many-to-many relationships, particularly by querying Odoo for relation metadata before falling back to name derivation, and by correctly using Odoo's write command for m2m updates. The changes are robust and well-implemented. My review focuses on opportunities to reduce code duplication, enhance performance with more idiomatic Polars usage, and refine the test suite for better clarity and precision.
aec323c to
7919d3e
Compare
…nd field name resolution
7919d3e to
eb28dd6
Compare
…nd field name resolution