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

Found multiple matches for field 'State' (2 matches) #27

Open
CarlosAdrianM opened this issue Dec 5, 2019 · 2 comments
Open

Found multiple matches for field 'State' (2 matches) #27

CarlosAdrianM opened this issue Dec 5, 2019 · 2 comments

Comments

@CarlosAdrianM
Copy link

Hi,

When I import the field state_id in res.partner, I do it this way (like any other field):

res_partner_mapping = {
    (........ more fields here)
    'country_id/id' : mapper.const('base.es'),
    'state_id': mapper.map_val('myStateField', my_state_dictionary),
}

But the field state_id is related to country_id, so if my dictionary returns "AV", there is an"AV" state in Spain, and another "AV" state in Italy, so it throws this error: "Found multiple matches for field 'State' (2 matches)"

I would need something like this:
state = fields.Many2one('country',related=city.country)
related=city.country is the important point.

What is the right way to map a related field like state_id?

Thank you

@tfrancoi
Copy link
Owner

Hello,
When you are importing many2one, you should always use the external_id of your record to avoid shush issue. so state_id/id should be the key of your mapping.

If you use state_id, the server will check with the name_search and indeed if the name search return more than one result you'll get this error.

@CarlosAdrianM
Copy link
Author

Same problem although I use state_id/id:

res_partner_mapping = {
    (........ more fields here)
    'country_id/id' : mapper.const('base.es'),
    'state_id/id': mapper.map_val('myStateField', my_state_dictionary),
}

My dictionary is implemented this way:

my_state_dictionary = {
        "03":"A",
        "02":"AB",
        "04":"AL",
        "05":"AV",
}

What am I doing wrong? How must I indicate that the "AV" state is from Spain and not from Italy, for example?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants