From 8978b0bc8f335a4339e7868343a2767980d29f97 Mon Sep 17 00:00:00 2001 From: Nisha patel Date: Fri, 6 Mar 2020 08:42:00 +0000 Subject: [PATCH] [IMP] web: Show company icon on property(company dependent) field Purpose Of the task is, we need a visual cue on those fields to let the user know that their value is company-specific. So, in this commit On company depedent field we added a building icon with title 'Values set here are company-specific' next to the label in the form view. closes odoo/odoo#47178 Taskid: 2001748 Closes: #47178 Signed-off-by: Yannick Tivisse (yti) --- .../static/src/js/views/form/form_renderer.js | 7 ++++++ addons/web/static/tests/views/form_tests.js | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index 1af48aabf73..bcab9808773 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -817,6 +817,13 @@ var FormRenderer = BasicRenderer.extend({ for: this._getIDForLabel(fieldName), text: text, }); + const field = this.state.fields[fieldName]; + if (field && field.company_dependent) { + $result.append($('', { + class: 'fa fa-sm fa-building-o ml-2', + title: _t("Values set here are company-specific"), + })); + } if (node.tag === 'label') { this._handleAttributes($result, node); } diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 00a73d9a6fd..9b5cad26e75 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -8978,6 +8978,28 @@ QUnit.module('Views', { form.destroy(); }); + + QUnit.test('display building icon for company dependent field', async function (assert) { + assert.expect(2); + this.data.partner.fields.product_id.company_dependent = true; + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '
', + }); + + assert.containsOnce(form, 'label.o_form_label:contains(Product) .fa.fa-sm.fa-building-o', 'Company dependent field shoud have a building icon'); + assert.containsNone(form, 'label.o_form_label:contains(Trululu) .fa.fa-sm.fa-building-o', 'Regular field shoud not have a building icon'); + + form.destroy(); + }); }); });