Skip to content

Commit

Permalink
fix: exportfile xml: include ids for records without reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Tardo committed Dec 28, 2024
1 parent c6d27dc commit ac64b1b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

**11.7.3**

```
FIX: exportfile xml: Include ids for records without reference
```

**11.7.2**

```
Expand Down
14 changes: 7 additions & 7 deletions _locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"from-x": "The rect X point",
"from-y": "The rect Y point",
"height": "The rect height",
"width": "The rect height"
"width": "The rect width"
},
"definition": "Clear canvas",
"detail": "Clear canvas"
Expand All @@ -27,7 +27,7 @@
"width": "The canvas width"
},
"definition": "Create 2D Window",
"detail": "Destroy 2D Window"
"detail": "Create 2D Window"
},
"cmd2DDestroyWindow": {
"args": {
Expand All @@ -43,7 +43,7 @@
"from-y": "The line from Y point",
"to-x": "The line to X point",
"to-y": "The line to Y point",
"width": "The line color"
"width": "The line width"
},
"definition": "Draw a line",
"detail": "Draw a line"
Expand All @@ -53,7 +53,7 @@
"canvas": "The canvas",
"color": "The rect color",
"height": "The rect height",
"width": "The rect color",
"width": "The rect width",
"x": "The rect X point",
"y": "The rect Y point"
},
Expand Down Expand Up @@ -298,7 +298,7 @@
},
"definition": "Exports the command result to a text/json file",
"detail": "Exports the command result to a text/json file.",
"invalidValue": "Invalid value: need a recordset with csv and xml",
"invalidValue": "Invalid value: must be a recordset with csv and xml",
"resultExported": "Command result exported to '{{filename}}' file"
},
"cmdExportVar": {
Expand Down Expand Up @@ -849,8 +849,8 @@
"args": {
"num": "The number of decimals"
},
"definition": "Rounds a number DOWN to the nearest integer",
"detail": "Rounds a number DOWN to the nearest integer"
"definition": "Rounds a number UP to the nearest integer",
"detail": "Rounds a number UP to the nearest integer"
},
"funcFloor": {
"args": {
Expand Down
2 changes: 1 addition & 1 deletion _locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"width": "El ancho del lienzo"
},
"definition": "Crear ventana 2D",
"detail": "Destruir ventana 2D"
"detail": "Crear ventana 2D"
},
"cmd2DDestroyWindow": {
"args": {
Expand Down
12 changes: 10 additions & 2 deletions src/js/page/odoo/net_utils/xml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import callModelMulti from '@odoo/osv/call_model_multi';
import callModel from '@odoo/osv/call_model';
import isNumber from '@trash/utils/is_number';
import type Recordset from '@terminal/core/recordset';

const IGNORED_FIELDS = [
Expand Down Expand Up @@ -44,7 +45,14 @@ async function getXMLIds(model: string, ids: $ReadOnlyArray<number>, context: ?{
context,
)
);
return Object.fromEntries(metadatas.map((item) => [item.id, item.xmlid]));
const xmlIds = Object.fromEntries(metadatas.map((item) => [item.id, item.xmlid]));
for (const id of ids) {
if (typeof xmlIds[id] === 'undefined' || xmlIds[id] === false) {
xmlIds[id] = id;
}
}
debugger;
return xmlIds;
}

function createRecordField(model: string, field_name: string, value: mixed, field_info: {[string]: string | number}, field_xmlids: ?{[string]: $ReadOnlyArray<string>}): string | void {
Expand Down Expand Up @@ -72,7 +80,7 @@ function createRecordField(model: string, field_name: string, value: mixed, fiel
if (xmlids_ids.length === 1 && field_info.type !== 'many2many' && field_info.type !== 'one2many') {
return `\t\t<field name="${field_name}" ref="${xmlids_ids[0]}"/>\n`;
} else {
const refs = xmlids_ids.filter((item) => item).map((item) => `Command.link(ref('${item}'))`);
const refs = xmlids_ids.filter((item) => item).map((item) => isNumber(item) ? `Command.link(${item})` : `Command.link(ref('${item}'))`);
if (refs.length === 0) {
return;
}
Expand Down

0 comments on commit ac64b1b

Please sign in to comment.