Skip to content
Permalink
Browse files

[IMP] web, *: add a description to generic widgets

A `description` key has been added on AbstractField and all generic
field widgets ; it is used to display a more user friendly name (both in
the webclient and in Studio).

Non-generic field widgets have an empty string as description.

Related task 1918327

Co-authored-by: Mohammed Shekha <msh@openerp.com>
  • Loading branch information...
2 people authored and mge-odoo committed Jan 4, 2019
1 parent c88fdf5 commit 8bea14fb8fb803c80dc247d17ba3c6a342d9d8e2
@@ -76,6 +76,7 @@ var SectionAndNoteListRenderer = ListRenderer.extend({
// to be sure this custom code will only impact selected fields having the widget
// and not applied to any other existing ListRenderer.
var SectionAndNoteFieldOne2Many = FieldOne2Many.extend({
description: "",
/**
* We want to use our custom renderer for the list.
*
@@ -9,6 +9,7 @@ var BarcodeEvents = require('barcodes.BarcodeEvents').BarcodeEvents;
// Field in which the user can both type normally and scan barcodes

var FieldFloatScannable = basicFields.FieldFloat.extend({
description: "",
events: _.extend({}, basicFields.FieldFloat.prototype.events, {
// The barcode_events component intercepts keypresses and releases them when it
// appears they are not part of a barcode. But since released keypresses don't
@@ -137,6 +137,7 @@ var Many2ManyAttendee = FieldMany2ManyTags.extend({
// as this widget is model dependant (rpc on res.partner), use it in another
// context probably won't work
// supportedFieldTypes: ['many2many'],
description: "",
tag_template: "Many2ManyAttendeeTag",
specialData: "_fetchSpecialAttendeeStatus",

@@ -85,6 +85,7 @@ var widgetName = 'timesheet_uom' in session ?
session.timesheet_uom.timesheet_widget : 'float_factor';
var FieldTimesheetUom = widgetName === 'float_toggle' ?
FieldTimesheetToggle : (fieldRegistry.get(widgetName) || FieldTimesheetFactor);
FieldTimesheetUom.prototype.description = "";

fieldRegistry.add('timesheet_uom', FieldTimesheetUom);

@@ -51,6 +51,7 @@ BasicModel.include({
});

var FieldMany2ManyTagsEmail = M2MTags.extend({
description: "",
tag_template: "FieldMany2ManyTagsEmail",
fieldsToFetch: _.extend({}, M2MTags.prototype.fieldsToFetch, {
email: {type: 'char'},
@@ -16,6 +16,7 @@ var FieldChar = basic_fields.FieldChar;
* "website" and "image" fields of records of this model).
*/
var FieldAutocomplete = FieldChar.extend(AutocompleteMixin, {
description: "",
className: 'o_field_partner_autocomplete',
debounceSuggestions: 400,
resetOnAnyFieldChange: true,
@@ -9,6 +9,7 @@ var field_registry = require('web.field_registry');
var _t = core._t;

var PartnerField = FieldMany2One.extend(AutocompleteMixin, {
description: "",
jsLibs: [
'/partner_autocomplete/static/lib/jsvat.js'
],
@@ -30,7 +30,6 @@ odoo.define('web.AbstractField', function (require) {
* @module web.AbstractField
*/

var ajax = require('web.ajax');
var field_utils = require('web.field_utils');
var Widget = require('web.Widget');

@@ -71,6 +70,12 @@ var AbstractField = Widget.extend({
*/
supportedFieldTypes: [],

/**
* To override to give a user friendly name to the widget.
*
* @type <string>
*/
description: "",
/**
* Abstract field class
*
@@ -23,6 +23,7 @@ var field_utils = require('web.field_utils');

var qweb = core.qweb;
var _t = core._t;
var _lt = core._lt;

var TranslatableFieldMixin = {
//--------------------------------------------------------------------------
@@ -406,6 +407,7 @@ var NumericField = InputField.extend({
});

var FieldChar = InputField.extend(TranslatableFieldMixin, {
description: _lt("Text"),
className: 'o_field_char',
tagName: 'span',
supportedFieldTypes: ['char'],
@@ -485,6 +487,7 @@ var LinkButton = AbstractField.extend({
});

var FieldDate = InputField.extend({
description: _lt("Date"),
className: "o_field_date",
tagName: "span",
supportedFieldTypes: ['date', 'datetime'],
@@ -600,6 +603,7 @@ var FieldDate = InputField.extend({
});

var FieldDateTime = FieldDate.extend({
description: _lt("Date & Time"),
supportedFieldTypes: ['datetime'],

/**
@@ -659,6 +663,7 @@ var FieldDateTime = FieldDate.extend({
});

var FieldMonetary = InputField.extend({
description: _lt("Monetary"),
className: 'o_field_monetary o_field_number',
tagName: 'span',
supportedFieldTypes: ['float', 'monetary'],
@@ -771,6 +776,7 @@ var FieldMonetary = InputField.extend({

var FieldBoolean = AbstractField.extend({
className: 'o_field_boolean',
description: _lt("Checkbox"),
events: _.extend({}, AbstractField.prototype.events, {
change: '_onChange',
}),
@@ -895,6 +901,7 @@ var FieldBoolean = AbstractField.extend({
});

var FieldInteger = NumericField.extend({
description: _lt("Integer"),
className: 'o_field_integer o_field_number',
supportedFieldTypes: ['integer'],

@@ -928,6 +935,7 @@ var FieldInteger = NumericField.extend({
});

var FieldFloat = NumericField.extend({
description: _lt("Decimal"),
className: 'o_field_float o_field_number',
supportedFieldTypes: ['float'],

@@ -946,6 +954,7 @@ var FieldFloat = NumericField.extend({
});

var FieldFloatTime = FieldFloat.extend({
description: _lt("Time"),
// this is not strictly necessary, as for this widget to be used, the 'widget'
// attrs must be set to 'float_time', so the formatType is automatically
// 'float_time', but for the sake of clarity, we explicitely define a
@@ -959,6 +968,7 @@ var FieldFloatTime = FieldFloat.extend({
});

var FieldFloatFactor = FieldFloat.extend({
description: "",
supportedFieldTypes: ['float'],
className: 'o_field_float_factor',
formatType: 'float_factor',
@@ -1095,10 +1105,12 @@ var FieldFloatToggle = AbstractField.extend({
});

var FieldPercentage = FieldFloat.extend({
description: _lt("Percentage"),
formatType:'percentage',
});

var FieldText = InputField.extend(TranslatableFieldMixin, {
description: _lt("Multiline Text"),
className: 'o_field_text',
supportedFieldTypes: ['text'],
tagName: 'span',
@@ -1172,10 +1184,10 @@ var ListFieldText = FieldText.extend({
* Displays a handle to modify the sequence.
*/
var HandleWidget = AbstractField.extend({
description: _lt("Handle"),
className: 'o_row_handle fa fa-arrows ui-sortable-handle',
widthFactor: 0,
tagName: 'span',
description: "",
supportedFieldTypes: ['integer'],

/*
@@ -1187,6 +1199,7 @@ var HandleWidget = AbstractField.extend({
});

var FieldEmail = InputField.extend({
description: _lt("Email"),
className: 'o_field_email',
events: _.extend({}, InputField.prototype.events, {
'click': '_onClick',
@@ -1249,6 +1262,7 @@ var FieldEmail = InputField.extend({
});

var FieldPhone = FieldEmail.extend({
description: _lt("Phone"),
className: 'o_field_phone',
prefix: 'tel',

@@ -1271,6 +1285,7 @@ var FieldPhone = FieldEmail.extend({
});

var UrlWidget = InputField.extend({
description: _lt("URL"),
className: 'o_field_url',
events: _.extend({}, InputField.prototype.events, {
'click': '_onClick',
@@ -1398,6 +1413,7 @@ var TextCopyClipboard = FieldText.extend(CopyClipboard, {
});

var CharCopyClipboard = FieldChar.extend(CopyClipboard, {
description: _lt("Copy to Clipboard"),
clipboardTemplate: 'CopyClipboardChar',
});

@@ -1526,6 +1542,7 @@ var AbstractFieldBinary = AbstractField.extend({
});

var FieldBinaryImage = AbstractFieldBinary.extend({
description: _lt("Image"),
fieldDependencies: _.extend({}, AbstractFieldBinary.prototype.fieldDependencies, {
__last_update: {type: 'datetime'},
}),
@@ -1587,6 +1604,7 @@ var FieldBinaryImage = AbstractFieldBinary.extend({
});

var FieldBinaryFile = AbstractFieldBinary.extend({
description: _lt("File"),
template: 'FieldBinaryFile',
events: _.extend({}, AbstractFieldBinary.prototype.events, {
'click': function (event) {
@@ -1669,6 +1687,7 @@ var FieldBinaryFile = AbstractFieldBinary.extend({
});

var FieldPdfViewer = FieldBinaryFile.extend({
description: _lt("PDF Viewer"),
supportedFieldTypes: ['binary'],
template: 'FieldPdfViewer',
/**
@@ -1778,6 +1797,7 @@ var FieldPdfViewer = FieldBinaryFile.extend({
});

var PriorityWidget = AbstractField.extend({
description: _lt("Priority"),
// the current implementation of this widget makes it
// only usable for fields of type selection
className: "o_priority",
@@ -2148,6 +2168,7 @@ var FieldBooleanButton = AbstractField.extend({
});

var BooleanToggle = FieldBoolean.extend({
description: _lt("Toggle"),
className: FieldBoolean.prototype.className + ' o_boolean_toggle',
events: {
'click': '_onClick'
@@ -2215,6 +2236,7 @@ var StatInfo = AbstractField.extend({
});

var FieldPercentPie = AbstractField.extend({
description: _lt("Percentage Pie"),
template: 'FieldPercentPie',
supportedFieldTypes: ['integer', 'float'],

@@ -2280,6 +2302,7 @@ var FieldPercentPie = AbstractField.extend({
* - title: title of the bar, displayed on top of the bar --> not translated, use parameter "title" instead
*/
var FieldProgressBar = AbstractField.extend({
description: _lt("Progress Bar"),
template: "ProgressBar",
events: {
'change input': 'on_change_input',
@@ -2439,6 +2462,7 @@ var FieldProgressBar = AbstractField.extend({
* switching between a green bullet / gray bullet.
*/
var FieldToggleBoolean = AbstractField.extend({
description: _lt("Button"),
template: "toggle_button",
events: {
'click': '_onToggleButton'
@@ -67,7 +67,7 @@ registry
.add('radio', relational_fields.FieldRadio)
.add('selection_badge', relational_fields.FieldSelectionBadge)
.add('many2one', relational_fields.FieldMany2One)
.add('many2one_barcode', relational_fields.FieldMany2One)
.add('many2one_barcode', relational_fields.Many2oneBarcode)
.add('list.many2one', relational_fields.ListFieldMany2One)
.add('kanban.many2one', relational_fields.KanbanFieldMany2One)
.add('many2many', relational_fields.FieldMany2Many)
@@ -27,6 +27,7 @@ var ListRenderer = require('web.ListRenderer');
var Pager = require('web.Pager');

var _t = core._t;
var _lt = core._lt;
var qweb = core.qweb;

//------------------------------------------------------------------------------
@@ -92,6 +93,7 @@ var M2ODialog = Dialog.extend({
});

var FieldMany2One = AbstractField.extend({
description: _lt("Many2one"),
supportedFieldTypes: ['many2one'],
template: 'FieldMany2One',
custom_events: _.extend({}, AbstractField.prototype.custom_events, {
@@ -765,6 +767,10 @@ var FieldMany2One = AbstractField.extend({
},
});

var Many2oneBarcode = FieldMany2One.extend({
description: "",
});

var ListFieldMany2One = FieldMany2One.extend({

//--------------------------------------------------------------------------
@@ -1462,6 +1468,7 @@ var One2ManyKanbanRenderer = KanbanRenderer.extend({
});

var FieldOne2Many = FieldX2Many.extend({
description: _lt("One2many"),
className: 'o_field_one2many',
supportedFieldTypes: ['one2many'],

@@ -1666,6 +1673,7 @@ var FieldOne2Many = FieldX2Many.extend({
});

var FieldMany2Many = FieldX2Many.extend({
description: _lt("Many2many"),
className: 'o_field_many2many',
supportedFieldTypes: ['many2many'],

@@ -1941,6 +1949,7 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({
});

var FieldMany2ManyTags = AbstractField.extend({
description: _lt("Tags"),
tag_template: "FieldMany2ManyTag",
className: "o_field_many2manytags",
supportedFieldTypes: ['many2many'],
@@ -2260,6 +2269,7 @@ var KanbanFieldMany2ManyTags = FieldMany2ManyTags.extend({
});

var FieldMany2ManyCheckBoxes = AbstractField.extend({
description: _lt("Checkboxes"),
template: 'FieldMany2ManyCheckBoxes',
events: _.extend({}, AbstractField.prototype.events, {
change: '_onChange',
@@ -2416,6 +2426,7 @@ var FieldStatus = AbstractField.extend({
* of type 'selection' and 'many2one'.
*/
var FieldSelection = AbstractField.extend({
description: _lt("Selection"),
template: 'FieldSelection',
specialData: "_fetchSpecialRelation",
supportedFieldTypes: ['selection', 'many2one'],
@@ -2542,6 +2553,7 @@ var FieldSelection = AbstractField.extend({
});

var FieldRadio = FieldSelection.extend({
description: _lt("Radio"),
template: null,
className: 'o_field_radio',
tagName: 'span',
@@ -2646,6 +2658,7 @@ var FieldRadio = FieldSelection.extend({


var FieldSelectionBadge = FieldSelection.extend({
description: _lt("Badges"),
template: null,
className: 'o_field_selection_badge',
tagName: 'span',
@@ -2862,6 +2875,7 @@ var FieldReference = FieldMany2One.extend({

return {
FieldMany2One: FieldMany2One,
Many2oneBarcode: Many2oneBarcode,
KanbanFieldMany2One: KanbanFieldMany2One,
ListFieldMany2One: ListFieldMany2One,

@@ -16,6 +16,7 @@ var _t = core._t;
* the time difference between UTC time and local time, in minutes.
*/
var FieldTimezoneMismatch = FieldSelection.extend({
description: "",
/**
* @override
*/
@@ -124,6 +125,7 @@ var FieldTimezoneMismatch = FieldSelection.extend({
var FieldReportLayout = relational_fields.FieldMany2One.extend({
// this widget is not generic, so we disable its studio use
// supportedFieldTypes: ['many2one', 'selection'],
description: "",
events: _.extend({}, relational_fields.FieldMany2One.prototype.events, {
'click img': '_onImgClicked',
}),
Oops, something went wrong.

0 comments on commit 8bea14f

Please sign in to comment.
You can’t perform that action at this time.