Skip to content

Conversation

@ivantodorovich
Copy link
Contributor

@ivantodorovich ivantodorovich commented Nov 20, 2025

Using options like this:

- model: res.country
  options:
    importer:
      odoo_unique_key: id
      override_existing: false
      break_on_error: true
    mapper:
      name: importer.mapper.dynamic

And a sample file like this:

id;code;name
base.af;AF;Afghanistan
  File ".../connector-interfaces/connector_importer/models/record.py", line 94, in import_record
    return importer.run(
           ^^^^^^^^^^^^^
  File ".../connector-interfaces/connector_importer/components/importer.py", line 355, in run
    skip_info = self.skip_it(values, line)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../connector-interfaces/connector_importer/components/importer.py", line 237, in skip_it
    msg += f": {self.unique_key}={values[self.unique_key]}"
                                  ~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'id'

@OCA-git-bot
Copy link
Contributor

Hi @simahawk,
some modules you are maintaining are being modified, check this out!

@ivantodorovich ivantodorovich force-pushed the fix-importer-unique-key branch from f8f4c8f to 467300e Compare November 20, 2025 13:13
Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance to have updated tests? 😁

@ivantodorovich
Copy link
Contributor Author

I didn't find my way into the existing tests :/
anyway it's only for the skip message, so not a big deal IMO

@simahawk
Copy link
Contributor

I didn't find my way into the existing tests :/ anyway it's only for the skip message, so not a big deal IMO

The test is here https://github.com/OCA/connector-interfaces/blob/18.0/connector_importer/tests/test_record_importer.py#L76

The mapper here https://github.com/OCA/connector-interfaces/blob/18.0/connector_importer/tests/fake_components.py#L8

You could simply add a ref key in the source and have an empty id key. This should lead to the situation you are trying to fix.

@ivantodorovich ivantodorovich force-pushed the fix-importer-unique-key branch from 467300e to fa53b46 Compare December 2, 2025 13:38
…f not mapped

```python-trackeback
  File ".../connector-interfaces/connector_importer/models/record.py", line 94, in import_record
    return importer.run(
           ^^^^^^^^^^^^^
  File ".../connector-interfaces/connector_importer/components/importer.py", line 355, in run
    skip_info = self.skip_it(values, line)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../connector-interfaces/connector_importer/components/importer.py", line 237, in skip_it
    msg += f": {self.unique_key}={values[self.unique_key]}"
                                  ~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'id'
```
@ivantodorovich ivantodorovich force-pushed the fix-importer-unique-key branch from fa53b46 to 1fd7394 Compare December 2, 2025 13:38
@ivantodorovich
Copy link
Contributor Author

Unit test added.
Ok to merge, @simahawk ? 🙏🏻

@simahawk
Copy link
Contributor

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-175-by-simahawk-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 9259c45 into OCA:18.0 Dec 11, 2025
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 33a5f31. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants