[IMP] misc comments
[odoo/odoo.git] / addons / base / static / src / js / chrome.js
1 /*---------------------------------------------------------
2  * OpenERP Web chrome
3  *---------------------------------------------------------*/
4
5 openerp.base.chrome = function(openerp) {
6
7 openerp.base.Notification =  openerp.base.Widget.extend({
8     init: function(parent, element_id) {
9         this._super(parent, element_id);
10         this.$element.notify({
11             speed: 500,
12             expires: 1500
13         });
14     },
15     notify: function(title, text) {
16         this.$element.notify('create', {
17             title: title,
18             text: text
19         });
20     },
21     warn: function(title, text) {
22         this.$element.notify('create', 'oe_notification_alert', {
23             title: title,
24             text: text
25         });
26     }
27 });
28
29 openerp.base.Dialog = openerp.base.OldWidget.extend({
30     dialog_title: "",
31     identifier_prefix: 'dialog',
32     init: function (parent, dialog_options) {
33         var self = this;
34         this._super(parent);
35         this.dialog_options = {
36             modal: true,
37             width: 'auto',
38             min_width: 0,
39             max_width: '100%',
40             height: 'auto',
41             min_height: 0,
42             max_height: '100%',
43             autoOpen: false,
44             buttons: {},
45             beforeClose: function () { self.on_close(); }
46         };
47         for (var f in this) {
48             if (f.substr(0, 10) == 'on_button_') {
49                 this.dialog_options.buttons[f.substr(10)] = this[f];
50             }
51         }
52         if (dialog_options) {
53             this.set_options(dialog_options);
54         }
55     },
56     set_options: function(options) {
57         options = options || {};
58         options.width = this.get_width(options.width || this.dialog_options.width);
59         options.min_width = this.get_width(options.min_width || this.dialog_options.min_width);
60         options.max_width = this.get_width(options.max_width || this.dialog_options.max_width);
61         options.height = this.get_height(options.height || this.dialog_options.height);
62         options.min_height = this.get_height(options.min_height || this.dialog_options.min_height);
63         options.max_height = this.get_height(options.max_height || this.dialog_options.max_width);
64
65         if (options.width !== 'auto') {
66             if (options.width > options.max_width) options.width = options.max_width;
67             if (options.width < options.min_width) options.width = options.min_width;
68         }
69         if (options.height !== 'auto') {
70             if (options.height > options.max_height) options.height = options.max_height;
71             if (options.height < options.min_height) options.height = options.min_height;
72         }
73         if (!options.title && this.dialog_title) {
74             options.title = this.dialog_title;
75         }
76         _.extend(this.dialog_options, options);
77     },
78     get_width: function(val) {
79         return this.get_size(val.toString(), $(window.top).width());
80     },
81     get_height: function(val) {
82         return this.get_size(val.toString(), $(window.top).height());
83     },
84     get_size: function(val, available_size) {
85         if (val === 'auto') {
86             return val;
87         } else if (val.slice(-1) == "%") {
88             return Math.round(available_size / 100 * parseInt(val.slice(0, -1), 10));
89         } else {
90             return parseInt(val, 10);
91         }
92     },
93     start: function () {
94         this.$dialog = $('<div id="' + this.element_id + '"></div>').dialog(this.dialog_options);
95         this._super();
96         return this;
97     },
98     open: function(dialog_options) {
99         // TODO fme: bind window on resize
100         if (this.template) {
101             this.$element.html(this.render());
102         }
103         this.set_options(dialog_options);
104         this.$dialog.dialog(this.dialog_options).dialog('open');
105     },
106     close: function() {
107         // Closes the dialog but leave it in a state where it could be opened again.
108         this.$dialog.dialog('close');
109     },
110     on_close: function() {
111     },
112     stop: function () {
113         // Destroy widget
114         this.close();
115         this.$dialog.dialog('destroy');
116     }
117 });
118
119 openerp.base.CrashManager = openerp.base.Dialog.extend({
120     identifier_prefix: 'dialog_crash',
121     init: function(parent) {
122         this._super(parent);
123         this.session.on_rpc_error.add(this.on_rpc_error);
124     },
125     on_button_Ok: function() {
126         this.close();
127     },
128     on_rpc_error: function(error) {
129         this.error = error;
130         if (error.data.fault_code) {
131             var split = error.data.fault_code.split('\n')[0].split(' -- ');
132             if (split.length > 1) {
133                 error.type = split.shift();
134                 error.data.fault_code = error.data.fault_code.substr(error.type.length + 4);
135             }
136         }
137         if (error.code === 200 && error.type) {
138             this.dialog_title = "OpenERP " + _.capitalize(error.type);
139             this.template = 'DialogWarning';
140             this.open({
141                 width: 'auto',
142                 height: 'auto'
143             });
144         } else {
145             this.dialog_title = "OpenERP Error";
146             this.template = 'DialogTraceback';
147             this.open({
148                 width: 'auto',
149                 height: 'auto'
150             });
151         }
152     }
153 });
154
155 openerp.base.Loading =  openerp.base.Widget.extend({
156     init: function(parent, element_id) {
157         this._super(parent, element_id);
158         this.count = 0;
159         this.session.on_rpc_request.add_first(this.on_rpc_event, 1);
160         this.session.on_rpc_response.add_last(this.on_rpc_event, -1);
161     },
162     on_rpc_event : function(increment) {
163         this.count += increment;
164         if (this.count) {
165             //this.$element.html(QWeb.render("Loading", {}));
166             this.$element.html("Loading ("+this.count+")");
167             this.$element.show();
168         } else {
169             this.$element.fadeOut();
170         }
171     }
172 });
173
174 openerp.base.Database = openerp.base.Widget.extend({
175     init: function(parent, element_id, option_id) {
176         this._super(parent, element_id);
177         this.$option_id = $('#' + option_id);
178     },
179     start: function() {
180         this.$element.html(QWeb.render("Database", this));
181         this.$element.closest(".openerp")
182                 .removeClass("login-mode")
183                 .addClass("database_block");
184         
185         var self = this;
186         
187         var fetch_db = this.rpc("/base/database/get_list", {}, function(result) {
188             self.db_list = result.db_list;
189         });
190         var fetch_langs = this.rpc("/base/session/get_lang_list", {}, function(result) {
191             if (result.error) {
192                 self.display_error(result);
193                 return;
194             }
195             self.lang_list = result.lang_list;
196         });
197         $.when(fetch_db, fetch_langs).then(function () {self.do_create();});
198         
199         this.$element.find('#db-create').click(this.do_create);
200         this.$element.find('#db-drop').click(this.do_drop);
201         this.$element.find('#db-backup').click(this.do_backup);
202         this.$element.find('#db-restore').click(this.do_restore);
203         this.$element.find('#db-change-password').click(this.do_change_password);
204         this.$element.find('#back-to-login').click(function() {
205             self.stop();
206         });
207     },
208     stop: function () {
209         this.$option_id.empty();
210
211         this.$element
212             .find('#db-create, #db-drop, #db-backup, #db-restore, #db-change-password, #back-to-login')
213                 .unbind('click')
214             .end()
215             .closest(".openerp")
216                 .addClass("login-mode")
217                 .removeClass("database_block")
218             .end()
219             .empty();
220
221     },
222     /**
223      * Converts a .serializeArray() result into a dict. Does not bother folding
224      * multiple identical keys into an array, last key wins.
225      *
226      * @param {Array} array
227      */
228     to_object: function (array) {
229         var result = {};
230         _(array).each(function (record) {
231             result[record.name] = record.value;
232         });
233         return result;
234     },
235     /**
236      * Waits until the new database is done creating, then unblocks the UI and
237      * logs the user in as admin
238      *
239      * @param {Number} db_creation_id identifier for the db-creation operation, used to fetch the current installation progress
240      * @param {Object} info info fields for this database creation
241      * @param {String} info.db name of the database being created
242      * @param {String} info.password super-admin password for the database
243      */
244     wait_for_newdb: function (db_creation_id, info) {
245         var self = this;
246         self.rpc('/base/database/progress', {
247             id: db_creation_id,
248             password: info.password
249         }, function (result) {
250             var progress = result[0];
251             // I'd display a progress bar, but turns out the progress status
252             // the server report kind-of blows goats: it's at 0 for ~75% of
253             // the installation, then jumps to 75%, then jumps down to either
254             // 0 or ~40%, then back up to 75%, then terminates. Let's keep that
255             // mess hidden behind a not-very-useful but not overly weird
256             // message instead.
257             if (progress < 1) {
258                 setTimeout(function () {
259                     self.wait_for_newdb(db_creation_id, info);
260                 }, 500);
261                 return;
262             }
263
264             var admin = result[1][0];
265             setTimeout(function () {
266                 self.stop();
267                 self.widget_parent.do_login(
268                         info.db, admin.login, admin.password);
269                 $.unblockUI();
270             });
271         });
272     },
273     /**
274      * Displays an error dialog resulting from the various RPC communications
275      * failing over themselves
276      *
277      * @param {Object} error error description
278      * @param {String} error.title title of the error dialog
279      * @param {String} error.error message of the error dialog
280      */
281     display_error: function (error) {
282         return $('<div>').dialog({
283             modal: true,
284             title: error.title,
285             buttons: {
286                 Ok: function() {
287                     $(this).dialog("close");
288                 }
289             }
290         }).html(error.error);
291     },
292     do_create: function() {
293         var self = this;
294         self.$option_id.html(QWeb.render("CreateDB", self));
295
296         self.$option_id.find("form[name=create_db_form]").validate({
297             submitHandler: function (form) {
298                 var fields = $(form).serializeArray();
299                 $.blockUI();
300                 self.rpc("/base/database/create", {'fields': fields}, function(result) {
301                     if (result.error) {
302                         $.unblockUI();
303                         self.display_error(result);
304                         return;
305                     }
306                     self.db_list.push(self.to_object(fields)['db_name']);
307                     self.db_list.sort();
308                     var form_obj = self.to_object(fields);
309                     self.wait_for_newdb(result, {
310                         password: form_obj['super_admin_pwd'],
311                         db: form_obj['db_name']
312                     });
313                 });
314             }
315         });
316     },
317         
318     do_drop: function() {
319         var self = this;
320         self.$option_id.html(QWeb.render("DropDB", self));
321         
322         self.$option_id.find("form[name=drop_db_form]").validate({
323             submitHandler: function (form) {
324                 var $form = $(form),
325                     fields = $form.serializeArray(),
326                     $db_list = $form.find('select[name=drop_db]'),
327                     db = $db_list.val();
328
329                 if (!confirm("Do you really want to delete the database: " + db + " ?")) {
330                     return;
331                 }
332                 self.rpc("/base/database/drop", {'fields': fields}, function(result) {
333                     if (result.error) {
334                         self.display_error(result);
335                         return;
336                     }
337                     $db_list.find(':selected').remove();
338                     self.db_list.splice(_.indexOf(self.db_list, db, true), 1);
339                     self.notification.notify("Dropping database", "The database '" + db + "' has been dropped");
340                 });
341             }
342         });
343     },
344
345     wait_for_file: function (token, cleanup) {
346         var self = this,
347             cookie_name = 'fileToken',
348             cookie_length = cookie_name.length;
349         this.backup_timer = setInterval(function () {
350             var cookies = document.cookie.split(';');
351             for(var i=0; i<cookies.length; ++i) {
352                 var cookie = cookies[i].replace(/^\s*/, '');
353                 if(!cookie.indexOf(cookie_name) === 0) { continue; }
354                 var cookie_val = cookie.substring(cookie_length + 1);
355                 if(parseInt(cookie_val, 10) !== token) { continue; }
356
357                 // clear waiter
358                 clearInterval(self.backup_timer);
359                 // clear cookie
360                 document.cookie = _.sprintf("%s=;expires=%s;path=/",
361                     cookie_name, new Date().toGMTString());
362
363                 if (cleanup) { cleanup(); }
364             }
365         }, 100);
366     },
367     do_backup: function() {
368         var self = this;
369         self.$option_id.html(QWeb.render("BackupDB", self));
370
371         self.$option_id.find("form[name=backup_db_form]").validate({
372             submitHandler: function (form) {
373                 $.blockUI();
374                 // need to detect when the file is done downloading (not used
375                 // yet, but we'll need it to fix the UI e.g. with a throbber
376                 // while dump is being generated), iframe load event only fires
377                 // when the iframe content loads, so we need to go smarter:
378                 // http://geekswithblogs.net/GruffCode/archive/2010/10/28/detecting-the-file-download-dialog-in-the-browser.aspx
379                 var $target = $('#backup-target'),
380                       token = new Date().getTime();
381                 if (!$target.length) {
382                     $target = $('<iframe id="backup-target" style="display: none;">')
383                         .appendTo(document.body)
384                         .load(function () {
385                             $.unblockUI();
386                             clearInterval(self.backup_timer);
387                             var error = this.contentDocument.body
388                                     .firstChild.data
389                                     .split('|');
390                             self.display_error({
391                                 title: error[0],
392                                 error: error[1]
393                             });
394                         });
395                 }
396                 $(form).find('input[name=token]').val(token);
397                 form.submit();
398
399                 self.wait_for_file(token, function () {
400                     $.unblockUI();
401                 });
402             }
403         });
404     },
405     
406     do_restore: function() {
407         var self = this;
408         self.$option_id.html(QWeb.render("RestoreDB", self));
409         
410         self.$option_id.find("form[name=restore_db_form]").validate({
411             submitHandler: function (form) {
412                 $.blockUI();
413                 $(form).ajaxSubmit({
414                     url: '/base/database/restore',
415                     type: 'POST',
416                     resetForm: true,
417                     success: function (body) {
418                         // TODO: ui manipulations
419                         // note: response objects don't work, but we have the
420                         // HTTP body of the response~~
421
422                         // If empty body, everything went fine
423                         if (!body) { return; }
424
425                         if (body.indexOf('403 Forbidden') !== -1) {
426                             self.display_error({
427                                 title: 'Access Denied',
428                                 error: 'Incorrect super-administrator password'
429                             })
430                         } else {
431                             self.display_error({
432                                 title: 'Restore Database',
433                                 error: 'Could not restore the database'
434                             })
435                         }
436                     },
437                     complete: function () {
438                         $.unblockUI();
439                     }
440                 });
441             }
442         });
443     },
444
445     do_change_password: function() {
446         var self = this;
447         self.$option_id.html(QWeb.render("Change_DB_Pwd", self));
448
449         self.$option_id.find("form[name=change_pwd_form]").validate({
450             messages: {
451                 old_pwd: "Please enter your previous password",
452                 new_pwd: "Please enter your new password",
453                 confirm_pwd: {
454                     required: "Please confirm your new password",
455                     equalTo: "The confirmation does not match the password"
456                 }
457             },
458             submitHandler: function (form) {
459                 self.rpc("/base/database/change_password", {
460                     'fields': $(form).serializeArray()
461                 }, function(result) {
462                     if (result.error) {
463                         self.display_error(result);
464                         return;
465                     }
466                     self.notification.notify("Changed Password", "Password has been changed successfully");
467                 });
468             }
469         });
470     }
471 });
472
473 openerp.base.Login =  openerp.base.Widget.extend({
474     remember_creditentials: true,
475     
476     init: function(parent, element_id) {
477         this._super(parent, element_id);
478         this.has_local_storage = typeof(localStorage) != 'undefined';
479         this.selected_db = null;
480         this.selected_login = null;
481
482         if (this.has_local_storage && this.remember_creditentials) {
483             this.selected_db = localStorage.getItem('last_db_login_success');
484             this.selected_login = localStorage.getItem('last_login_login_success');
485         }
486         if (jQuery.deparam(jQuery.param.querystring()).debug != undefined) {
487             this.selected_db = this.selected_db || "trunk";
488             this.selected_login = this.selected_login || "admin";
489             this.selected_password = this.selected_password || "a";
490         }
491     },
492     start: function() {
493         var self = this;
494         this.rpc("/base/database/get_list", {}, function(result) {
495             self.db_list = result.db_list;
496             self.display();
497         }, function() {
498             self.display();
499         });
500     },
501     display: function() {
502         var self = this;
503
504         this.$element.html(QWeb.render("Login", this));
505         this.database = new openerp.base.Database(
506                 this, "oe_database", "oe_db_options");
507
508         this.$element.find('#oe-db-config').click(function() {
509             self.database.start();
510         });
511
512         this.$element.find("form").submit(this.on_submit);
513     },
514     on_login_invalid: function() {
515         this.$element.closest(".openerp").addClass("login-mode");
516     },
517     on_login_valid: function() {
518         this.$element.closest(".openerp").removeClass("login-mode");
519     },
520     on_submit: function(ev) {
521         ev.preventDefault();
522         var $e = this.$element;
523         var db = $e.find("form [name=db]").val();
524         var login = $e.find("form input[name=login]").val();
525         var password = $e.find("form input[name=password]").val();
526
527         this.do_login(db, login, password);
528     },
529     /**
530      * Performs actual login operation, and UI-related stuff
531      *
532      * @param {String} db database to log in
533      * @param {String} login user login
534      * @param {String} password user password
535      */
536     do_login: function (db, login, password) {
537         var self = this;
538         this.session.session_login(db, login, password, function() {
539             if(self.session.session_is_valid()) {
540                 if (self.has_local_storage) {
541                     if(self.remember_creditentials) {
542                         localStorage.setItem('last_db_login_success', db);
543                         localStorage.setItem('last_login_login_success', login);
544                     } else {
545                         localStorage.setItem('last_db_login_success', '');
546                         localStorage.setItem('last_login_login_success', '');
547                     }
548                 }
549                 self.on_login_valid();
550             } else {
551                 self.$element.addClass("login_invalid");
552                 self.on_login_invalid();
553             }
554         });
555     },
556     do_ask_login: function(continuation) {
557         this.on_login_invalid();
558         this.$element
559             .removeClass("login_invalid");
560         this.on_login_valid.add({
561             position: "last",
562             unique: true,
563             callback: continuation
564         });
565     },
566     on_logout: function() {
567         this.session.logout();
568     }
569 });
570
571 openerp.base.Header =  openerp.base.Widget.extend({
572     init: function(parent, element_id) {
573         this._super(parent, element_id);
574     },
575     start: function() {
576         this.do_update();
577     },
578     do_update: function() {
579         this.$element.html(QWeb.render("Header", this));
580         this.$element.find(".logout").click(this.on_logout);
581     },
582     on_logout: function() {}
583 });
584
585 openerp.base.Menu =  openerp.base.Widget.extend({
586     init: function(parent, element_id, secondary_menu_id) {
587         this._super(parent, element_id);
588         this.secondary_menu_id = secondary_menu_id;
589         this.$secondary_menu = $("#" + secondary_menu_id).hide();
590         this.menu = false;
591     },
592     start: function() {
593         this.rpc("/base/menu/load", {}, this.on_loaded);
594     },
595     on_loaded: function(data) {
596         this.data = data;
597         this.$element.html(QWeb.render("Menu", this.data));
598         for (var i = 0; i < this.data.data.children.length; i++) {
599             var v = { menu : this.data.data.children[i] };
600             this.$secondary_menu.append(QWeb.render("Menu.secondary", v));
601         }
602         this.$secondary_menu.find("div.menu_accordion").accordion({
603             animated : false,
604             autoHeight : false,
605             icons : false
606         });
607         this.$secondary_menu.find("div.submenu_accordion").accordion({
608             animated : false,
609             autoHeight : false,
610             active: false,
611             collapsible: true,
612             header: 'h4'
613         });
614
615         this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click);
616     },
617     on_menu_click: function(ev, id) {
618         id = id || 0;
619         var $menu, $parent, $secondary;
620
621         if (id) {
622             // We can manually activate a menu with it's id (for hash url mapping)
623             $menu = this.$element.find('a[data-menu=' + id + ']');
624             if (!$menu.length) {
625                 $menu = this.$secondary_menu.find('a[data-menu=' + id + ']');
626             }
627         } else {
628             $menu = $(ev.currentTarget);
629             id = $menu.data('menu');
630         }
631         if (this.$secondary_menu.has($menu).length) {
632             $secondary = $menu.parents('.menu_accordion');
633             $parent = this.$element.find('a[data-menu=' + $secondary.data('menu-parent') + ']');
634         } else {
635             $parent = $menu;
636             $secondary = this.$secondary_menu.find('.menu_accordion[data-menu-parent=' + $menu.attr('data-menu') + ']');
637         }
638
639         this.$secondary_menu.find('.menu_accordion').hide();
640         // TODO: ui-accordion : collapse submenus and expand the good one
641         $secondary.show();
642
643         if (id) {
644             this.rpc('/base/menu/action', {'menu_id': id},
645                     this.on_menu_action_loaded);
646         }
647
648         $('.active', this.$element.add(this.$secondary_menu.show())).removeClass('active');
649         $parent.addClass('active');
650         $menu.addClass('active');
651         $menu.parent('h4').addClass('active');
652
653         return !$menu.is(".leaf");
654     },
655     on_menu_action_loaded: function(data) {
656         var self = this;
657         if (data.action.length) {
658             var action = data.action[0][2];
659             self.on_action(action);
660         }
661     },
662     on_action: function(action) {
663     }
664 });
665
666 openerp.base.Homepage = openerp.base.Widget.extend({
667 });
668
669 openerp.base.Preferences = openerp.base.Widget.extend({
670 });
671
672 openerp.base.WebClient = openerp.base.Widget.extend({
673     init: function(element_id) {
674         this._super(null, element_id);
675         openerp.webclient = this;
676
677         QWeb.add_template("/base/static/src/xml/base.xml");
678         var params = {};
679         if(jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) {
680             this.$element.addClass("kitten-mode-activated");
681         }
682         this.$element.html(QWeb.render("Interface", params));
683
684         this.session = new openerp.base.Session(this,"oe_errors");
685         this.loading = new openerp.base.Loading(this,"oe_loading");
686         this.crashmanager =  new openerp.base.CrashManager(this);
687         this.crashmanager.start();
688
689         // Do you autorize this ? will be replaced by notify() in controller
690         openerp.base.Widget.prototype.notification = new openerp.base.Notification(this, "oe_notification");
691
692         this.header = new openerp.base.Header(this, "oe_header");
693         this.login = new openerp.base.Login(this, "oe_login");
694         this.header.on_logout.add(this.login.on_logout);
695
696         this.session.on_session_invalid.add(this.login.do_ask_login);
697         this.session.on_session_valid.add_last(this.header.do_update);
698         this.session.on_session_valid.add_last(this.on_logged);
699
700         this.menu = new openerp.base.Menu(this, "oe_menu", "oe_secondary_menu");
701         this.menu.on_action.add(this.on_menu_action);
702
703     },
704     start: function() {
705         this.session.start();
706         this.header.start();
707         this.login.start();
708         this.menu.start();
709         this.notification.notify("OpenERP Client", "The openerp client has been initialized.");
710     },
711     on_logged: function() {
712         if(this.action_manager)
713             this.action_manager.stop();
714         this.action_manager = new openerp.base.ActionManager(this);
715         this.action_manager.appendTo($("#oe_app"));
716
717         // if using saved actions, load the action and give it to action manager
718         var parameters = jQuery.deparam(jQuery.param.querystring());
719         if (parameters["s_action"] != undefined) {
720             var key = parseInt(parameters["s_action"], 10);
721             var self = this;
722             this.rpc("/base/session/get_session_action", {key:key}, function(action) {
723                 self.action_manager.do_action(action);
724             });
725         } else if (openerp._modules_loaded) { // TODO: find better option than this
726             this.load_url_state()
727         } else {
728             this.session.on_modules_loaded.add({
729                 callback: $.proxy(this, 'load_url_state'),
730                 unique: true,
731                 position: 'last'
732             })
733         }
734     },
735     /**
736      * Loads state from URL if any, or checks if there is a home action and
737      * loads that, assuming we're at the index
738      */
739     load_url_state: function () {
740         var self = this;
741         // TODO: add actual loading if there is url state to unpack, test on window.location.hash
742
743         // not logged in
744         if (!this.session.uid) { return; }
745         var ds = new openerp.base.DataSetSearch(this, 'res.users');
746         ds.read_ids([this.session.uid], ['action_id'], function (users) {
747             var home_action = users[0].action_id;
748             if (!home_action) {
749                 self.default_home();
750                 return;
751             }
752             self.execute_home_action(home_action[0], ds);
753         })
754     },
755     default_home: function () { 
756     },
757     /**
758      * Bundles the execution of the home action
759      *
760      * @param {Number} action action id
761      * @param {openerp.base.DataSet} dataset action executor
762      */
763     execute_home_action: function (action, dataset) {
764         var self = this;
765         this.rpc('/base/action/load', {
766             action_id: action,
767             context: dataset.get_context()
768         }, function (meh) {
769             var action = meh.result;
770             action.context = _.extend(action.context || {}, {
771                 active_id: false,
772                 active_ids: [false],
773                 active_model: dataset.model
774             });
775             self.action_manager.do_action(action);
776         });
777     },
778     on_menu_action: function(action) {
779         this.action_manager.do_action(action);
780     },
781     do_about: function() {
782     }
783 });
784
785 openerp.base.webclient = function(element_id) {
786     // TODO Helper to start webclient rename it openerp.base.webclient
787     var client = new openerp.base.WebClient(element_id);
788     client.start();
789     return client;
790 };
791
792 };
793
794 // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: