Skip to content

Commit a5074ab

Browse files
author
bosd
committed
Fixup pre-commit relational_import
1 parent a8a150e commit a5074ab

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/odoo_data_flow/lib/relational_import.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,18 @@ def _derive_relation_info(
242242
"""
243243
# Hardcoded mappings for known self-referencing fields
244244
known_self_referencing_fields = {
245-
('product.template', 'optional_product_ids'): ('product_optional_rel', 'product_template_id'),
245+
("product.template", "optional_product_ids"): (
246+
"product_optional_rel",
247+
"product_template_id",
248+
),
246249
# Add more known self-referencing fields here as needed
247250
}
248-
251+
249252
# Check if we have a known mapping for this field
250253
key = (model, field)
251254
if key in known_self_referencing_fields:
252255
return known_self_referencing_fields[key]
253-
256+
254257
# Derive relation table name (typically follows pattern: model1_model2_rel)
255258
# with models sorted alphabetically for canonical naming
256259
models = sorted([model.replace(".", "_"), related_model_fk.replace(".", "_")])
@@ -716,15 +719,17 @@ def run_write_o2m_tuple_import(
716719
# Check if the field with /id suffix exists (common for relation fields)
717720
field_with_id = f"{field}/id"
718721
if field_with_id in source_df.columns:
719-
log.debug(f"Using field '{field_with_id}' instead of '{field}' for O2M filtering")
722+
log.debug(
723+
f"Using field '{field_with_id}' instead of '{field}' for O2M filtering"
724+
)
720725
actual_field = field_with_id
721726
else:
722727
log.error(
723728
f"Field '{field}' not found in source DataFrame. "
724729
f"Available columns: {list(source_df.columns)}"
725730
)
726731
return False
727-
732+
728733
o2m_df = source_df.filter(pl.col(actual_field).is_not_null())
729734

730735
for record in o2m_df.iter_rows(named=True):

0 commit comments

Comments
 (0)