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

raise error when found multiple match #643

Open
wants to merge 2 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spp_import_match/models/import_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ def _match_find(self, model, converted_row, imported_row):
domain.append((field_value, "=", row_value))
if not combination_valid:
continue
_logger.info("DOMAIN: %s" % domain)
match = model.search(domain)
if len(match) == 1:
return match
elif len(match) > 1:
raise ValidationError(_("Multiple matches found for '%s'!" % match[0].name))

return model

Expand Down
6 changes: 3 additions & 3 deletions spp_import_match/views/import_match_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
<field name="field_ids">
<tree editable="bottom">
<field name="field_id" options="{'no_create': True}" />
<field name="relation" invisible="1" />
<field name="relation" column_invisible="1" />
<field
name="sub_field_id"
attrs="{'readonly': [('relation', '=', False)], 'required': [('relation', '!=', False)]}"
domain="[('model_id.model', '=', relation)]"
options="{'no_create': True}"
/>
<field name="match_id" invisible="1" />
<field name="model_id" invisible="1" />
<field name="match_id" column_invisible="1" />
<field name="model_id" column_invisible="1" />
<field name="conditional" />
<field
name="imported_value"
Expand Down
Loading