[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) <yti@odoo.com>
This commit is contained in:
committed by
Yannick Tivisse
parent
fe74b0b6f4
commit
8978b0bc8f
@@ -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($('<span>', {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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: '<form>' +
|
||||
'<group>' +
|
||||
'<field name="trululu"/>' +
|
||||
'<field name="product_id"/>' +
|
||||
'</group>' +
|
||||
'</form>',
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user