[已解决]odoo11 form view 根据字段的值显示不同的颜色
-
@鲍永道
是继承的字段selection,我只需要显示即只读状态下显示背景颜色。如下:
(不知道是否还有更好的解决方法)
ps:用原版的css样式,颜色太淡了,不满足需要的可以考虑写css。odoo.define('product.modify_field_value_bgcolor', function (require) { "use strict"; var relational_fields = require('web.relational_fields'); var FieldSelection = relational_fields.FieldSelection; FieldSelection.include({ /** * @override * @private */ _renderReadonly: function () { var formatValue = this._formatValue(this.value); if(formatValue === 'In Process'){ this.$el.addClass('bg-warning'); }else if(formatValue === 'Ready'){ this.$el.addClass('bg-primary'); }else if(formatValue === 'Complete'){ this.$el.addClass('bg-success'); }else if(formatValue === 'Problem'){ this.$el.addClass('bg-danger'); } this.$el.empty().text(formatValue); }, }); });