-
Notifications
You must be signed in to change notification settings - Fork 0
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
move import match to base #8
Conversation
@api.onchange("field_id") | ||
def _onchange_field_id(self): | ||
for rec in self: | ||
field_id = rec.field_id.id | ||
fields_list = [] | ||
for field in rec.match_id.field_ids: | ||
new_id_str = str(field.id) | ||
if not new_id_str.find("NewId_'virtual"): | ||
fields_list.append(field.field_id.id) | ||
|
||
duplicate_counter = 0 | ||
for duplicate_field in fields_list: | ||
if duplicate_field == field_id: | ||
duplicate_counter += 1 | ||
|
||
if duplicate_counter > 1: | ||
raise ValidationError(_("Field '%s', already exists!") % rec.field_id.field_description) | ||
|
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.
@api.onchange("field_id") | |
def _onchange_field_id(self): | |
for rec in self: | |
field_id = rec.field_id.id | |
fields_list = [] | |
for field in rec.match_id.field_ids: | |
new_id_str = str(field.id) | |
if not new_id_str.find("NewId_'virtual"): | |
fields_list.append(field.field_id.id) | |
duplicate_counter = 0 | |
for duplicate_field in fields_list: | |
if duplicate_field == field_id: | |
duplicate_counter += 1 | |
if duplicate_counter > 1: | |
raise ValidationError(_("Field '%s', already exists!") % rec.field_id.field_description) | |
_sql_constraints = [ | |
( | |
"field_id_uniq", | |
"UNIQUE(field_id, match_id)", | |
"Field should be unique for each match", | |
) | |
] | |
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.
This is edited, sql_constraints is not good here is we should allow different sub-fields for a one2many field.
required=True, | ||
help="Fields to Match in Importing", | ||
) | ||
|
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.
_sql_constraints = [ | |
( | |
"model_id_uniq", | |
"UNIQUE(model_id)", | |
"Model should be unique!", | |
) | |
] |
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.
This will be removed, as we can have multiple Import Match Configuration for a single model.
available = self.search([("model_name", "=", model_name)]) | ||
field_to_match = [] | ||
for record in available: | ||
field_to_match.append(record.field_ids.mapped("name")) | ||
for f in record.field_ids: | ||
if f.name in fields or f.field_id.name in fields: | ||
result |= record |
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.
available = self.search([("model_name", "=", model_name)]) | |
field_to_match = [] | |
for record in available: | |
field_to_match.append(record.field_ids.mapped("name")) | |
for f in record.field_ids: | |
if f.name in fields or f.field_id.name in fields: | |
result |= record | |
available = self.search([("model_name", "=", model_name)], limit=1) | |
if not available: | |
return [], [] | |
field_to_match = [] | |
for f in available.field_ids: | |
if f.name in fields or f.field_id.name in fields: | |
result |= available | |
field_to_match.append(f.name) | |
Added a boolean field in import match to have an option if matched data will overwitten or ignored. |
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.
Fix the errors in the automated test
No description provided.