[FIX] base_import: unable to select name, external id or db id separatly

Before this commit, when selecting the field to import, the name, external
id and database id could not be selected separatly while they should.

This commit fixes that by comparing the full field path instead of the id
of the fields.

closes odoo/odoo#135482

X-original-commit: 587ee0797bd0075dc7d3a0393ec95360c8ab0770
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
This commit is contained in:
Bastien Fafchamps (bafa)
2023-09-14 17:08:02 +00:00
parent e6b353d6df
commit e1cf7e93c9
3 changed files with 16 additions and 6 deletions
@@ -186,9 +186,8 @@ export class ImportAction extends Component {
// Fields
//--------------------------------------------------------------------------
onFieldChanged(column, fieldId) {
const selection = this.model.fields.find((f) => f.id === fieldId);
this.model.setColumnField(column, selection);
onFieldChanged(column, fieldInfo) {
this.model.setColumnField(column, fieldInfo);
}
isFieldSet(column) {
@@ -46,7 +46,7 @@ export class ImportDataContent extends Component {
makeChoices(fields) {
return fields.map((field) => ({
label: field.label,
value: field.id,
value: field.fieldPath,
}));
}
@@ -83,4 +83,15 @@ export class ImportDataContent extends Component {
getCommentClass(column, comment, index) {
return `alert-${comment.type} ${index < column.comments.length - 1 ? "mb-2" : "mb-0"}`;
}
onFieldChanged(column, fieldPath) {
const fields = [
...column.fields.basic,
...column.fields.suggested,
...column.fields.additional,
...column.fields.relational,
];
const fieldInfo = fields.find((f) => f.fieldPath === fieldPath);
this.props.onFieldChanged(column, fieldInfo);
}
}
@@ -60,9 +60,9 @@
</td>
<td>
<SelectMenu
value="column.fieldInfo and column.fieldInfo.id"
value="column.fieldInfo ? column.fieldInfo.fieldPath : undefined"
groups="getGroups(column)"
onSelect="(fieldId) => this.props.onFieldChanged(column, fieldId)"
onSelect="(fieldPath) => this.onFieldChanged(column, fieldPath)"
searchPlaceholder="searchPlaceholder"
togglerClass="column.fieldInfo ? 'ps-1' : ''"
>