1 openerp.web.form = function (openerp) {
3 var _t = openerp.web._t;
4 var QWeb = openerp.web.qweb;
6 openerp.web.views.add('form', 'openerp.web.FormView');
7 openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# */{
9 * Indicates that this view is not searchable, and thus that no search
10 * view should be displayed (if there is one active).
13 form_template: "FormView",
15 * @constructs openerp.web.FormView
16 * @extends openerp.web.View
18 * @param {openerp.web.Session} session the current openerp session
19 * @param {openerp.web.DataSet} dataset the dataset this view will work with
20 * @param {String} view_id the identifier of the OpenERP view object
22 * @property {openerp.web.Registry} registry=openerp.web.form.widgets widgets registry for this form view instance
24 init: function(parent, dataset, view_id, options) {
26 this.set_default_options(options);
27 this.dataset = dataset;
28 this.model = dataset.model;
29 this.view_id = view_id || false;
30 this.fields_view = {};
32 this.widgets_counter = 0;
36 this.show_invalid = true;
37 this.dirty_for_user = false;
38 this.default_focus_field = null;
39 this.default_focus_button = null;
40 this.registry = openerp.web.form.widgets;
41 this.has_been_loaded = $.Deferred();
42 this.$form_header = null;
43 this.translatable_fields = [];
44 _.defaults(this.options, {"always_show_new_button": true});
48 return this.init_view();
50 init_view: function() {
51 if (this.embedded_view) {
52 var def = $.Deferred().then(this.on_loaded);
54 setTimeout(function() {def.resolve(self.embedded_view);}, 0);
57 var context = new openerp.web.CompoundContext(this.dataset.get_context());
58 return this.rpc("/web/view/load", {
60 "view_id": this.view_id,
62 toolbar: this.options.sidebar,
69 this.sidebar.attachments.stop();
72 _.each(this.widgets, function(w) {
76 on_loaded: function(data) {
78 this.fields_view = data;
79 var frame = new (this.registry.get_object('frame'))(this, this.fields_view.arch);
81 this.$element.html(QWeb.render(this.form_template, { 'frame': frame, 'view': this }));
82 _.each(this.widgets, function(w) {
85 this.$form_header = this.$element.find('#' + this.element_id + '_header');
86 this.$form_header.find('div.oe_form_pager button[data-pager-action]').click(function() {
87 var action = $(this).data('pager-action');
88 self.on_pager_action(action);
91 this.$form_header.find('button.oe_form_button_save').click(this.do_save);
92 this.$form_header.find('button.oe_form_button_save_edit').click(this.do_save_edit);
93 this.$form_header.find('button.oe_form_button_cancel').click(this.do_cancel);
94 this.$form_header.find('button.oe_form_button_new').click(this.on_button_new);
95 this.$form_header.find('button.oe_form_button_duplicate').click(this.on_button_duplicate);
97 if (this.options.sidebar && this.options.sidebar_id) {
98 this.sidebar = new openerp.web.Sidebar(this, this.options.sidebar_id);
100 this.sidebar.do_unfold();
101 this.sidebar.attachments = new openerp.web.form.SidebarAttachments(this.sidebar, this.sidebar.add_section('attachments', "Attachments"), this);
102 this.sidebar.add_toolbar(this.fields_view.toolbar);
103 this.set_common_sidebar_sections(this.sidebar);
105 this.has_been_loaded.resolve();
107 do_show: function () {
109 if (this.dataset.index === null) {
110 // null index means we should start a new record
111 promise = this.on_button_new();
113 promise = this.dataset.read_index(_.keys(this.fields_view.fields), this.on_record_loaded);
115 this.$element.show();
117 this.sidebar.$element.show();
121 do_hide: function () {
122 this.$element.hide();
124 this.sidebar.$element.hide();
127 on_record_loaded: function(record) {
129 throw("Form: No record received");
132 this.$form_header.find('.oe_form_on_create').show();
133 this.$form_header.find('.oe_form_on_update').hide();
134 if (!this.options["always_show_new_button"]) {
135 this.$form_header.find('button.oe_form_button_new').hide();
138 this.$form_header.find('.oe_form_on_create').hide();
139 this.$form_header.find('.oe_form_on_update').show();
140 this.$form_header.find('button.oe_form_button_new').show();
142 this.dirty_for_user = false;
143 this.datarecord = record;
144 for (var f in this.fields) {
145 var field = this.fields[f];
147 field.set_value(this.datarecord[f] || false);
151 // New record: Second pass in order to trigger the onchanges
152 this.show_invalid = false;
153 for (var f in record) {
154 var field = this.fields[f];
157 this.do_onchange(field);
161 this.on_form_changed();
162 this.show_invalid = this.ready = true;
163 this.do_update_pager(record.id == null);
165 this.sidebar.attachments.do_update();
166 this.sidebar.$element.find('.oe_sidebar_translate').toggleClass('oe_hide', !record.id);
168 if (this.default_focus_field && !this.embedded_view) {
169 this.default_focus_field.focus();
172 on_form_changed: function() {
173 for (var w in this.widgets) {
175 w.process_modifiers();
179 on_pager_action: function(action) {
180 if (this.can_be_discarded()) {
183 this.dataset.index = 0;
186 this.dataset.previous();
192 this.dataset.index = this.dataset.ids.length - 1;
198 do_update_pager: function(hide_index) {
199 var $pager = this.$element.find('#' + this.element_id + '_header div.oe_form_pager');
200 var index = hide_index ? '-' : this.dataset.index + 1;
201 $pager.find('span.oe_pager_index').html(index);
202 $pager.find('span.oe_pager_count').html(this.dataset.ids.length);
204 do_onchange: function(widget, processed) {
205 processed = processed || [];
206 if (widget.node.attrs.on_change) {
209 var onchange = _.trim(widget.node.attrs.on_change);
210 var call = onchange.match(/^\s?(.*?)\((.*?)\)\s?$/);
212 var method = call[1], args = [];
213 var context_index = null;
214 var argument_replacement = {
215 'False' : function() {return false;},
216 'True' : function() {return true;},
217 'None' : function() {return null;},
218 'context': function(i) {
220 var ctx = widget.build_context ? widget.build_context() : {};
224 var parent_fields = null;
225 _.each(call[2].split(','), function(a, i) {
226 var field = _.trim(a);
227 if (field in argument_replacement) {
228 args.push(argument_replacement[field](i));
230 } else if (self.fields[field]) {
231 var value = self.fields[field].get_on_change_value();
232 args.push(value == null ? false : value);
235 var splitted = field.split('.');
236 if (splitted.length > 1 && _.trim(splitted[0]) === "parent" && self.dataset.parent_view) {
237 if (parent_fields === null) {
238 parent_fields = self.dataset.parent_view.get_fields_values();
240 var p_val = parent_fields[_.trim(splitted[1])];
241 if (p_val !== undefined) {
242 args.push(p_val == null ? false : p_val);
247 throw "Could not get field with name '" + field +
248 "' for onchange '" + onchange + "'";
251 url: '/web/dataset/call',
254 return this.rpc(ajax, {
255 model: this.dataset.model,
257 args: [(this.datarecord.id == null ? [] : [this.datarecord.id])].concat(args),
258 context_id: context_index === null ? null : context_index + 1
259 }, function(response) {
260 self.on_processed_onchange(response, processed);
263 console.log("Wrong on_change format", on_change);
267 on_processed_onchange: function(response, processed) {
268 var result = response;
270 for (var f in result.value) {
271 var field = this.fields[f];
272 // If field is not defined in the view, just ignore it
274 var value = result.value[f];
275 processed.push(field.name);
276 if (field.get_value() != value) {
277 field.set_value(value);
278 field.dirty = this.dirty_for_user = true;
279 if (_.indexOf(processed, field.name) < 0) {
280 this.do_onchange(field, processed);
285 this.on_form_changed();
287 if (!_.isEmpty(result.warning)) {
288 $(QWeb.render("DialogWarning", result.warning)).dialog({
292 $(this).dialog("close");
302 on_button_new: function() {
304 var def = $.Deferred();
305 $.when(this.has_been_loaded).then(function() {
306 if (self.can_be_discarded()) {
307 var keys = _.keys(self.fields_view.fields);
309 self.dataset.default_get(keys).then(self.on_record_loaded).then(function() {
313 self.on_record_loaded({});
318 return def.promise();
320 on_button_duplicate: function() {
322 var def = $.Deferred();
323 $.when(this.has_been_loaded).then(function() {
324 if (self.can_be_discarded()) {
325 self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
326 return self.on_created({ result : new_id });
332 return def.promise();
334 can_be_discarded: function() {
335 return !this.dirty_for_user || confirm(_t("Warning, the record has been modified, your changes will be discarded."));
338 * Triggers saving the form's record. Chooses between creating a new
339 * record or saving an existing one depending on whether the record
340 * already has an id property.
342 * @param {Function} success callback on save success
343 * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new record, should that record be inserted at the start of the dataset (by default, records are added at the end)
345 do_save: function(success, prepend_on_create) {
350 var form_dirty = false,
351 form_invalid = false,
353 first_invalid_field = null;
354 for (var f in this.fields) {
359 if (!first_invalid_field) {
360 first_invalid_field = f;
362 } else if (f.is_dirty()) {
364 values[f.name] = f.get_value();
368 first_invalid_field.focus();
372 console.log("About to save", values);
373 if (!this.datarecord.id) {
374 return this.dataset.create(values, function(r) {
375 self.on_created(r, success, prepend_on_create);
378 return this.dataset.write(this.datarecord.id, values, {}, function(r) {
379 self.on_saved(r, success);
384 do_save_edit: function() {
386 //this.switch_readonly(); Use promises
388 switch_readonly: function() {
390 switch_editable: function() {
392 on_invalid: function() {
394 _.each(this.fields, function(f) {
396 msg += "<li>" + f.string + "</li>";
400 this.notification.warn("The following fields are invalid :", msg);
402 on_saved: function(r, success) {
404 // should not happen in the server, but may happen for internal purpose
413 * Updates the form' dataset to contain the new record:
415 * * Adds the newly created record to the current dataset (at the end by
417 * * Selects that record (sets the dataset's index to point to the new
419 * * Updates the pager and sidebar displays
422 * @param {Function} success callback to execute after having updated the dataset
423 * @param {Boolean} [prepend_on_create=false] adds the newly created record at the beginning of the dataset instead of the end
425 on_created: function(r, success, prepend_on_create) {
427 // should not happen in the server, but may happen for internal purpose
429 this.datarecord.id = r.result;
430 if (!prepend_on_create) {
431 this.dataset.ids.push(this.datarecord.id);
432 this.dataset.index = this.dataset.ids.length - 1;
434 this.dataset.ids.unshift(this.datarecord.id);
435 this.dataset.index = 0;
437 this.do_update_pager();
439 this.sidebar.attachments.do_update();
441 console.debug("The record has been created with id #" + this.datarecord.id);
443 success(_.extend(r, {created: true}));
448 do_search: function (domains, contexts, groupbys) {
449 console.debug("Searching form");
451 on_action: function (action) {
452 console.debug('Executing action', action);
454 do_cancel: function () {
455 console.debug("Cancelling form");
458 if (this.dataset.index == null || this.dataset.index < 0) {
459 this.on_button_new();
461 this.dataset.read_index(_.keys(this.fields_view.fields), this.on_record_loaded);
464 get_fields_values: function() {
466 _.each(this.fields, function(value, key) {
467 var val = value.get_value();
472 get_selected_ids: function() {
473 var id = this.dataset.ids[this.dataset.index];
474 return id ? [id] : [];
477 openerp.web.FormDialog = openerp.web.Dialog.extend({
478 init: function(parent, options, view_id, dataset) {
479 this._super(parent, options);
480 this.dataset = dataset;
481 this.view_id = view_id;
486 this.form = new openerp.web.FormView(this, this.dataset, this.view_id, {
490 this.form.appendTo(this.$element);
491 this.form.on_created.add_last(this.on_form_dialog_saved);
492 this.form.on_saved.add_last(this.on_form_dialog_saved);
495 load_id: function(id) {
497 return this.dataset.read_ids([id], _.keys(this.form.fields_view.fields), function(records) {
498 self.form.on_record_loaded(records[0]);
501 on_form_dialog_saved: function(r) {
507 openerp.web.form = {};
509 openerp.web.form.SidebarAttachments = openerp.web.Widget.extend({
510 init: function(parent, element_id, form_view) {
511 this._super(parent, element_id);
512 this.view = form_view;
514 do_update: function() {
515 if (!this.view.datarecord.id) {
516 this.on_attachments_loaded([]);
518 (new openerp.web.DataSetSearch(
519 this, 'ir.attachment', this.view.dataset.get_context(),
521 ['res_model', '=', this.view.dataset.model],
522 ['res_id', '=', this.view.datarecord.id],
523 ['type', 'in', ['binary', 'url']]
524 ])).read_slice(['name', 'url', 'type'], {}, this.on_attachments_loaded);
527 on_attachments_loaded: function(attachments) {
528 this.attachments = attachments;
529 this.$element.html(QWeb.render('FormView.sidebar.attachments', this));
530 this.$element.find('.oe-binary-file').change(this.on_attachment_changed);
531 this.$element.find('.oe-sidebar-attachment-delete').click(this.on_attachment_delete);
533 on_attachment_changed: function(e) {
534 window[this.element_id + '_iframe'] = this.do_update;
535 var $e = $(e.target);
536 if ($e.val() != '') {
537 this.$element.find('form.oe-binary-form').submit();
538 $e.parent().find('input[type=file]').attr('disabled', 'true');
539 $e.parent().find('button').attr('disabled', 'true').find('img, span').toggle();
542 on_attachment_delete: function(e) {
543 var self = this, $e = $(e.currentTarget);
544 var name = _.trim($e.parent().find('a.oe-sidebar-attachments-link').text());
545 if (confirm("Do you really want to delete the attachment " + name + " ?")) {
546 this.rpc('/web/dataset/unlink', {
547 model: 'ir.attachment',
548 ids: [parseInt($e.attr('data-id'))]
550 $e.parent().remove();
551 self.notification.notify("Delete an attachment", "The attachment '" + name + "' has been deleted");
557 openerp.web.form.compute_domain = function(expr, fields) {
559 for (var i = expr.length - 1; i >= 0; i--) {
561 if (ex.length == 1) {
562 var top = stack.pop();
565 stack.push(stack.pop() || top);
568 stack.push(stack.pop() && top);
574 throw new Error('Unknown domain operator ' + ex);
578 var field = fields[ex[0]];
580 throw new Error("Domain references unknown field : " + ex[0]);
582 var field_value = field.get_value ? fields[ex[0]].get_value() : fields[ex[0]].value;
586 switch (op.toLowerCase()) {
589 stack.push(field_value == val);
593 stack.push(field_value != val);
596 stack.push(field_value < val);
599 stack.push(field_value > val);
602 stack.push(field_value <= val);
605 stack.push(field_value >= val);
608 stack.push(_(val).contains(field_value));
611 stack.push(!_(val).contains(field_value));
614 console.log("Unsupported operator in modifiers :", op);
617 return _.all(stack, _.identity);
620 openerp.web.form.Widget = openerp.web.Widget.extend(/** @lends openerp.web.form.Widget# */{
623 * @constructs openerp.web.form.Widget
624 * @extends openerp.web.Widget
629 init: function(view, node) {
632 this.modifiers = JSON.parse(this.node.attrs.modifiers || '{}');
633 this.type = this.type || node.tag;
634 this.element_name = this.element_name || this.type;
635 this.element_id = [this.view.element_id, this.element_name, this.view.widgets_counter++].join("_");
637 this._super(view, this.element_id);
639 this.view.widgets[this.element_id] = this;
640 this.children = node.children;
641 this.colspan = parseInt(node.attrs.colspan || 1, 10);
642 this.decrease_max_width = 0;
644 this.string = this.string || node.attrs.string;
645 this.help = this.help || node.attrs.help;
646 this.invisible = this.modifiers['invisible'] === true;
647 this.classname = 'oe_form_' + this.type;
649 this.width = this.node.attrs.width;
652 this.$element = $('#' + this.element_id);
656 this.$element.remove();
659 process_modifiers: function() {
660 var compute_domain = openerp.web.form.compute_domain;
661 for (var a in this.modifiers) {
662 this[a] = compute_domain(this.modifiers[a], this.view.fields);
665 update_dom: function() {
666 this.$element.toggle(!this.invisible);
669 var template = this.template;
670 return QWeb.render(template, { "widget": this });
674 openerp.web.form.WidgetFrame = openerp.web.form.Widget.extend({
675 template: 'WidgetFrame',
676 init: function(view, node) {
677 this._super(view, node);
678 this.columns = parseInt(node.attrs.col || 4, 10);
683 for (var i = 0; i < node.children.length; i++) {
684 var n = node.children[i];
685 if (n.tag == "newline") {
691 this.set_row_cells_with(this.table[this.table.length - 1]);
694 if (this.table.length) {
695 this.set_row_cells_with(this.table[this.table.length - 1]);
698 this.table.push(row);
703 set_row_cells_with: function(row) {
706 for (var i = 0; i < row.length; i++) {
707 bypass += row[i].width === undefined ? 0 : 1;
708 max_width -= row[i].decrease_max_width;
710 var size_unit = Math.round(max_width / (this.columns - bypass)),
712 for (var i = 0; i < row.length; i++) {
714 colspan_sum += w.colspan;
715 if (w.width === undefined) {
716 var width = (i === row.length - 1 && colspan_sum === this.columns) ? max_width : Math.round(size_unit * w.colspan);
718 w.width = width + '%';
722 handle_node: function(node) {
724 if (node.tag == 'field') {
725 type = this.view.fields_view.fields[node.attrs.name] || {};
727 var widget = new (this.view.registry.get_any(
728 [node.attrs.widget, type.type, node.tag])) (this.view, node);
729 if (node.tag == 'field') {
730 if (!this.view.default_focus_field || node.attrs.default_focus == '1') {
731 this.view.default_focus_field = widget;
733 if (node.attrs.nolabel != '1') {
734 var label = new (this.view.registry.get_object('label')) (this.view, node);
735 label["for"] = widget;
736 this.add_widget(label, widget.colspan + 1);
739 this.add_widget(widget);
741 add_widget: function(widget, colspan) {
742 colspan = colspan || widget.colspan;
743 var current_row = this.table[this.table.length - 1];
744 if (current_row.length && (this.x + colspan) > this.columns) {
745 current_row = this.add_row();
747 current_row.push(widget);
748 this.x += widget.colspan;
753 openerp.web.form.WidgetNotebook = openerp.web.form.Widget.extend({
754 template: 'WidgetNotebook',
755 init: function(view, node) {
756 this._super(view, node);
758 for (var i = 0; i < node.children.length; i++) {
759 var n = node.children[i];
760 if (n.tag == "page") {
761 var page = new openerp.web.form.WidgetNotebookPage(this.view, n, this, this.pages.length);
762 this.pages.push(page);
767 this._super.apply(this, arguments);
768 this.$element.tabs();
769 this.view.on_button_new.add_last(this.do_select_first_visible_tab);
771 do_select_first_visible_tab: function() {
772 for (var i = 0; i < this.pages.length; i++) {
773 var page = this.pages[i];
774 if (page.invisible === false) {
775 this.$element.tabs('select', page.index);
782 openerp.web.form.WidgetNotebookPage = openerp.web.form.WidgetFrame.extend({
783 template: 'WidgetNotebookPage',
784 init: function(view, node, notebook, index) {
785 this.notebook = notebook;
787 this.element_name = 'page_' + index;
788 this._super(view, node);
789 this.element_tab_id = this.element_id + '_tab';
792 this._super.apply(this, arguments);
793 this.$element_tab = $('#' + this.element_tab_id);
795 update_dom: function() {
796 if (this.invisible && this.index === this.notebook.$element.tabs('option', 'selected')) {
797 this.notebook.do_select_first_visible_tab();
799 this.$element_tab.toggle(!this.invisible);
800 this.$element.toggle(!this.invisible);
804 openerp.web.form.WidgetSeparator = openerp.web.form.Widget.extend({
805 init: function(view, node) {
806 this._super(view, node);
807 this.template = "WidgetSeparator";
808 this.orientation = node.attrs.orientation || 'horizontal';
809 if (this.orientation === 'vertical') {
812 this.classname += '_' + this.orientation;
816 openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({
817 init: function(view, node) {
818 this._super(view, node);
819 this.template = "WidgetButton";
821 // We don't have button key bindings in the webclient
822 this.string = this.string.replace(/_/g, '');
824 if (node.attrs.default_focus == '1') {
825 // TODO fme: provide enter key binding to widgets
826 this.view.default_focus_button = this;
830 this._super.apply(this, arguments);
831 this.$element.click(this.on_click);
833 on_click: function(saved) {
835 if ((!this.node.attrs.special && this.view.dirty_for_user && saved !== true) || !this.view.datarecord.id) {
836 this.view.do_save(function() {
840 if (this.node.attrs.confirm) {
841 var dialog = $('<div>' + this.node.attrs.confirm + '</div>').dialog({
847 $(this).dialog("close");
850 $(this).dialog("close");
859 on_confirmed: function() {
862 this.view.do_execute_action(
863 this.node.attrs, this.view.dataset, this.view.datarecord.id, function () {
869 openerp.web.form.WidgetLabel = openerp.web.form.Widget.extend({
870 init: function(view, node) {
871 this.element_name = 'label_' + node.attrs.name;
873 this._super(view, node);
875 // TODO fme: support for attrs.align
876 if (this.node.tag == 'label' && (this.node.attrs.colspan || (this.string && this.string.length > 32))) {
877 this.template = "WidgetParagraph";
878 this.colspan = parseInt(this.node.attrs.colspan || 1, 10);
880 this.template = "WidgetLabel";
883 this.decrease_max_width = 1;
887 render: function () {
888 if (this['for'] && this.type !== 'label') {
889 return QWeb.render(this.template, {widget: this['for']});
891 // Actual label widgets should not have a false and have type label
892 return QWeb.render(this.template, {widget: this});
897 this.$element.find("label").dblclick(function() {
898 var widget = self['for'] || self;
899 console.log(widget.element_id , widget);
905 openerp.web.form.Field = openerp.web.form.Widget.extend(/** @lends openerp.web.form.Field# */{
907 * @constructs openerp.web.form.Field
908 * @extends openerp.web.form.Widget
913 init: function(view, node) {
914 this.name = node.attrs.name;
915 this.value = undefined;
916 view.fields[this.name] = this;
917 this.type = node.attrs.widget || view.fields_view.fields[node.attrs.name].type;
918 this.element_name = "field_" + this.name + "_" + this.type;
920 this._super(view, node);
922 if (node.attrs.nolabel != '1' && this.colspan > 1) {
925 this.field = view.fields_view.fields[node.attrs.name] || {};
926 this.string = node.attrs.string || this.field.string;
927 this.help = node.attrs.help || this.field.help;
928 this.nolabel = (this.field.nolabel || node.attrs.nolabel) === '1';
929 this.readonly = this.modifiers['readonly'] === true;
930 this.required = this.modifiers['required'] === true;
931 this.invalid = false;
934 this.classname = 'oe_form_field_' + this.type;
937 this._super.apply(this, arguments);
938 if (this.field.translate) {
939 this.view.translatable_fields.push(this);
940 this.$element.find('.oe_field_translate').click(this.on_translate);
943 set_value: function(value) {
945 this.invalid = false;
947 this.on_value_changed();
949 set_value_from_ui: function() {
950 this.on_value_changed();
952 on_value_changed: function() {
954 on_translate: function() {
955 this.view.open_translate_dialog(this);
957 get_value: function() {
960 is_valid: function() {
961 return !this.invalid;
963 is_dirty: function() {
964 return this.dirty && !this.readonly;
966 get_on_change_value: function() {
967 return this.get_value();
969 update_dom: function() {
970 this._super.apply(this, arguments);
971 if (this.field.translate) {
972 this.$element.find('.oe_field_translate').toggle(!!this.view.datarecord.id);
974 if (!this.disable_utility_classes) {
975 this.$element.toggleClass('disabled', this.readonly);
976 this.$element.toggleClass('required', this.required);
977 if (this.view.show_invalid) {
978 this.$element.toggleClass('invalid', !this.is_valid());
982 on_ui_change: function() {
983 this.dirty = this.view.dirty_for_user = true;
985 if (this.is_valid()) {
986 this.set_value_from_ui();
987 this.view.do_onchange(this);
988 this.view.on_form_changed();
993 validate: function() {
994 this.invalid = false;
998 _build_view_fields_values: function() {
999 var a_dataset = this.view.dataset || {};
1000 var fields_values = this.view.get_fields_values();
1001 var parent_values = a_dataset.parent_view ? a_dataset.parent_view.get_fields_values() : {};
1002 fields_values.parent = parent_values;
1003 return fields_values;
1006 * Builds a new context usable for operations related to fields by merging
1007 * the fields'context with the action's context.
1009 build_context: function() {
1010 var f_context = this.field.context || null;
1011 // maybe the default_get should only be used when we do a default_get?
1012 var v_contexts = _.compact([this.node.attrs.default_get || null,
1013 this.node.attrs.context || null]);
1014 var v_context = new openerp.web.CompoundContext();
1015 _.each(v_contexts, function(x) {v_context.add(x);});
1016 if (_.detect(v_contexts, function(x) {return !!x.__ref;})) {
1017 var fields_values = this._build_view_fields_values();
1018 v_context.set_eval_context(fields_values);
1020 // if there is a context on the node, overrides the model's context
1021 var ctx = v_contexts.length > 0 ? v_context : f_context;
1024 build_domain: function() {
1025 var f_domain = this.field.domain || null;
1026 var v_domain = this.node.attrs.domain || [];
1027 if (!(v_domain instanceof Array) || true) { //TODO niv: remove || true
1028 var fields_values = this._build_view_fields_values();
1029 v_domain = new openerp.web.CompoundDomain(v_domain).set_eval_context(fields_values);
1031 // if there is a domain on the node, overrides the model's domain
1032 return f_domain || v_domain;
1036 openerp.web.form.FieldChar = openerp.web.form.Field.extend({
1037 init: function(view, node) {
1038 this._super(view, node);
1039 this.template = "FieldChar";
1042 this._super.apply(this, arguments);
1043 this.$element.find('input').change(this.on_ui_change);
1045 set_value: function(value) {
1046 this._super.apply(this, arguments);
1047 var show_value = openerp.web.format_value(value, this, '');
1048 this.$element.find('input').val(show_value);
1050 update_dom: function() {
1051 this._super.apply(this, arguments);
1052 this.$element.find('input').attr('disabled', this.readonly);
1054 set_value_from_ui: function() {
1055 this.value = openerp.web.parse_value(this.$element.find('input').val(), this);
1058 validate: function() {
1059 this.invalid = false;
1061 var value = openerp.web.parse_value(this.$element.find('input').val(), this, '');
1062 this.invalid = this.required && value === '';
1064 this.invalid = true;
1068 this.$element.find('input').focus();
1072 openerp.web.form.FieldEmail = openerp.web.form.FieldChar.extend({
1073 init: function(view, node) {
1074 this._super(view, node);
1075 this.template = "FieldEmail";
1078 this._super.apply(this, arguments);
1079 this.$element.find('button').click(this.on_button_clicked);
1081 on_button_clicked: function() {
1082 if (!this.value || !this.is_valid()) {
1083 this.notification.warn("E-mail error", "Can't send email to invalid e-mail address");
1085 location.href = 'mailto:' + this.value;
1088 set_value: function(value) {
1089 this._super.apply(this, arguments);
1090 this.$element.find('a').attr('href', 'mailto:' + this.$element.find('input').val());
1094 openerp.web.form.FieldUrl = openerp.web.form.FieldChar.extend({
1095 init: function(view, node) {
1096 this._super(view, node);
1097 this.template = "FieldUrl";
1100 this._super.apply(this, arguments);
1101 this.$element.find('button').click(this.on_button_clicked);
1103 on_button_clicked: function() {
1105 this.notification.warn("Resource error", "This resource is empty");
1107 window.open(this.value);
1112 openerp.web.form.FieldFloat = openerp.web.form.FieldChar.extend({
1113 set_value: function(value) {
1114 if (value === false || value === undefined) {
1115 // As in GTK client, floats default to 0
1119 this._super.apply(this, [value]);
1123 openerp.web.DateTimeWidget = openerp.web.Widget.extend({
1124 template: "web.datetimepicker",
1125 jqueryui_object: 'datetimepicker',
1126 type_of_date: "datetime",
1129 this.$element.find('input').change(this.on_change);
1131 onSelect: this.on_picker_select,
1135 showButtonPanel: false
1137 this.$element.find('img.oe_datepicker_trigger').click(function() {
1138 if (!self.readonly) {
1139 self.picker('setDate', self.value || new Date());
1140 self.$element.find('.oe_datepicker').toggle();
1143 this.$element.find('.ui-datepicker-inline').removeClass('ui-widget-content ui-corner-all');
1144 this.$element.find('button.oe_datepicker_close').click(function() {
1145 self.$element.find('.oe_datepicker').hide();
1147 this.set_readonly(false);
1150 picker: function() {
1151 return $.fn[this.jqueryui_object].apply(this.$element.find('.oe_datepicker_container'), arguments);
1153 on_picker_select: function(text, instance) {
1154 var date = this.picker('getDate');
1155 this.$element.find('input').val(date ? this.format_client(date) : '').change();
1157 set_value: function(value) {
1159 this.$element.find('input').val(value ? this.format_client(value) : '');
1161 get_value: function() {
1164 set_value_from_ui: function() {
1165 var value = this.$element.find('input').val() || false;
1166 this.value = this.parse_client(value);
1168 set_readonly: function(readonly) {
1169 this.readonly = readonly;
1170 this.$element.find('input').attr('disabled', this.readonly);
1171 this.$element.find('img.oe_datepicker_trigger').toggleClass('oe_input_icon_disabled', readonly);
1173 is_valid: function(required) {
1174 var value = this.$element.find('input').val();
1179 this.parse_client(value);
1187 this.$element.find('input').focus();
1189 parse_client: function(v) {
1190 return openerp.web.parse_value(v, {"widget": this.type_of_date});
1192 format_client: function(v) {
1193 return openerp.web.format_value(v, {"widget": this.type_of_date});
1195 on_change: function() {
1196 if (this.is_valid()) {
1197 this.set_value_from_ui();
1202 openerp.web.DateWidget = openerp.web.DateTimeWidget.extend({
1203 jqueryui_object: 'datepicker',
1204 type_of_date: "date",
1205 on_picker_select: function(text, instance) {
1206 this._super(text, instance);
1207 this.$element.find('.oe_datepicker').hide();
1211 openerp.web.form.FieldDatetime = openerp.web.form.Field.extend({
1212 template: "EmptyComponent",
1213 build_widget: function() {
1214 return new openerp.web.DateTimeWidget(this);
1218 this._super.apply(this, arguments);
1219 this.datewidget = this.build_widget();
1220 this.datewidget.on_change.add(this.on_ui_change);
1221 this.datewidget.appendTo(this.$element);
1223 set_value: function(value) {
1225 this.datewidget.set_value(value);
1227 get_value: function() {
1228 return this.datewidget.get_value();
1230 update_dom: function() {
1231 this._super.apply(this, arguments);
1232 this.datewidget.set_readonly(this.readonly);
1234 validate: function() {
1235 this.invalid = !this.datewidget.is_valid(this.required);
1238 this.datewidget.focus();
1242 openerp.web.form.FieldDate = openerp.web.form.FieldDatetime.extend({
1243 build_widget: function() {
1244 return new openerp.web.DateWidget(this);
1248 openerp.web.form.FieldText = openerp.web.form.Field.extend({
1249 init: function(view, node) {
1250 this._super(view, node);
1251 this.template = "FieldText";
1254 this._super.apply(this, arguments);
1255 this.$element.find('textarea').change(this.on_ui_change);
1257 set_value: function(value) {
1258 this._super.apply(this, arguments);
1259 var show_value = openerp.web.format_value(value, this, '');
1260 this.$element.find('textarea').val(show_value);
1262 update_dom: function() {
1263 this._super.apply(this, arguments);
1264 this.$element.find('textarea').attr('disabled', this.readonly);
1266 set_value_from_ui: function() {
1267 this.value = openerp.web.parse_value(this.$element.find('textarea').val(), this);
1270 validate: function() {
1271 this.invalid = false;
1273 var value = openerp.web.parse_value(this.$element.find('textarea').val(), this, '');
1274 this.invalid = this.required && value === '';
1276 this.invalid = true;
1280 this.$element.find('textarea').focus();
1284 openerp.web.form.FieldBoolean = openerp.web.form.Field.extend({
1285 init: function(view, node) {
1286 this._super(view, node);
1287 this.template = "FieldBoolean";
1291 this._super.apply(this, arguments);
1292 this.$element.find('input').click(function() {
1293 if ($(this).is(':checked') != self.value) {
1294 self.on_ui_change();
1298 set_value: function(value) {
1299 this._super.apply(this, arguments);
1300 this.$element.find('input')[0].checked = value;
1302 set_value_from_ui: function() {
1303 this.value = this.$element.find('input').is(':checked');
1306 update_dom: function() {
1307 this._super.apply(this, arguments);
1308 this.$element.find('input').attr('disabled', this.readonly);
1310 validate: function() {
1311 this.invalid = this.required && !this.$element.find('input').is(':checked');
1314 this.$element.find('input').focus();
1318 openerp.web.form.FieldProgressBar = openerp.web.form.Field.extend({
1319 init: function(view, node) {
1320 this._super(view, node);
1321 this.template = "FieldProgressBar";
1324 this._super.apply(this, arguments);
1325 this.$element.find('div').progressbar({
1327 disabled: this.readonly
1330 set_value: function(value) {
1331 this._super.apply(this, arguments);
1332 var show_value = Number(value);
1333 if (isNaN(show_value)) {
1336 this.$element.find('div').progressbar('option', 'value', show_value).find('span').html(show_value + '%');
1340 openerp.web.form.FieldTextXml = openerp.web.form.Field.extend({
1341 // to replace view editor
1344 openerp.web.form.FieldSelection = openerp.web.form.Field.extend({
1345 init: function(view, node) {
1347 this._super(view, node);
1348 this.template = "FieldSelection";
1349 this.values = this.field.selection;
1350 _.each(this.values, function(v, i) {
1351 if (v[0] === false && v[1] === '') {
1352 self.values.splice(i, 1);
1355 this.values.unshift([false, '']);
1358 // Flag indicating whether we're in an event chain containing a change
1359 // event on the select, in order to know what to do on keyup[RETURN]:
1360 // * If the user presses [RETURN] as part of changing the value of a
1361 // selection, we should just let the value change and not let the
1362 // event broadcast further (e.g. to validating the current state of
1363 // the form in editable list view, which would lead to saving the
1364 // current row or switching to the next one)
1365 // * If the user presses [RETURN] with a select closed (side-effect:
1366 // also if the user opened the select and pressed [RETURN] without
1367 // changing the selected value), takes the action as validating the
1369 var ischanging = false;
1370 this._super.apply(this, arguments);
1371 this.$element.find('select')
1372 .change(this.on_ui_change)
1373 .change(function () { ischanging = true; })
1374 .click(function () { ischanging = false; })
1375 .keyup(function (e) {
1376 if (e.which !== 13 || !ischanging) { return; }
1377 e.stopPropagation();
1381 set_value: function(value) {
1382 value = value === null ? false : value;
1383 value = value instanceof Array ? value[0] : value;
1386 for (var i = 0, ii = this.values.length; i < ii; i++) {
1387 if (this.values[i][0] === value) index = i;
1389 this.$element.find('select')[0].selectedIndex = index;
1391 set_value_from_ui: function() {
1392 this.value = this.values[this.$element.find('select')[0].selectedIndex][0];
1395 update_dom: function() {
1396 this._super.apply(this, arguments);
1397 this.$element.find('select').attr('disabled', this.readonly);
1399 validate: function() {
1400 var value = this.values[this.$element.find('select')[0].selectedIndex];
1401 this.invalid = !(value && !(this.required && value[0] === false));
1404 this.$element.find('select').focus();
1408 // jquery autocomplete tweak to allow html
1410 var proto = $.ui.autocomplete.prototype,
1411 initSource = proto._initSource;
1413 function filter( array, term ) {
1414 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
1415 return $.grep( array, function(value) {
1416 return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
1421 _initSource: function() {
1422 if ( this.options.html && $.isArray(this.options.source) ) {
1423 this.source = function( request, response ) {
1424 response( filter( this.options.source, request.term ) );
1427 initSource.call( this );
1431 _renderItem: function( ul, item) {
1432 return $( "<li></li>" )
1433 .data( "item.autocomplete", item )
1434 .append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) )
1440 openerp.web.form.dialog = function(content, options) {
1441 options = _.extend({
1448 options.autoOpen = true;
1449 var dialog = new openerp.web.Dialog(null, options);
1450 dialog.$dialog = $(content).dialog(dialog.dialog_options);
1451 return dialog.$dialog;
1454 openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({
1455 init: function(view, node) {
1456 this._super(view, node);
1457 this.template = "FieldMany2One";
1460 this.cm_id = _.uniqueId('m2o_cm_');
1461 this.last_search = [];
1462 this.tmp_value = undefined;
1467 this.$input = this.$element.find("input");
1468 this.$drop_down = this.$element.find(".oe-m2o-drop-down-button");
1469 this.$menu_btn = this.$element.find(".oe-m2o-cm-button");
1472 var init_context_menu_def = $.Deferred().then(function(e) {
1473 var rdataset = new openerp.web.DataSetStatic(self, "ir.values", self.build_context());
1474 rdataset.call("get", ['action', 'client_action_relate',
1475 [[self.field.relation, false]], false, rdataset.get_context()], false, 0)
1476 .then(function(result) {
1477 self.related_entries = result;
1479 var $cmenu = $("#" + self.cm_id);
1480 $cmenu.append(QWeb.render("FieldMany2One.context_menu", {widget: self}));
1482 bindings[self.cm_id + "_search"] = function() {
1483 self._search_create_popup("search");
1485 bindings[self.cm_id + "_create"] = function() {
1486 self._search_create_popup("form");
1488 bindings[self.cm_id + "_open"] = function() {
1492 var pop = new openerp.web.form.FormOpenPopup(self.view);
1493 pop.show_element(self.field.relation, self.value[0],self.build_context(), {});
1494 pop.on_write_completed.add_last(function() {
1495 self.set_value(self.value[0]);
1498 _.each(_.range(self.related_entries.length), function(i) {
1499 bindings[self.cm_id + "_related_" + i] = function() {
1500 self.open_related(self.related_entries[i]);
1503 var cmenu = self.$menu_btn.contextMenu(self.cm_id, {'leftClickToo': true,
1504 bindings: bindings, itemStyle: {"color": ""},
1505 onContextMenu: function() {
1507 $("#" + self.cm_id + " .oe_m2o_menu_item_mandatory").removeClass("oe-m2o-disabled-cm");
1509 $("#" + self.cm_id + " .oe_m2o_menu_item_mandatory").addClass("oe-m2o-disabled-cm");
1512 }, menuStyle: {width: "200px"}
1514 setTimeout(function() {self.$menu_btn.trigger(e);}, 0);
1517 var ctx_callback = function(e) {init_context_menu_def.resolve(e); e.preventDefault()};
1518 this.$menu_btn.bind('contextmenu', ctx_callback);
1519 this.$menu_btn.click(ctx_callback);
1521 // some behavior for input
1522 this.$input.keyup(function() {
1523 if (self.$input.val() === "") {
1524 self._change_int_value(null);
1525 } else if (self.value === null || (self.value && self.$input.val() !== self.value[1])) {
1526 self._change_int_value(undefined);
1529 this.$drop_down.click(function() {
1530 if (self.$input.autocomplete("widget").is(":visible")) {
1531 self.$input.autocomplete("close");
1534 self.$input.autocomplete("search", "");
1536 self.$input.autocomplete("search");
1538 self.$input.focus();
1541 var anyoneLoosesFocus = function() {
1542 if (!self.$input.is(":focus") &&
1543 !self.$input.autocomplete("widget").is(":visible") &&
1545 if (self.value === undefined && self.last_search.length > 0) {
1546 self._change_int_ext_value(self.last_search[0]);
1548 self._change_int_ext_value(null);
1552 this.$input.focusout(anyoneLoosesFocus);
1554 var isSelecting = false;
1556 this.$input.autocomplete({
1557 source: function(req, resp) { self.get_search_result(req, resp); },
1558 select: function(event, ui) {
1562 self._change_int_value([item.id, item.name]);
1563 } else if (item.action) {
1564 self._change_int_value(undefined);
1569 focus: function(e, ui) {
1573 close: anyoneLoosesFocus,
1577 // used to correct a bug when selecting an element by pushing 'enter' in an editable list
1578 this.$input.keyup(function(e) {
1579 if (e.which === 13) {
1581 e.stopPropagation();
1583 isSelecting = false;
1586 // autocomplete component content handling
1587 get_search_result: function(request, response) {
1588 var search_val = request.term;
1591 var dataset = new openerp.web.DataSetStatic(this, this.field.relation, self.build_context());
1593 dataset.name_search(search_val, self.build_domain(), 'ilike',
1594 this.limit + 1, function(data) {
1595 self.last_search = data;
1596 // possible selections for the m2o
1597 var values = _.map(data, function(x) {
1598 return {label: $('<span />').text(x[1]).html(), name:x[1], id:x[0]};
1601 // search more... if more results that max
1602 if (values.length > self.limit) {
1603 values = values.slice(0, self.limit);
1604 values.push({label: _t("<em>Â Â Â Search More...</em>"), action: function() {
1605 dataset.name_search(search_val, self.build_domain(), 'ilike'
1606 , false, function(data) {
1607 self._change_int_value(null);
1608 self._search_create_popup("search", data);
1613 var raw_result = _(data.result).map(function(x) {return x[1];});
1614 if (search_val.length > 0 &&
1615 !_.include(raw_result, search_val) &&
1616 (!self.value || search_val !== self.value[1])) {
1617 values.push({label: _.sprintf(_t('<em>Â Â Â Create "<strong>%s</strong>"</em>'),
1618 $('<span />').text(search_val).html()), action: function() {
1619 self._quick_create(search_val);
1623 values.push({label: _t("<em>Â Â Â Create and Edit...</em>"), action: function() {
1624 self._change_int_value(null);
1625 self._search_create_popup("form", undefined, {"default_name": search_val});
1631 _quick_create: function(name) {
1633 var dataset = new openerp.web.DataSetStatic(this, this.field.relation, self.build_context());
1634 dataset.name_create(name, function(data) {
1635 self._change_int_ext_value(data);
1636 }).fail(function(error, event) {
1637 event.preventDefault();
1638 self._change_int_value(null);
1639 self._search_create_popup("form", undefined, {"default_name": name});
1642 // all search/create popup handling
1643 _search_create_popup: function(view, ids, context) {
1645 var pop = new openerp.web.form.SelectCreatePopup(this);
1646 pop.select_element(self.field.relation,{
1647 initial_ids: ids ? _.map(ids, function(x) {return x[0]}) : undefined,
1649 disable_multiple_selection: true
1650 }, self.build_domain(),
1651 new openerp.web.CompoundContext(self.build_context(), context || {}));
1652 pop.on_select_elements.add(function(element_ids) {
1653 var dataset = new openerp.web.DataSetStatic(self, self.field.relation, self.build_context());
1654 dataset.name_get([element_ids[0]], function(data) {
1655 self._change_int_ext_value(data[0]);
1659 _change_int_ext_value: function(value) {
1660 this._change_int_value(value);
1661 this.$input.val(this.value ? this.value[1] : "");
1663 _change_int_value: function(value) {
1665 var back_orig_value = this.original_value;
1666 if (this.value === null || this.value) {
1667 this.original_value = this.value;
1669 if (back_orig_value === undefined) { // first use after a set_value()
1672 if (this.value !== undefined && ((back_orig_value ? back_orig_value[0] : null)
1673 !== (this.value ? this.value[0] : null))) {
1674 this.on_ui_change();
1677 set_value: function(value) {
1678 value = value || null;
1679 this.invalid = false;
1681 this.tmp_value = value;
1683 self.on_value_changed();
1684 var real_set_value = function(rval) {
1685 self.tmp_value = undefined;
1687 self.original_value = undefined;
1688 self._change_int_ext_value(rval);
1690 if(typeof(value) === "number") {
1691 var dataset = new openerp.web.DataSetStatic(this, this.field.relation, self.build_context());
1692 dataset.name_get([value], function(data) {
1693 real_set_value(data[0]);
1694 }).fail(function() {self.tmp_value = undefined;});
1696 setTimeout(function() {real_set_value(value);}, 0);
1699 get_value: function() {
1700 if (this.tmp_value !== undefined) {
1701 if (this.tmp_value instanceof Array) {
1702 return this.tmp_value[0];
1704 return this.tmp_value ? this.tmp_value : false;
1706 if (this.value === undefined)
1707 return this.original_value ? this.original_value[0] : false;
1708 return this.value ? this.value[0] : false;
1710 validate: function() {
1711 this.invalid = false;
1712 var val = this.tmp_value !== undefined ? this.tmp_value : this.value;
1714 this.invalid = this.required;
1717 open_related: function(related) {
1721 var additional_context = {
1722 active_id: self.value[0],
1723 active_ids: [self.value[0]],
1724 active_model: self.field.relation
1726 self.rpc("/web/action/load", {
1727 action_id: related[2].id,
1728 context: additional_context
1729 }, function(result) {
1730 result.result.context = _.extend(result.result.context || {}, additional_context);
1731 self.do_action(result.result);
1737 # Values: (0, 0, { fields }) create
1738 # (1, ID, { fields }) update
1739 # (2, ID) remove (delete)
1740 # (3, ID) unlink one (target id or target of relation)
1742 # (5) unlink all (only valid for one2many)
1747 'create': function (values) {
1748 return [commands.CREATE, false, values];
1750 // (1, id, {values})
1752 'update': function (id, values) {
1753 return [commands.UPDATE, id, values];
1757 'delete': function (id) {
1758 return [commands.DELETE, id, false];
1760 // (3, id[, _]) removes relation, but not linked record itself
1762 'forget': function (id) {
1763 return [commands.FORGET, id, false];
1767 'link_to': function (id) {
1768 return [commands.LINK_TO, id, false];
1772 'delete_all': function () {
1773 return [5, false, false];
1775 // (6, _, ids) replaces all linked records with provided ids
1777 'replace_with': function (ids) {
1778 return [6, false, ids];
1781 openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
1782 multi_selection: false,
1783 init: function(view, node) {
1784 this._super(view, node);
1785 this.template = "FieldOne2Many";
1786 this.is_started = $.Deferred();
1787 this.form_last_update = $.Deferred();
1788 this.disable_utility_classes = true;
1791 this._super.apply(this, arguments);
1795 this.dataset = new openerp.web.form.One2ManyDataSet(this, this.field.relation);
1796 this.dataset.o2m = this;
1797 this.dataset.parent_view = this.view;
1798 this.dataset.on_change.add_last(function() {
1799 self.on_ui_change();
1802 var modes = this.node.attrs.mode;
1803 modes = !!modes ? modes.split(",") : ["tree", "form"];
1805 _.each(modes, function(mode) {
1808 view_type: mode == "tree" ? "list" : mode,
1809 options: { sidebar : false }
1811 if (self.field.views && self.field.views[mode]) {
1812 view.embedded_view = self.field.views[mode];
1814 if(view.view_type === "list") {
1815 view.options.selectable = self.multi_selection;
1821 this.viewmanager = new openerp.web.ViewManager(this, this.dataset, views);
1822 this.viewmanager.registry = openerp.web.views.clone({
1823 list: 'openerp.web.form.One2ManyListView',
1824 form: 'openerp.web.form.One2ManyFormView'
1826 var once = $.Deferred().then(function() {
1827 self.form_last_update.resolve();
1829 this.viewmanager.on_controller_inited.add_last(function(view_type, controller) {
1830 if (view_type == "list") {
1831 controller.o2m = self;
1832 } else if (view_type == "form") {
1833 controller.on_record_loaded.add_last(function() {
1836 controller.on_pager_action.add_first(function() {
1837 self.save_form_view();
1839 controller.$element.find(".oe_form_button_save_edit").hide();
1841 self.is_started.resolve();
1843 this.viewmanager.on_mode_switch.add_first(function() {
1844 self.save_form_view();
1846 setTimeout(function () {
1847 self.viewmanager.appendTo(self.$element);
1850 reload_current_view: function() {
1852 var view = self.viewmanager.views[self.viewmanager.active_view].controller;
1853 if(self.viewmanager.active_view === "list") {
1854 view.reload_content();
1855 } else if (self.viewmanager.active_view === "form") {
1856 if (this.dataset.index === null && this.dataset.ids.length >= 1) {
1857 this.dataset.index = 0;
1859 this.form_last_update.then(function() {
1860 this.form_last_update = view.do_show();
1864 set_value: function(value) {
1865 value = value || [];
1867 this.dataset.reset_ids([]);
1868 if(value.length >= 1 && value[0] instanceof Array) {
1870 _.each(value, function(command) {
1871 var obj = {values: command[2]};
1872 switch (command[0]) {
1873 case commands.CREATE:
1874 obj['id'] = _.uniqueId(self.dataset.virtual_id_prefix);
1875 self.dataset.to_create.push(obj);
1876 self.dataset.cache.push(_.clone(obj));
1879 case commands.UPDATE:
1880 obj['id'] = command[1];
1881 self.dataset.to_write.push(obj);
1882 self.dataset.cache.push(_.clone(obj));
1885 case commands.DELETE:
1886 self.dataset.to_delete.push({id: command[1]});
1888 case commands.LINK_TO:
1889 ids.push(command[1]);
1891 case commands.DELETE_ALL:
1892 self.dataset.delete_all = true;
1897 this.dataset.set_ids(ids);
1898 } else if (value.length >= 1 && typeof(value[0]) === "object") {
1900 this.dataset.delete_all = true;
1901 _.each(value, function(command) {
1902 var obj = {values: command};
1903 obj['id'] = _.uniqueId(self.dataset.virtual_id_prefix);
1904 self.dataset.to_create.push(obj);
1905 self.dataset.cache.push(_.clone(obj));
1909 this.dataset.set_ids(ids);
1912 this.dataset.reset_ids(value);
1914 if (this.dataset.index === null && this.dataset.ids.length > 0) {
1915 this.dataset.index = 0;
1917 $.when(this.is_started).then(function() {
1918 self.reload_current_view();
1921 get_value: function() {
1925 var val = this.dataset.delete_all ? [commands.delete_all()] : [];
1926 val = val.concat(_.map(this.dataset.ids, function(id) {
1927 var alter_order = _.detect(self.dataset.to_create, function(x) {return x.id === id;});
1929 return commands.create(alter_order.values);
1931 alter_order = _.detect(self.dataset.to_write, function(x) {return x.id === id;});
1933 return commands.update(alter_order.id, alter_order.values);
1935 return commands.link_to(id);
1937 return val.concat(_.map(
1938 this.dataset.to_delete, function(x) {
1939 return commands['delete'](x.id);}));
1941 save_form_view: function() {
1942 if (this.viewmanager && this.viewmanager.views && this.viewmanager.active_view &&
1943 this.viewmanager.views[this.viewmanager.active_view] &&
1944 this.viewmanager.views[this.viewmanager.active_view].controller) {
1945 var view = this.viewmanager.views[this.viewmanager.active_view].controller;
1946 if (this.viewmanager.active_view === "form") {
1947 var res = $.when(view.do_save());
1948 if (res === false) {
1950 } else if (res.isRejected()) {
1951 throw "Save or create on one2many dataset is not supposed to fail.";
1952 } else if (!res.isResolved()) {
1953 throw "Asynchronous get_value() is not supported in form view.";
1960 is_valid: function() {
1962 return this._super();
1964 validate: function() {
1965 this.invalid = false;
1967 var view = self.viewmanager.views[self.viewmanager.active_view].controller;
1968 if (self.viewmanager.active_view === "form") {
1969 for (var f in view.fields) {
1971 if (!f.is_valid()) {
1972 this.invalid = true;
1978 is_dirty: function() {
1979 this.save_form_view();
1980 return this._super();
1982 update_dom: function() {
1983 this._super.apply(this, arguments);
1984 this.$element.toggleClass('disabled', this.readonly);
1988 openerp.web.form.One2ManyDataSet = openerp.web.BufferedDataSet.extend({
1989 get_context: function() {
1990 this.context = this.o2m.build_context();
1991 return this.context;
1995 openerp.web.form.One2ManyFormView = openerp.web.FormView.extend({
1998 openerp.web.form.One2ManyListView = openerp.web.ListView.extend({
1999 do_add_record: function () {
2000 if (this.options.editable) {
2001 this._super.apply(this, arguments);
2004 var pop = new openerp.web.form.SelectCreatePopup(this);
2005 pop.select_element(self.o2m.field.relation,{
2006 initial_view: "form",
2007 alternative_form_view: self.o2m.field.views ? self.o2m.field.views["form"] : undefined,
2008 create_function: function(data) {
2009 return self.o2m.dataset.create(data, function(r) {
2010 self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r.result]));
2011 self.o2m.dataset.on_change();
2014 parent_view: self.o2m.view
2015 }, self.o2m.build_domain(), self.o2m.build_context());
2016 pop.on_select_elements.add_last(function() {
2017 self.o2m.reload_current_view();
2021 do_activate_record: function(index, id) {
2023 var pop = new openerp.web.form.FormOpenPopup(self.o2m.view);
2024 pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(),{
2026 alternative_form_view: self.o2m.field.views ? self.o2m.field.views["form"] : undefined,
2027 parent_view: self.o2m.view,
2028 read_function: function() {
2029 return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments);
2032 pop.on_write.add(function(id, data) {
2033 self.o2m.dataset.write(id, data, {}, function(r) {
2034 self.o2m.reload_current_view();
2040 openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({
2041 multi_selection: false,
2042 init: function(view, node) {
2043 this._super(view, node);
2044 this.template = "FieldMany2Many";
2045 this.list_id = _.uniqueId("many2many");
2046 this.is_started = $.Deferred();
2049 this._super.apply(this, arguments);
2053 this.dataset = new openerp.web.form.Many2ManyDataSet(this, this.field.relation);
2054 this.dataset.m2m = this;
2055 this.dataset.on_unlink.add_last(function(ids) {
2056 self.on_ui_change();
2059 this.list_view = new openerp.web.form.Many2ManyListView(this, this.dataset, false, {
2061 'selectable': self.multi_selection
2063 this.list_view.m2m_field = this;
2064 this.list_view.on_loaded.add_last(function() {
2065 self.is_started.resolve();
2067 setTimeout(function () {
2068 self.list_view.appendTo($("#" + self.list_id));
2071 set_value: function(value) {
2072 value = value || [];
2073 if (value.length >= 1 && value[0] instanceof Array) {
2074 value = value[0][2];
2077 this.dataset.set_ids(value);
2079 $.when(this.is_started).then(function() {
2080 self.list_view.reload_content();
2083 get_value: function() {
2084 return [commands.replace_with(this.dataset.ids)];
2086 validate: function() {
2087 this.invalid = false;
2092 openerp.web.form.Many2ManyDataSet = openerp.web.DataSetStatic.extend({
2093 get_context: function() {
2094 this.context = this.m2m.build_context();
2095 return this.context;
2101 * @extends openerp.web.ListView
2103 openerp.web.form.Many2ManyListView = openerp.web.ListView.extend(/** @lends openerp.web.form.Many2ManyListView# */{
2104 do_add_record: function () {
2105 var pop = new openerp.web.form.SelectCreatePopup(this);
2106 pop.select_element(this.model, {},
2107 new openerp.web.CompoundDomain(this.m2m_field.build_domain(), ["!", ["id", "in", this.m2m_field.dataset.ids]]),
2108 this.m2m_field.build_context());
2110 pop.on_select_elements.add(function(element_ids) {
2111 _.each(element_ids, function(element_id) {
2112 if(! _.detect(self.dataset.ids, function(x) {return x == element_id;})) {
2113 self.dataset.set_ids([].concat(self.dataset.ids, [element_id]));
2114 self.m2m_field.on_ui_change();
2115 self.reload_content();
2120 do_activate_record: function(index, id) {
2122 var pop = new openerp.web.form.FormOpenPopup(this);
2123 pop.show_element(this.dataset.model, id, this.m2m_field.build_context(), {});
2124 pop.on_write_completed.add_last(function() {
2125 self.reload_content();
2132 * @extends openerp.web.OldWidget
2134 openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends openerp.web.form.SelectCreatePopup# */{
2135 identifier_prefix: "selectcreatepopup",
2136 template: "SelectCreatePopup",
2140 * - initial_view: form or search (default search)
2141 * - disable_multiple_selection
2142 * - alternative_form_view
2143 * - create_function (defaults to a naive saving behavior)
2146 select_element: function(model, options, domain, context) {
2149 this.domain = domain || [];
2150 this.context = context || {};
2151 this.options = _.defaults(options || {}, {"initial_view": "search", "create_function": function() {
2152 return self.create_row.apply(self, arguments);
2154 this.initial_ids = this.options.initial_ids;
2155 this.created_elements = [];
2156 openerp.web.form.dialog(this.render(), {close:function() {
2163 this.dataset = new openerp.web.ReadOnlyDataSetSearch(this, this.model,
2165 this.dataset.parent_view = this.options.parent_view;
2166 if (this.options.initial_view == "search") {
2167 this.setup_search_view();
2172 setup_search_view: function() {
2174 if (this.searchview) {
2175 this.searchview.stop();
2177 this.searchview = new openerp.web.SearchView(this,
2178 this.dataset, false, {
2179 "selectable": !this.options.disable_multiple_selection,
2182 this.searchview.on_search.add(function(domains, contexts, groupbys) {
2183 if (self.initial_ids) {
2184 self.view_list.do_search.call(self, domains.concat([[["id", "in", self.initial_ids]], self.domain]),
2185 contexts, groupbys);
2186 self.initial_ids = undefined;
2188 self.view_list.do_search.call(self, domains.concat([self.domain]), contexts, groupbys);
2191 this.searchview.on_loaded.add_last(function () {
2192 var $buttons = self.searchview.$element.find(".oe_search-view-buttons");
2193 $buttons.append(QWeb.render("SelectCreatePopup.search.buttons"));
2194 var $cbutton = $buttons.find(".oe_selectcreatepopup-search-close");
2195 $cbutton.click(function() {
2198 var $sbutton = $buttons.find(".oe_selectcreatepopup-search-select");
2199 if(self.options.disable_multiple_selection) {
2202 $sbutton.click(function() {
2203 self.on_select_elements(self.selected_ids);
2206 self.view_list = new openerp.web.form.SelectCreateListView(self,
2207 self.dataset, false,
2208 {'deletable': false});
2209 self.view_list.popup = self;
2210 self.view_list.appendTo($("#" + self.element_id + "_view_list")).pipe(function() {
2211 self.view_list.do_show();
2212 }).pipe(function() {
2213 self.searchview.do_search();
2217 this.searchview.appendTo($("#" + this.element_id + "_search"));
2219 create_row: function(data) {
2221 var wdataset = new openerp.web.DataSetSearch(this, this.model, this.context, this.domain);
2222 wdataset.parent_view = this.options.parent_view;
2223 return wdataset.create(data);
2225 on_select_elements: function(element_ids) {
2227 on_click_element: function(ids) {
2228 this.selected_ids = ids || [];
2229 if(this.selected_ids.length > 0) {
2230 this.$element.find(".oe_selectcreatepopup-search-select").removeAttr('disabled');
2232 this.$element.find(".oe_selectcreatepopup-search-select").attr('disabled', "disabled");
2235 new_object: function() {
2237 if (this.searchview) {
2238 this.searchview.hide();
2240 if (this.view_list) {
2241 this.view_list.$element.hide();
2243 this.dataset.index = null;
2244 this.view_form = new openerp.web.FormView(this, this.dataset, false);
2245 if (this.options.alternative_form_view) {
2246 this.view_form.set_embedded_view(this.options.alternative_form_view);
2248 this.view_form.appendTo(this.$element.find("#" + this.element_id + "_view_form"));
2249 this.view_form.on_loaded.add_last(function() {
2250 var $buttons = self.view_form.$element.find(".oe_form_buttons");
2251 $buttons.html(QWeb.render("SelectCreatePopup.form.buttons", {widget:self}));
2252 var $nbutton = $buttons.find(".oe_selectcreatepopup-form-save-new");
2253 $nbutton.click(function() {
2254 self._created = $.Deferred().then(function() {
2255 self._created = undefined;
2256 self.view_form.on_button_new();
2258 self.view_form.do_save();
2260 var $nbutton = $buttons.find(".oe_selectcreatepopup-form-save");
2261 $nbutton.click(function() {
2262 self._created = $.Deferred().then(function() {
2263 self._created = undefined;
2266 self.view_form.do_save();
2268 var $cbutton = $buttons.find(".oe_selectcreatepopup-form-close");
2269 $cbutton.click(function() {
2273 this.dataset.on_create.add(function(data) {
2274 self.options.create_function(data).then(function(r) {
2275 self.created_elements.push(r.result);
2276 if (self._created) {
2277 self._created.resolve();
2281 this.view_form.do_show();
2283 check_exit: function() {
2284 if (this.created_elements.length > 0) {
2285 this.on_select_elements(this.created_elements);
2291 openerp.web.form.SelectCreateListView = openerp.web.ListView.extend({
2292 do_add_record: function () {
2293 this.popup.new_object();
2295 select_record: function(index) {
2296 this.popup.on_select_elements([this.dataset.ids[index]]);
2299 do_select: function(ids, records) {
2300 this._super(ids, records);
2301 this.popup.on_click_element(ids);
2307 * @extends openerp.web.OldWidget
2309 openerp.web.form.FormOpenPopup = openerp.web.OldWidget.extend(/** @lends openerp.web.form.FormOpenPopup# */{
2310 identifier_prefix: "formopenpopup",
2311 template: "FormOpenPopup",
2314 * - alternative_form_view
2315 * - auto_write (default true)
2319 show_element: function(model, row_id, context, options) {
2321 this.row_id = row_id;
2322 this.context = context || {};
2323 this.options = _.defaults(options || {}, {"auto_write": true});
2324 jQuery(this.render()).dialog({title: '',
2332 this.dataset = new openerp.web.form.FormOpenDataset(this, this.model, this.context);
2333 this.dataset.fop = this;
2334 this.dataset.ids = [this.row_id];
2335 this.dataset.index = 0;
2336 this.dataset.parent_view = this.options.parent_view;
2337 this.setup_form_view();
2339 on_write: function(id, data) {
2341 if (!this.options.auto_write)
2344 var wdataset = new openerp.web.DataSetSearch(this, this.model, this.context, this.domain);
2345 wdataset.parent_view = this.options.parent_view;
2346 wdataset.write(id, data, {}, function(r) {
2347 self.on_write_completed();
2350 on_write_completed: function() {},
2351 setup_form_view: function() {
2353 this.view_form = new openerp.web.FormView(this, this.dataset, false);
2354 if (this.options.alternative_form_view) {
2355 this.view_form.set_embedded_view(this.options.alternative_form_view);
2357 this.view_form.appendTo(this.$element.find("#" + this.element_id + "_view_form"));
2358 this.view_form.on_loaded.add_last(function() {
2359 var $buttons = self.view_form.$element.find(".oe_form_buttons");
2360 $buttons.html(QWeb.render("FormOpenPopup.form.buttons"));
2361 var $nbutton = $buttons.find(".oe_formopenpopup-form-save");
2362 $nbutton.click(function() {
2363 self.view_form.do_save();
2365 var $cbutton = $buttons.find(".oe_formopenpopup-form-close");
2366 $cbutton.click(function() {
2369 self.view_form.do_show();
2371 this.dataset.on_write.add(this.on_write);
2375 openerp.web.form.FormOpenDataset = openerp.web.ReadOnlyDataSetSearch.extend({
2376 read_ids: function() {
2377 if (this.fop.options.read_function) {
2378 return this.fop.options.read_function.apply(null, arguments);
2380 return this._super.apply(this, arguments);
2385 openerp.web.form.FieldReference = openerp.web.form.Field.extend({
2386 init: function(view, node) {
2387 this._super(view, node);
2388 this.template = "FieldReference";
2389 this.fields_view = {
2392 selection: view.fields_view.fields[this.name].selection
2399 this.get_fields_values = view.get_fields_values;
2400 this.do_onchange = this.on_form_changed = this.on_nop;
2403 this.selection = new openerp.web.form.FieldSelection(this, { attrs: {
2407 this.selection.on_value_changed.add_last(this.on_selection_changed);
2408 this.m2o = new openerp.web.form.FieldMany2One(this, { attrs: {
2413 on_nop: function() {
2415 on_selection_changed: function() {
2416 this.m2o.field.relation = this.selection.get_value();
2417 this.m2o.set_value(null);
2421 this.selection.start();
2424 is_valid: function() {
2425 return this.required === false || typeof(this.get_value()) === 'string';
2427 is_dirty: function() {
2428 return this.selection.is_dirty() || this.m2o.is_dirty();
2430 set_value: function(value) {
2432 if (typeof(value) === 'string') {
2433 var vals = value.split(',');
2434 this.selection.set_value(vals[0]);
2435 this.m2o.set_value(parseInt(vals[1], 10));
2438 get_value: function() {
2439 var model = this.selection.get_value(),
2440 id = this.m2o.get_value();
2441 if (typeof(model) === 'string' && typeof(id) === 'number') {
2442 return model + ',' + id;
2449 openerp.web.form.FieldBinary = openerp.web.form.Field.extend({
2450 init: function(view, node) {
2451 this._super(view, node);
2452 this.iframe = this.element_id + '_iframe';
2453 this.binary_value = false;
2456 this._super.apply(this, arguments);
2457 this.$element.find('input.oe-binary-file').change(this.on_file_change);
2458 this.$element.find('button.oe-binary-file-save').click(this.on_save_as);
2459 this.$element.find('.oe-binary-file-clear').click(this.on_clear);
2461 update_dom: function() {
2462 this._super.apply(this, arguments);
2463 this.$element.find('.oe-binary').toggle(!this.readonly);
2465 human_filesize : function(size) {
2466 var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
2468 while (size >= 1024) {
2472 return size.toFixed(2) + ' ' + units[i];
2474 on_file_change: function(e) {
2475 // TODO: on modern browsers, we could directly read the file locally on client ready to be used on image cropper
2476 // http://www.html5rocks.com/tutorials/file/dndfiles/
2477 // http://deepliquid.com/projects/Jcrop/demos.php?demo=handler
2478 window[this.iframe] = this.on_file_uploaded;
2479 if ($(e.target).val() != '') {
2480 this.$element.find('form.oe-binary-form input[name=session_id]').val(this.session.session_id);
2481 this.$element.find('form.oe-binary-form').submit();
2482 this.toggle_progress();
2485 toggle_progress: function() {
2486 this.$element.find('.oe-binary-progress, .oe-binary').toggle();
2488 on_file_uploaded: function(size, name, content_type, file_base64) {
2489 delete(window[this.iframe]);
2490 if (size === false) {
2491 this.notification.warn("File Upload", "There was a problem while uploading your file");
2492 // TODO: use openerp web crashmanager
2493 console.warn("Error while uploading file : ", name);
2495 this.on_file_uploaded_and_valid.apply(this, arguments);
2496 this.on_ui_change();
2498 this.toggle_progress();
2500 on_file_uploaded_and_valid: function(size, name, content_type, file_base64) {
2502 on_save_as: function() {
2503 if (!this.view.datarecord.id) {
2504 this.notification.warn("Can't save file", "The record has not yet been saved");
2506 var url = '/web/binary/saveas?session_id=' + this.session.session_id + '&model=' +
2507 this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name +
2508 '&fieldname=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime());
2512 on_clear: function() {
2513 if (this.value !== false) {
2515 this.binary_value = false;
2516 this.on_ui_change();
2522 openerp.web.form.FieldBinaryFile = openerp.web.form.FieldBinary.extend({
2523 init: function(view, node) {
2524 this._super(view, node);
2525 this.template = "FieldBinaryFile";
2527 set_value: function(value) {
2528 this._super.apply(this, arguments);
2529 var show_value = (value != null && value !== false) ? value : '';
2530 this.$element.find('input').eq(0).val(show_value);
2532 on_file_uploaded_and_valid: function(size, name, content_type, file_base64) {
2533 this.value = file_base64;
2534 this.binary_value = true;
2535 var show_value = this.human_filesize(size);
2536 this.$element.find('input').eq(0).val(show_value);
2537 this.set_filename(name);
2539 set_filename: function(value) {
2540 var filename = this.node.attrs.filename;
2541 if (this.view.fields[filename]) {
2542 this.view.fields[filename].set_value(value);
2543 this.view.fields[filename].on_ui_change();
2546 on_clear: function() {
2547 this._super.apply(this, arguments);
2548 this.$element.find('input').eq(0).val('');
2549 this.set_filename('');
2553 openerp.web.form.FieldBinaryImage = openerp.web.form.FieldBinary.extend({
2554 init: function(view, node) {
2555 this._super(view, node);
2556 this.template = "FieldBinaryImage";
2559 this._super.apply(this, arguments);
2560 this.$image = this.$element.find('img.oe-binary-image');
2562 set_value: function(value) {
2563 this._super.apply(this, arguments);
2564 this.set_image_maxwidth();
2565 var url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' +
2566 this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + '&t=' + (new Date().getTime());
2567 this.$image.attr('src', url);
2569 set_image_maxwidth: function() {
2570 this.$image.css('max-width', this.$element.width());
2572 on_file_change: function() {
2573 this.set_image_maxwidth();
2574 this._super.apply(this, arguments);
2576 on_file_uploaded_and_valid: function(size, name, content_type, file_base64) {
2577 this.value = file_base64;
2578 this.binary_value = true;
2579 this.$image.attr('src', 'data:' + (content_type || 'image/png') + ';base64,' + file_base64);
2581 on_clear: function() {
2582 this._super.apply(this, arguments);
2583 this.$image.attr('src', '/web/static/src/img/placeholder.png');
2587 openerp.web.form.FieldStatus = openerp.web.form.Field.extend({
2588 template: "EmptyComponent",
2591 this.selected_value = null;
2595 set_value: function(value) {
2597 this.selected_value = value;
2601 render_list: function() {
2603 var shown = _.map(((this.node.attrs || {}).statusbar_visible || "").split(","),
2604 function(x) { return x.trim(); });
2605 shown = _.select(shown, function(x) { return x.length > 0; });
2607 if (shown.length == 0) {
2608 this.to_show = this.field.selection;
2610 this.to_show = _.select(this.field.selection, function(x) {
2611 return _.indexOf(shown, x[0]) !== -1 || x[0] === self.selected_value;
2615 var content = openerp.web.qweb.render("FieldStatus.content", {widget: this, _:_});
2616 this.$element.html(content);
2618 var colors = JSON.parse((this.node.attrs || {}).statusbar_colors || "{}");
2619 var color = colors[this.selected_value];
2621 var elem = this.$element.find("li.oe-arrow-list-selected span");
2622 elem.css("border-color", color);
2623 elem = this.$element.find("li.oe-arrow-list-selected .oe-arrow-list-before");
2624 elem.css("border-left-color", "rgba(0,0,0,0)");
2625 elem = this.$element.find("li.oe-arrow-list-selected .oe-arrow-list-after");
2626 elem.css("border-color", "rgba(0,0,0,0)");
2627 elem.css("border-left-color", color);
2633 * Registry of form widgets, called by :js:`openerp.web.FormView`
2635 openerp.web.form.widgets = new openerp.web.Registry({
2636 'frame' : 'openerp.web.form.WidgetFrame',
2637 'group' : 'openerp.web.form.WidgetFrame',
2638 'notebook' : 'openerp.web.form.WidgetNotebook',
2639 'separator' : 'openerp.web.form.WidgetSeparator',
2640 'label' : 'openerp.web.form.WidgetLabel',
2641 'button' : 'openerp.web.form.WidgetButton',
2642 'char' : 'openerp.web.form.FieldChar',
2643 'email' : 'openerp.web.form.FieldEmail',
2644 'url' : 'openerp.web.form.FieldUrl',
2645 'text' : 'openerp.web.form.FieldText',
2646 'text_wiki' : 'openerp.web.form.FieldText',
2647 'date' : 'openerp.web.form.FieldDate',
2648 'datetime' : 'openerp.web.form.FieldDatetime',
2649 'selection' : 'openerp.web.form.FieldSelection',
2650 'many2one' : 'openerp.web.form.FieldMany2One',
2651 'many2many' : 'openerp.web.form.FieldMany2Many',
2652 'one2many' : 'openerp.web.form.FieldOne2Many',
2653 'one2many_list' : 'openerp.web.form.FieldOne2Many',
2654 'reference' : 'openerp.web.form.FieldReference',
2655 'boolean' : 'openerp.web.form.FieldBoolean',
2656 'float' : 'openerp.web.form.FieldFloat',
2657 'integer': 'openerp.web.form.FieldFloat',
2658 'float_time': 'openerp.web.form.FieldFloat',
2659 'progressbar': 'openerp.web.form.FieldProgressBar',
2660 'image': 'openerp.web.form.FieldBinaryImage',
2661 'binary': 'openerp.web.form.FieldBinaryFile',
2662 'statusbar': 'openerp.web.form.FieldStatus'
2667 // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: