diff options
| author | Nisha patel <nit@odoo.com> | 2020-01-30 06:26:18 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2020-02-27 13:16:32 +0000 |
| commit | 4df7594d58f62ed76c3227413b2f335e83198c0b (patch) | |
| tree | 4d94d3a1cb634fc9fb41bb34641fee40e43a804d /addons | |
| parent | f4bcf2c3f922d54bbea93cabedfe60e8c6b1c6c9 (diff) | |
[FIX] web: fix boolean fields display in pivot view
Since formatBoolean returns a jQuery object, boolean fields were
displayed as [Object object] in pivot view.
so fix the issue of checkbox in the pivot view by not calling
fromatValue for boolean instead just set the checkbox element in
in template itself and added test case for checkbox in pivot view.
closes odoo/odoo#46445
Taskid: 2172258
Closes: #44299
X-original-commit: d7d0caf6f599f313687c958c5aff5764c0d23ffd
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/static/src/xml/pivot.xml | 6 | ||||
| -rw-r--r-- | addons/web/static/tests/views/pivot_tests.js | 25 |
2 files changed, 31 insertions, 0 deletions
diff --git a/addons/web/static/src/xml/pivot.xml b/addons/web/static/src/xml/pivot.xml index bfc08e56bd1..0b16af71f0c 100644 --- a/addons/web/static/src/xml/pivot.xml +++ b/addons/web/static/src/xml/pivot.xml @@ -37,6 +37,12 @@ o_negative: cell.value < 0, o_null: cell.value === 0, }" t-esc="_getFormattedVariation(cell)"/> + <div t-elif="props.fields and props.fields[cell.measure].type === 'boolean'" class="o_value"> + <div class="custom-control custom-checkbox"> + <input type="checkbox" t-attf-id="checkbox_{{cell_index}}_{{row_index}}" disabled="disabled" t-att-checked="cell.value" class="custom-control-input"/> + <label t-attf-for="checkbox_{{cell_index}}_{{row_index}}" class="custom-control-label"/> + </div> + </div> <div t-else="1" class="o_value" t-esc="_getFormattedValue(cell)"/> </t> </td> diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js index e3483b4ff1d..8ab46a0ca8d 100644 --- a/addons/web/static/tests/views/pivot_tests.js +++ b/addons/web/static/tests/views/pivot_tests.js @@ -2723,5 +2723,30 @@ QUnit.module('Views', { pivot.destroy(); }); + + QUnit.test('pivot rendering with boolean field', async function (assert) { + assert.expect(4); + + this.data.partner.fields.bar = {string: "bar", type: "boolean", store: true, searchable: true, group_operator: 'bool_or'} + this.data.partner.records = [{id: 1, bar: true, date: '2019-12-14'}, {id: 2, bar: false, date: '2019-05-14'}]; + + var pivot = await createView({ + View: PivotView, + model: "partner", + data: this.data, + arch: '<pivot>' + + '<field name="date" type="row" interval="day"/>' + + '<field name="bar" type="col"/>' + + '<field name="bar" string="SLA status Failed" type="measure"/>' + + '</pivot>', + }); + + assert.strictEqual(pivot.$('tbody tr:contains("2019-12-14")').length, 1, 'There should be a first column'); + assert.ok(pivot.$('tbody tr:contains("2019-12-14") [type="checkbox"]').is(':checked'), 'first column contains checkbox and value should be ticked'); + assert.strictEqual(pivot.$('tbody tr:contains("2019-05-14")').length, 1, 'There should be a second column'); + assert.notOk(pivot.$('tbody tr:contains("2019-05-14") [type="checkbox"]').is(':checked'), "second column should have checkbox that is not checked by default"); + + pivot.destroy(); + }); }); }); |
