[IMP] web: Allow to hide the currency symbol on FieldMonetary widget
In some cases, we want to use the regular FieldMonetary widget (performing the amount rounding correctly) but without displaying the currency symbol since the currency code is displayed elsewhere. This is needed because some currencies are using the same currency symbol like USD / MXN. Task: 2555114 Part-of: odoo/odoo#91448
This commit is contained in:
@@ -1258,7 +1258,7 @@ var FieldMonetary = NumericField.extend({
|
||||
// Prepare and add the input
|
||||
var def = this._prepareInput(this.$input).appendTo(this.$el);
|
||||
|
||||
if (this.currency) {
|
||||
if (this.currency && !this.nodeOptions.no_symbol) {
|
||||
// Prepare and add the currency symbol
|
||||
var $currencySymbol = $('<span>', {text: this.currency.symbol});
|
||||
if (this.currency.position === "after") {
|
||||
|
||||
@@ -5782,6 +5782,33 @@ QUnit.module('basic_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('monetary field without currency symbol', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var form = await createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:'<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<field name="qux" widget="monetary" options="{\'no_symbol\': True}"/>' +
|
||||
'<field name="currency_id" invisible="1"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
res_id: 5,
|
||||
session: {
|
||||
currencies: _.indexBy(this.data.currency.records, 'id'),
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.form.clickEdit(form);
|
||||
|
||||
// Non-breaking space between the currency and the amount
|
||||
assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), "9.10", "The currency symbol is not displayed");
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('monetary field in editable list view', async function (assert) {
|
||||
assert.expect(9);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user