[FIX] spreadsheet: fetch currency field
Get to a list view where there's a monetary field AND the related currency
field in the same list.
Then insert the list in a spreadsheet.
=> Either the currency format is not fetched or the currency name, depending
on the order in the list.
Bug introduced by 8777973e
opw-3770057
closes odoo/odoo#157623
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
This commit is contained in:
@@ -85,6 +85,7 @@ export class ListDataSource extends OdooViewsDataSource {
|
||||
spec[field.name] = {};
|
||||
spec[field.currency_field] = {
|
||||
fields: {
|
||||
...spec[field.currency_field]?.fields,
|
||||
name: {}, // currency code
|
||||
symbol: {},
|
||||
decimal_places: {},
|
||||
@@ -95,7 +96,12 @@ export class ListDataSource extends OdooViewsDataSource {
|
||||
case "many2one":
|
||||
case "many2many":
|
||||
case "one2many":
|
||||
spec[field.name] = { fields: { display_name: {} } };
|
||||
spec[field.name] = {
|
||||
fields: {
|
||||
display_name: {},
|
||||
...spec[field.name]?.fields,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
spec[field.name] = field;
|
||||
|
||||
@@ -549,6 +549,34 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"list with both a monetary field and the related currency field",
|
||||
async function (assert) {
|
||||
const { model } = await createSpreadsheetWithList({
|
||||
columns: ["pognon", "currency_id"],
|
||||
});
|
||||
setCellContent(model, "A1", '=ODOO.LIST(1, 1, "pognon")');
|
||||
setCellContent(model, "A2", '=ODOO.LIST(1, 1, "currency_id")');
|
||||
await waitForDataSourcesLoaded(model);
|
||||
assert.strictEqual(getEvaluatedCell(model, "A1").formattedValue, "74.40€");
|
||||
assert.strictEqual(getEvaluatedCell(model, "A2").value, "EUR");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"list with both a monetary field and the related currency field",
|
||||
async function (assert) {
|
||||
const { model } = await createSpreadsheetWithList({
|
||||
columns: ["currency_id", "pognon"],
|
||||
});
|
||||
setCellContent(model, "A1", '=ODOO.LIST(1, 1, "pognon")');
|
||||
setCellContent(model, "A2", '=ODOO.LIST(1, 1, "currency_id")');
|
||||
await waitForDataSourcesLoaded(model);
|
||||
assert.strictEqual(getEvaluatedCell(model, "A1").formattedValue, "74.40€");
|
||||
assert.strictEqual(getEvaluatedCell(model, "A2").value, "EUR");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"List record limit is computed during the import and UPDATE_CELL",
|
||||
async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user