From 3d3b99108c68dc0621273dca700e88365b6d8012 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 18 Aug 2011 19:43:22 +0200 Subject: [IMP] Added on_value_changed callback to all form's fields bzr revid: fme@openerp.com-20110818174322-quezskn0jrryz9o2 --- addons/base/static/src/js/form.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 6eeff025e1f..6a7e64049a8 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -1,5 +1,5 @@ openerp.base.form = function (openerp) { - + var _t = openerp.base._t; openerp.base.views.add('form', 'openerp.base.FormView'); @@ -811,6 +811,7 @@ openerp.base.form.WidgetLabel = openerp.base.form.Widget.extend({ this.$element.find("label").dblclick(function() { var widget = self['for'] || self; self.log(widget.element_id , widget); + window.w = widget; }); } }); @@ -841,9 +842,12 @@ openerp.base.form.Field = openerp.base.form.Widget.extend({ this.value = value; this.invalid = false; this.update_dom(); + this.on_value_changed(); }, set_value_from_ui: function() { - this.value = undefined; + this.on_value_changed(); + }, + on_value_changed: function() { }, get_value: function() { return this.value; @@ -942,6 +946,7 @@ openerp.base.form.FieldChar = openerp.base.form.Field.extend({ }, set_value_from_ui: function() { this.value = this.$element.find('input').val(); + this._super(); }, validate: function() { this.invalid = false; @@ -1016,6 +1021,7 @@ openerp.base.form.FieldFloat = openerp.base.form.FieldChar.extend({ }, set_value_from_ui: function() { this.value = Number(this.$element.find('input').val().replace(/,/g, '.')); + this._super(); } }); @@ -1036,6 +1042,7 @@ openerp.base.form.FieldInteger = openerp.base.form.FieldFloat.extend({ }, set_value_from_ui: function() { this.value = Number(this.$element.find('input').val()); + this._super(); } }); @@ -1073,6 +1080,7 @@ openerp.base.form.FieldDatetime = openerp.base.form.Field.extend({ if (this.value) { this.value = this.format(this.value); } + this._super(); }, update_dom: function() { this._super.apply(this, arguments); @@ -1124,6 +1132,7 @@ openerp.base.form.FieldFloatTime = openerp.base.form.FieldChar.extend({ set_value_from_ui: function() { var time = this.$element.find('input').val().split(':'); this.set_value(parseInt(time[0], 10) + parseInt(time[1], 10) / 60); + this._super(); } }); @@ -1148,6 +1157,7 @@ openerp.base.form.FieldText = openerp.base.form.Field.extend({ }, set_value_from_ui: function() { this.value = this.$element.find('textarea').val(); + this._super(); }, validate: function() { this.invalid = false; @@ -1183,6 +1193,7 @@ openerp.base.form.FieldBoolean = openerp.base.form.Field.extend({ }, set_value_from_ui: function() { this.value = this.$element.find('input').is(':checked'); + this._super(); }, update_dom: function() { this._super.apply(this, arguments); @@ -1265,6 +1276,7 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({ var ikey = this.$element.find('select').val(); var option = _.detect(this.field_index, function(x) {return x.ikey === ikey;}); this.value = option === undefined ? false : option.ekey; + this._super(); }, update_dom: function() { this._super.apply(this, arguments); @@ -1529,7 +1541,6 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ this.on_ui_change(); } }, - set_value_from_ui: function() {}, set_value: function(value) { value = value || null; var self = this; @@ -1697,7 +1708,6 @@ openerp.base.form.FieldOne2Many = openerp.base.form.Field.extend({ }); } }, - set_value_from_ui: function() {}, set_value: function(value) { value = value || []; var self = this; @@ -1918,7 +1928,6 @@ openerp.base.form.FieldMany2Many = openerp.base.form.Field.extend({ get_value: function() { return [commands.replace_with(this.dataset.ids)]; }, - set_value_from_ui: function() {}, validate: function() { this.invalid = false; // TODO niv @@ -2192,13 +2201,6 @@ openerp.base.form.FormOpenPopup = openerp.base.OldWidget.extend({ } }); -openerp.base.form.FieldReference = openerp.base.form.FieldChar.extend({ - init: function(view, node) { - this._super(view, node); - //this.template = "FieldReference"; - } -}); - openerp.base.form.FieldBinary = openerp.base.form.Field.extend({ init: function(view, node) { this._super(view, node); @@ -2211,8 +2213,6 @@ openerp.base.form.FieldBinary = openerp.base.form.Field.extend({ this.$element.find('button.oe-binary-file-save').click(this.on_save_as); this.$element.find('.oe-binary-file-clear').click(this.on_clear); }, - set_value_from_ui: function() { - }, update_dom: function() { this._super.apply(this, arguments); this.$element.find('.oe-binary').toggle(!this.readonly); -- cgit v1.2.3 From 79001193eaf623a6e15167cc8bed8414e2783201 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 18 Aug 2011 19:45:08 +0200 Subject: [ADD] FormView: added field reference bzr revid: fme@openerp.com-20110818174508-zkpi5l5eocl3lj6z --- addons/base/static/src/js/form.js | 64 +++++++++++++++++++++++++++++++++++++ addons/base/static/src/xml/base.xml | 11 ++++++- 2 files changed, 74 insertions(+), 1 deletion(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 6a7e64049a8..d3056e618bf 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -2201,6 +2201,70 @@ openerp.base.form.FormOpenPopup = openerp.base.OldWidget.extend({ } }); +openerp.base.form.FieldReference = openerp.base.form.Field.extend({ + init: function(view, node) { + this._super(view, node); + this.template = "FieldReference"; + this.fields_view = { + fields: { + selection: { + selection: view.fields_view.fields[this.name].selection + }, + m2o: { + relation: null + } + } + } + this.get_fields_values = view.get_fields_values; + this.do_onchange = this.on_form_changed = this.on_nop; + this.widgets = {}; + this.fields = {}; + this.selection = new openerp.base.form.FieldSelection(this, { attrs: { + name: 'selection', + widget: 'selection' + }}); + this.selection.on_value_changed.add_last(this.on_selection_changed); + this.m2o = new openerp.base.form.FieldMany2One(this, { attrs: { + name: 'm2o', + widget: 'many2one' + }}); + }, + on_nop: function() { + }, + on_selection_changed: function() { + this.m2o.field.relation = this.selection.get_value(); + this.m2o.set_value(null); + }, + start: function() { + this._super(); + this.selection.start(); + this.m2o.start(); + }, + is_valid: function() { + return this.required === false || typeof(this.get_value()) === 'string'; + }, + is_dirty: function() { + return this.selection.is_dirty() || this.m2o.is_dirty(); + }, + set_value: function(value) { + this._super(value); + if (typeof(value) === 'string') { + var vals = value.split(','); + this.selection.set_value(vals[0]); + this.m2o.set_value(parseInt(vals[1], 10)); + } + }, + get_value: function() { + var model = this.selection.get_value(), + id = this.m2o.get_value(); + if (typeof(model) === 'string' && typeof(id) === 'number') { + return model + ',' + id; + } else { + return false; + } + } +}); + openerp.base.form.FieldBinary = openerp.base.form.Field.extend({ init: function(view, node) { this._super(view, node); diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 4f0be9bd552..34a729a028c 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -784,7 +784,16 @@
- + + + + + +
+ + + +
Date: Thu, 18 Aug 2011 21:21:50 +0200 Subject: [IMP] production mode by default, developers should use ?debug bzr revid: al@openerp.com-20110818192150-qtwh8u3eigmkz0k9 --- addons/base/static/src/css/base.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index e8d411b1ae1..30ca7a5231c 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -381,7 +381,7 @@ label.error { /* Header */ .openerp .header { height: 65px; - background: url("../img/header-background.png") repeat-x scroll left top transparent; + background: url("/base/static/src/img/header-background.png") repeat-x scroll left top transparent; color: #FFFFFF; letter-spacing: 0.5px; text-shadow: 0 1px 0 #333333; -- cgit v1.2.3 From ed5097650b236bbd7bb4b96690258a9dbfb9d2c9 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 18 Aug 2011 21:53:49 +0200 Subject: [IMP] more production mode move Session above session aware, jquery ui css is not absolute bzr revid: al@openerp.com-20110818195349-zebyew12sefo93ml --- addons/base/static/src/js/boot.js | 33 +- addons/base/static/src/js/core.js | 800 ++++++++++++++--------------- addons/base/static/src/js/list-editable.js | 2 +- 3 files changed, 405 insertions(+), 430 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/boot.js b/addons/base/static/src/js/boot.js index 3d1d1e75e7c..461d84b2253 100644 --- a/addons/base/static/src/js/boot.js +++ b/addons/base/static/src/js/boot.js @@ -14,8 +14,6 @@ /** @lends openerp */ var openerp = this.openerp = { - // debug flag - debug: true, // Per session namespace // openerp. will map to // openerp.sessions.sessionname. using a closure @@ -57,32 +55,11 @@ openerp.base = function(instance) { openerp.base.formats(instance); openerp.base.chrome(instance); openerp.base.data(instance); - if (openerp.base.views) { - openerp.base.views(instance); - } - if (openerp.base.search) { - openerp.base.search(instance); - } - if (openerp.base.list) { - openerp.base.list(instance); - } - if (openerp.base. m2o) { - openerp.base.m2o(instance); - } - if (openerp.base.form) { - openerp.base.form(instance); - } - if (openerp.base.list && openerp.base.list.editable) { - openerp.base.list.editable(instance); - } - if (openerp.web_mobile) { - openerp.web_mobile(instance); - } - if (openerp.base.view_tree) { - openerp.base.view_tree(instance); - } - if (openerp.base.data_export) { - openerp.base.data_export(instance); + files = ["views","search","list","form","list_editable","web_mobile","view_tree","data_export"]; + for(i=0; i').text(v).appendTo($('body')); - } - if(notify && this.notification) { - this.notification.notify("Logging:",v); - } - } - } - } -}); - -openerp.base.Widget = openerp.base.SessionAware.extend({ - /** - * The name of the QWeb template that will be used for rendering. Must be - * redefined in subclasses or the default render() method can not be used. - * - * @type string - */ - template: null, - /** - * The prefix used to generate an id automatically. Should be redefined in - * subclasses. If it is not defined, a generic identifier will be used. - * - * @type string - */ - identifier_prefix: 'generic-identifier-', - /** - * Construct the widget and set its parent if a parent is given. - * - * @constructs - * @param {openerp.base.Widget} parent Binds the current instance to the given Widget instance. - * When that widget is destroyed by calling stop(), the current instance will be - * destroyed too. Can be null. - * @param {String} element_id Deprecated. Sets the element_id. Only useful when you want - * to bind the current Widget to an already existing part of the DOM, which is not compatible - * with the DOM insertion methods provided by the current implementation of Widget. So - * for new components this argument should not be provided any more. - */ - init: function(parent, /** @deprecated */ element_id) { - this._super((parent || {}).session); - // if given an element_id, try to get the associated DOM element and save - // a reference in this.$element. Else just generate a unique identifier. - this.element_id = element_id; - this.element_id = this.element_id || _.uniqueId(this.identifier_prefix); - var tmp = document.getElementById(this.element_id); - this.$element = tmp ? $(tmp) : undefined; - - this.widget_parent = parent; - this.widget_children = []; - if(parent && parent.widget_children) { - parent.widget_children.push(this); - } - // useful to know if the widget was destroyed and should not be used anymore - this.widget_is_stopped = false; - }, - /** - * Render the current widget and appends it to the given jQuery object or Widget. - * - * @param target A jQuery object or a Widget instance. - */ - appendTo: function(target) { - var self = this; - return this._render_and_insert(function(t) { - self.$element.appendTo(t); - }, target); - }, - /** - * Render the current widget and prepends it to the given jQuery object or Widget. - * - * @param target A jQuery object or a Widget instance. - */ - prependTo: function(target) { - var self = this; - return this._render_and_insert(function(t) { - self.$element.prependTo(t); - }, target); - }, - /** - * Render the current widget and inserts it after to the given jQuery object or Widget. - * - * @param target A jQuery object or a Widget instance. - */ - insertAfter: function(target) { - var self = this; - return this._render_and_insert(function(t) { - self.$element.insertAfter(t); - }, target); - }, - /** - * Render the current widget and inserts it before to the given jQuery object or Widget. - * - * @param target A jQuery object or a Widget instance. - */ - insertBefore: function(target) { - var self = this; - return this._render_and_insert(function(t) { - self.$element.insertBefore(t); - }, target); - }, - _render_and_insert: function(insertion, target) { - var rendered = this.render(); - this.$element = $(rendered); - if (target instanceof openerp.base.Widget) - target = target.$element; - insertion(target); - return this.start(); - }, - /** - * Renders the widget using QWeb, `this.template` must be defined. - * The context given to QWeb contains the "widget" key that references `this`. - * - * @param {Object} additional Additional context arguments to pass to the template. - */ - render: function (additional) { - return QWeb.render(this.template, _.extend({widget: this}, additional || {})); - }, - /** - * Method called after rendering. Mostly used to bind actions, perform asynchronous - * calls, etc... - * - * By convention, the method should return a promise to inform the caller when - * this widget has been initialized. - * - * @returns {jQuery.Deferred} - */ - start: function() { - if (!this.$element) { - var tmp = document.getElementById(this.element_id); - this.$element = tmp ? $(tmp) : undefined; - } - return $.Deferred().done().promise(); - }, - /** - * Destroys the current widget, also destory all its children before destroying itself. - */ - stop: function() { - _.each(_.clone(this.widget_children), function(el) { - el.stop(); - }); - if(this.$element != null) { - this.$element.remove(); - } - if (this.widget_parent && this.widget_parent.widget_children) { - this.widget_parent.widget_children = _.without(this.widget_parent.widget_children, this); - } - this.widget_parent = null; - this.widget_is_stopped = true; - }, - /** - * Inform the action manager to do an action. Of course, this suppose that - * the action manager can be found amongst the ancestors of the current widget. - * If that's not the case this method will simply return `false`. - */ - do_action: function(action, on_finished) { - if (this.widget_parent) { - return this.widget_parent.do_action(action, on_finished); - } - return false; - }, - do_notify: function() { - if (this.widget_parent) { - return this.widget_parent.do_notify.apply(this,arguments); - } - return false; - }, - do_warn: function() { - if (this.widget_parent) { - return this.widget_parent.do_warn.apply(this,arguments); - } - return false; - }, - rpc: function(url, data, success, error) { - var def = $.Deferred().then(success, error); - var self = this; - this._super(url, data). then(function() { - if (!self.widget_is_stopped) - def.resolve.apply(def, arguments); - }, function() { - if (!self.widget_is_stopped) - def.reject.apply(def, arguments); - }); - return def.promise(); - } -}); - -/** - * @deprecated - * For retro compatibility only, the only difference with is that render() uses - * directly `this` instead of context with a "widget" key. - */ -openerp.base.OldWidget = openerp.base.Widget.extend({ - render: function (additional) { - return QWeb.render(this.template, _.extend(_.extend({}, this), additional || {})); - } -}); - -openerp.base.TranslationDataBase = openerp.base.Class.extend({ - init: function() { - this.db = {}; - this.parameters = {"direction": 'ltr', - "date_format": '%m/%d/%Y', - "time_format": '%H:%M:%S', - "grouping": "[]", - "decimal_point": ".", - "thousands_sep": ","}; - }, - set_bundle: function(translation_bundle) { - var self = this; - this.db = {}; - var modules = _.keys(translation_bundle.modules).sort(); - if (_.include(modules, "base")) { - modules = ["base"].concat(_.without(modules, "base")); - } - _.each(modules, function(name) { - self.add_module_translation(translation_bundle.modules[name]); - }); - if (translation_bundle.lang_parameters) { - this.parameters = translation_bundle.lang_parameters; - } - }, - add_module_translation: function(mod) { - var self = this; - _.each(mod.messages, function(message) { - if (self.db[message.id] === undefined) { - self.db[message.id] = message.string; - } - }); - }, - build_translation_function: function() { - var self = this; - var fcnt = function(str) { - var tmp = self.get(str); - return tmp === undefined ? str : tmp; - } - fcnt.database = this; - return fcnt; - }, - get: function(key) { - if (this.db[key]) - return this.db[key]; - return undefined; - } -}); - -openerp.base._t = new openerp.base.TranslationDataBase().build_translation_function(); - openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.base.Session# */{ /** * @constructs @@ -625,7 +332,7 @@ openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.b this.server = (server == undefined) ? location.hostname : server; this.port = (port == undefined) ? location.port : port; this.rpc_mode = (server == location.hostname) ? "ajax" : "jsonp"; - this.debug = true; + this.debug = (window.location.search.indexOf('?debug') !== -1); this.db = ""; this.login = ""; this.password = ""; @@ -765,143 +472,434 @@ openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.b success_callback(); }); }, - session_logout: function() { - this.uid = false; + session_logout: function() { + this.uid = false; + }, + /** + * Reloads uid and session_id from local storage, if they exist + */ + session_restore: function () { + this.uid = this.get_cookie('uid'); + this.session_id = this.get_cookie('session_id'); + this.db = this.get_cookie('db'); + this.login = this.get_cookie('login'); + this.user_context = this.get_cookie("user_context"); + // we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login + // then call on_session_valid + this.on_session_valid(); + }, + /** + * Saves the session id and uid locally + */ + session_save: function () { + this.set_cookie('uid', this.uid); + this.set_cookie('session_id', this.session_id); + this.set_cookie('db', this.db); + this.set_cookie('login', this.login); + this.set_cookie('user_context', this.user_context); + }, + logout: function() { + delete this.uid; + delete this.session_id; + delete this.db; + delete this.login; + this.set_cookie('uid', ''); + this.set_cookie('session_id', ''); + this.set_cookie('db', ''); + this.set_cookie('login', ''); + this.on_session_invalid(function() {}); + }, + /** + * Fetches a cookie stored by an openerp session + * + * @private + * @param name the cookie's name + */ + get_cookie: function (name) { + var nameEQ = this.element_id + '|' + name + '='; + var cookies = document.cookie.split(';'); + for(var i=0; i').text(v).appendTo($('body')); + } + if(notify && this.notification) { + this.notification.notify("Logging:",v); + } + } + } + } +}); + +openerp.base.Widget = openerp.base.SessionAware.extend({ + /** + * The name of the QWeb template that will be used for rendering. Must be + * redefined in subclasses or the default render() method can not be used. + * + * @type string + */ + template: null, + /** + * The prefix used to generate an id automatically. Should be redefined in + * subclasses. If it is not defined, a generic identifier will be used. + * + * @type string + */ + identifier_prefix: 'generic-identifier-', + /** + * Construct the widget and set its parent if a parent is given. + * + * @constructs + * @param {openerp.base.Widget} parent Binds the current instance to the given Widget instance. + * When that widget is destroyed by calling stop(), the current instance will be + * destroyed too. Can be null. + * @param {String} element_id Deprecated. Sets the element_id. Only useful when you want + * to bind the current Widget to an already existing part of the DOM, which is not compatible + * with the DOM insertion methods provided by the current implementation of Widget. So + * for new components this argument should not be provided any more. + */ + init: function(parent, /** @deprecated */ element_id) { + this._super((parent || {}).session); + // if given an element_id, try to get the associated DOM element and save + // a reference in this.$element. Else just generate a unique identifier. + this.element_id = element_id; + this.element_id = this.element_id || _.uniqueId(this.identifier_prefix); + var tmp = document.getElementById(this.element_id); + this.$element = tmp ? $(tmp) : undefined; + + this.widget_parent = parent; + this.widget_children = []; + if(parent && parent.widget_children) { + parent.widget_children.push(this); + } + // useful to know if the widget was destroyed and should not be used anymore + this.widget_is_stopped = false; + }, + /** + * Render the current widget and appends it to the given jQuery object or Widget. + * + * @param target A jQuery object or a Widget instance. + */ + appendTo: function(target) { + var self = this; + return this._render_and_insert(function(t) { + self.$element.appendTo(t); + }, target); + }, + /** + * Render the current widget and prepends it to the given jQuery object or Widget. + * + * @param target A jQuery object or a Widget instance. + */ + prependTo: function(target) { + var self = this; + return this._render_and_insert(function(t) { + self.$element.prependTo(t); + }, target); }, /** - * Reloads uid and session_id from local storage, if they exist + * Render the current widget and inserts it after to the given jQuery object or Widget. + * + * @param target A jQuery object or a Widget instance. */ - session_restore: function () { - this.uid = this.get_cookie('uid'); - this.session_id = this.get_cookie('session_id'); - this.db = this.get_cookie('db'); - this.login = this.get_cookie('login'); - this.user_context = this.get_cookie("user_context"); - // we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login - // then call on_session_valid - this.on_session_valid(); + insertAfter: function(target) { + var self = this; + return this._render_and_insert(function(t) { + self.$element.insertAfter(t); + }, target); }, /** - * Saves the session id and uid locally + * Render the current widget and inserts it before to the given jQuery object or Widget. + * + * @param target A jQuery object or a Widget instance. */ - session_save: function () { - this.set_cookie('uid', this.uid); - this.set_cookie('session_id', this.session_id); - this.set_cookie('db', this.db); - this.set_cookie('login', this.login); - this.set_cookie('user_context', this.user_context); + insertBefore: function(target) { + var self = this; + return this._render_and_insert(function(t) { + self.$element.insertBefore(t); + }, target); }, - logout: function() { - delete this.uid; - delete this.session_id; - delete this.db; - delete this.login; - this.set_cookie('uid', ''); - this.set_cookie('session_id', ''); - this.set_cookie('db', ''); - this.set_cookie('login', ''); - this.on_session_invalid(function() {}); + _render_and_insert: function(insertion, target) { + var rendered = this.render(); + this.$element = $(rendered); + if (target instanceof openerp.base.Widget) + target = target.$element; + insertion(target); + return this.start(); }, /** - * Fetches a cookie stored by an openerp session + * Renders the widget using QWeb, `this.template` must be defined. + * The context given to QWeb contains the "widget" key that references `this`. * - * @private - * @param name the cookie's name + * @param {Object} additional Additional context arguments to pass to the template. */ - get_cookie: function (name) { - var nameEQ = this.element_id + '|' + name + '='; - var cookies = document.cookie.split(';'); - for(var i=0; i Date: Thu, 18 Aug 2011 22:31:47 +0200 Subject: [IMP] Use Ubuntu font bzr revid: fme@openerp.com-20110818203147-3utl21mr2xpom01n --- addons/base/static/src/css/base.css | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 30ca7a5231c..21016dcb5a7 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -1,11 +1,17 @@ /* TODO: separate openerp web client page css from openerp views css */ -body { +body.openerp { padding: 0; margin: 0; - font-family: helvetica, arial, sans-serif; + height: 100%; + min-width: 1000px; + overflow-y: scroll; font-size: 80%; } +body.openerp, .openerp textarea, .openerp input, .openerp select, .openerp option, .openerp button, .openerp .ui-widget { + font-family: Ubuntu, Helvetica, sans-serif; +} + .oe_box { border: 1px solid #aaf; padding: 2px; @@ -20,13 +26,6 @@ body { margin: 0; } - -body.openerp { - height: 100%; - min-width: 1000px; - overflow-y: scroll; -} - .openerp .oe-number { text-align: right !important; } @@ -120,7 +119,6 @@ body.openerp { -moz-border-radius: 3px; -webkit-border-radius: 3px; color: white; - font-family: Ubuntu, Helvetica, sans-serif; font-size: 16px; font-weight: bold; padding: 5px; @@ -497,7 +495,6 @@ label.error { color: #666666; font-weight: bold; font-size: 0.8em; - font-family: Ubuntu, Helvetica, sans-serif; text-align: center; } .openerp div.oe_footer p.oe_footer_powered a { @@ -515,7 +512,6 @@ label.error { .openerp h2.oe_view_title { font-size: 175%; font-weight: normal; - font-family: Ubuntu, Helvetica, sans-serif; margin: 2px 0; color: #252424; text-shadow: white 0 1px 0; @@ -859,7 +855,7 @@ label.error { -webkit-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; - padding: 2px; + padding: 0 2px 0 2px; border: 1px solid #999; -moz-border-radius: 3px; -webkit-border-radius: 3px; @@ -988,7 +984,6 @@ label.error { margin: 0; width: 180px; height: 100%; - font-family: Ubuntu, Helvetica, sans-serif; font-size: 0.9em; } @@ -1046,7 +1041,6 @@ label.error { .openerp .view-manager-main-sidebar h2 { margin:0; - font-family: Ubuntu, Helvetica, sans-serif; font-size: 1.15em; color: #8E8E8E; text-shadow: white 0 1px 0; -- cgit v1.2.3 From 47e709eb735f0fab8ee53c802e1352ee445d52cc Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 19 Aug 2011 00:57:21 +0200 Subject: [IMP] read_slice fields outside option [] are probably bugs bzr revid: al@openerp.com-20110818225721-tn1vl2450tbe11d6 --- addons/base/static/src/js/data.js | 15 +++++++++------ addons/base/static/src/js/form.js | 4 +--- addons/base/static/src/js/list.js | 11 +++++------ addons/base/static/src/js/view_tree.js | 2 +- addons/base/static/src/js/views.js | 24 ++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 16 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js index 244c057d544..2dac0bb5ae4 100644 --- a/addons/base/static/src/js/data.js +++ b/addons/base/static/src/js/data.js @@ -286,14 +286,16 @@ openerp.base.DataSet = openerp.base.Widget.extend( /** @lends openerp.base.Data * Read a slice of the records represented by this DataSet, based on its * domain and context. * + * @param {Array} [fields] fields to read and return, by default all fields are returned * @params {Object} options - * @param {Array} [options.fields] fields to read and return, by default all fields are returned * @param {Number} [options.offset=0] The index from which selected records should be returned * @param {Number} [options.limit=null] The maximum number of records to return * @param {Function} callback function called with read_slice result * @returns {$.Deferred} */ - read_slice: function (options, callback) { return null; }, + read_slice: function (fields, options, callback) { + return null; + }, /** * Reads the current dataset record (from its index) * @@ -478,11 +480,12 @@ openerp.base.DataSetStatic = openerp.base.DataSet.extend({ // all local records this.ids = ids || []; }, - read_slice: function (options, callback) { + read_slice: function (fields, options, callback) { + // TODO remove fields from options var self = this, offset = options.offset || 0, limit = options.limit || false, - fields = options.fields || false; + fields = fields || false; var end_pos = limit && limit !== -1 ? offset + limit : undefined; return this.read_ids(this.ids.slice(offset, end_pos), fields, callback); }, @@ -532,12 +535,12 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({ * @param {Function} callback function called with read_slice result * @returns {$.Deferred} */ - read_slice: function (options, callback) { + read_slice: function (fields, options, callback) { var self = this; var offset = options.offset || 0; return this.rpc('/base/dataset/search_read', { model: this.model, - fields: options.fields || false, + fields: fields || false, domain: this.get_domain(options.domain), context: this.get_context(options.context), sort: this.sort(), diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index d3056e618bf..c85d1fd4cb2 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -458,9 +458,7 @@ openerp.base.form.SidebarAttachments = openerp.base.Widget.extend({ ['res_model', '=', this.view.dataset.model], ['res_id', '=', this.view.datarecord.id], ['type', 'in', ['binary', 'url']] - ])).read_slice( - {fields: ['name', 'url', 'type']}, - this.on_attachments_loaded); + ])).read_slice(['name', 'url', 'type'], this.on_attachments_loaded); } }, on_attachments_loaded: function(attachments) { diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js index a0440221520..d715c3600be 100644 --- a/addons/base/static/src/js/list.js +++ b/addons/base/static/src/js/list.js @@ -476,7 +476,8 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi */ do_activate_record: function (index, id, dataset) { var self = this; - this.dataset.read_slice({ + // TODO is it needed ? + this.dataset.read_slice([],{ context: dataset.get_context(), domain: dataset.get_domain() }, function () { @@ -1034,11 +1035,9 @@ openerp.base.ListView.Groups = openerp.base.Class.extend( /** @lends openerp.bas d = new $.Deferred(), page = this.datagroup.openable ? this.page : view.page; - dataset.read_slice({ - fields: _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name'), - offset: page * limit, - limit: limit - }, function (records) { + var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name'); + var options = { offset: page * limit, limit: limit }; + dataset.read_slice(fields, options , function (records) { if (!self.datagroup.openable) { view.configure_pager(dataset); } else { diff --git a/addons/base/static/src/js/view_tree.js b/addons/base/static/src/js/view_tree.js index 5c3c7457e1c..59544a998b3 100644 --- a/addons/base/static/src/js/view_tree.js +++ b/addons/base/static/src/js/view_tree.js @@ -72,7 +72,7 @@ openerp.base.TreeView = openerp.base.View.extend({ 'toolbar': has_toolbar })); - this.dataset.read_slice({fields: this.fields_list()}, function (records) { + this.dataset.read_slice(this.fields_list(), {}, function (records) { if (!has_toolbar) { // WARNING: will do a second read on the same ids, but only on // first load so not very important diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index f21c6387d32..ad75268156f 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -17,6 +17,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({ this.dialog = null; this.dialog_viewmanager = null; this.client_widget = null; + this.url = {} }, render: function() { return "
"; @@ -35,6 +36,28 @@ openerp.base.ActionManager = openerp.base.Widget.extend({ this.inner_viewmanager = null; } }, + url_update: function(action) { + // this.url = { + // "model": action.model, + // "domain": action.domain, + // }; + // action.res_model + // action.domain + // action.context + // after + // action.views + // action.res_id + // mode + // menu + }, + url_stringify: function(action) { + }, + url_parse: function(action) { + }, + on_url_update: function(url) { + }, + do_url_action: function(url) { + }, do_action: function(action, on_close) { var type = action.type.replace(/\./g,'_'); var popup = action.target === 'new'; @@ -69,6 +92,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({ this.inner_stop(); this.inner_viewmanager = new openerp.base.ViewManagerAction(this, action); this.inner_viewmanager.appendTo(this.$element); + this.url_update(action); } /* new window code this.rpc("/base/session/save_session_action", { the_action : action}, function(key) { -- cgit v1.2.3 From 056a91f72439ae99f1df02a75c30aafc13bd3648 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 19 Aug 2011 01:38:11 +0200 Subject: [IMP] web_rpc example bzr revid: al@openerp.com-20110818233811-yiee3czhbtc6p3ob --- addons/base/static/src/js/core.js | 2 +- addons/base/static/src/js/data.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/core.js b/addons/base/static/src/js/core.js index 58d19de9008..e0ec45c3e6f 100644 --- a/addons/base/static/src/js/core.js +++ b/addons/base/static/src/js/core.js @@ -323,7 +323,6 @@ openerp.base.CallbackEnabled = openerp.base.Class.extend({ openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.base.Session# */{ /** * @constructs - * @param element_id to use for exception reporting * @param server * @param port */ @@ -344,6 +343,7 @@ openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.b this.context = {}; this.shortcuts = []; this.active_id = null; + this.session = this; }, start: function() { this.session_restore(); diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js index 2dac0bb5ae4..04c23224806 100644 --- a/addons/base/static/src/js/data.js +++ b/addons/base/static/src/js/data.js @@ -537,6 +537,7 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({ */ read_slice: function (fields, options, callback) { var self = this; + var options = options || {}; var offset = options.offset || 0; return this.rpc('/base/dataset/search_read', { model: this.model, -- cgit v1.2.3 From 7b79fd47d5a733b1cfdf996d521c2235f167156b Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 19 Aug 2011 04:01:56 +0200 Subject: [IMP] database creation cleanups bzr revid: al@openerp.com-20110819020156-yo41xcjnxiwqtkwr --- addons/base/static/src/js/boot.js | 2 -- addons/base/static/src/js/chrome.js | 17 ++--------------- addons/base/static/src/xml/base.xml | 11 +++-------- 3 files changed, 5 insertions(+), 25 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/boot.js b/addons/base/static/src/js/boot.js index 461d84b2253..e8807064122 100644 --- a/addons/base/static/src/js/boot.js +++ b/addons/base/static/src/js/boot.js @@ -12,7 +12,6 @@ return; var session_counter = 0; - /** @lends openerp */ var openerp = this.openerp = { // Per session namespace // openerp. will map to @@ -42,7 +41,6 @@ } return new_instance; } - // TODO add initrpc to init core only for RPC }; })(); diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 927a000f002..3aff7b5e402 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -291,8 +291,7 @@ openerp.base.Database = openerp.base.Widget.extend({ }, do_create: function() { var self = this; - self.$option_id.html(QWeb.render("CreateDB", self)); - + self.$option_id.html(QWeb.render("Database.CreateDB", self)); self.$option_id.find("form[name=create_db_form]").validate({ submitHandler: function (form) { var fields = $(form).serializeArray(); @@ -314,11 +313,9 @@ openerp.base.Database = openerp.base.Widget.extend({ } }); }, - do_drop: function() { var self = this; self.$option_id.html(QWeb.render("DropDB", self)); - self.$option_id.find("form[name=drop_db_form]").validate({ submitHandler: function (form) { var $form = $(form), @@ -341,7 +338,6 @@ openerp.base.Database = openerp.base.Widget.extend({ } }); }, - wait_for_file: function (token, cleanup) { var self = this, cookie_name = 'fileToken', @@ -362,7 +358,7 @@ openerp.base.Database = openerp.base.Widget.extend({ if (cleanup) { cleanup(); } } - }, 100); + }, 200); }, do_backup: function() { var self = this; @@ -402,7 +398,6 @@ openerp.base.Database = openerp.base.Widget.extend({ } }); }, - do_restore: function() { var self = this; self.$option_id.html(QWeb.render("RestoreDB", self)); @@ -441,7 +436,6 @@ openerp.base.Database = openerp.base.Widget.extend({ } }); }, - do_change_password: function() { var self = this; self.$option_id.html(QWeb.render("Change_DB_Pwd", self)); @@ -836,13 +830,6 @@ openerp.base.WebClient = openerp.base.Widget.extend({ } }); -openerp.base.webclient = function(element_id) { - // TODO Helper to start webclient rename it openerp.base.webclient - var client = new openerp.base.WebClient(element_id); - client.start(); - return client; -}; - }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 34a729a028c..81255fb3e75 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -67,7 +67,7 @@
  • Back to Login
  • - +
    @@ -79,8 +79,7 @@
    - + @@ -95,9 +94,7 @@ @@ -367,7 +364,6 @@ t-att-data-shortcut-id="shortcut.id" > -
    @@ -1175,7 +1171,6 @@ Export -
    -- cgit v1.2.3 From eaf0914e2a152e1ff50c4ec2d0956584abedd04a Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 19 Aug 2011 16:39:47 +0200 Subject: [FIX] incompatibility between static home and ActionManager convert static home to a client action, fix ActionManager's handling of client actions to play correctly with the Widget lifecycle (and clean any client action displayed in case it's switching to an inner act_window) bzr revid: xmo@openerp.com-20110819143947-29dzerce0d42fhel --- addons/base/static/src/js/views.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index ad75268156f..cb9b7d364cf 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -30,11 +30,15 @@ openerp.base.ActionManager = openerp.base.Widget.extend({ this.dialog = null; } }, - inner_stop: function () { + content_stop: function () { if (this.inner_viewmanager) { this.inner_viewmanager.stop(); this.inner_viewmanager = null; } + if (this.client_widget) { + this.client_widget.stop(); + this.client_widget = null; + } }, url_update: function(action) { // this.url = { @@ -89,7 +93,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({ this.dialog.open(); } else { this.dialog_stop(); - this.inner_stop(); + this.content_stop(); this.inner_viewmanager = new openerp.base.ViewManagerAction(this, action); this.inner_viewmanager.appendTo(this.$element); this.url_update(action); @@ -114,8 +118,9 @@ openerp.base.ActionManager = openerp.base.Widget.extend({ }); }, ir_actions_client: function (action) { - this.client_widget = openerp.base.client_actions.get_object(action.tag); - new this.client_widget(this, this.element_id, action.params).start(); + this.content_stop(); + var ClientWidget = openerp.base.client_actions.get_object(action.tag); + (this.client_widget = new ClientWidget(this, action.params)).appendTo(this); } }); -- cgit v1.2.3 From bf509d08c37f773a82ec7ec29fdc9ba81f0e30d2 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 19 Aug 2011 16:46:56 +0200 Subject: [imp] Refactoring of dates conversion functions. bzr revid: nicolas.vanhoren@openerp.com-20110819144656-g13y3jfsfgy5pspb --- addons/base/static/src/js/form.js | 8 ++++---- addons/base/static/src/js/formats.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index c85d1fd4cb2..272848338f7 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -1098,8 +1098,8 @@ openerp.base.form.FieldDatetime = openerp.base.form.Field.extend({ focus: function() { this.$element.find('input').focus(); }, - parse: openerp.base.parse_datetime, - format: openerp.base.format_datetime + parse: openerp.base.str_to_datetime, + format: openerp.base.datetime_to_str }); openerp.base.form.FieldDate = openerp.base.form.FieldDatetime.extend({ @@ -1108,8 +1108,8 @@ openerp.base.form.FieldDate = openerp.base.form.FieldDatetime.extend({ this.jqueryui_object = 'datepicker'; this.validation_regex = /^\d+-\d+-\d+$/; }, - parse: openerp.base.parse_date, - format: openerp.base.format_date + parse: openerp.base.str_to_date, + format: openerp.base.date_to_str }); openerp.base.form.FieldFloatTime = openerp.base.form.FieldChar.extend({ diff --git a/addons/base/static/src/js/formats.js b/addons/base/static/src/js/formats.js index 074cabe5eee..59dd7d9a787 100644 --- a/addons/base/static/src/js/formats.js +++ b/addons/base/static/src/js/formats.js @@ -11,7 +11,7 @@ openerp.base.formats = function(openerp) { * @param {String} str A string representing a datetime. * @returns {Date} */ -openerp.base.parse_datetime = function(str) { +openerp.base.str_to_datetime = function(str) { if(!str) { return str; } @@ -34,7 +34,7 @@ openerp.base.parse_datetime = function(str) { * @param {String} str A string representing a date. * @returns {Date} */ -openerp.base.parse_date = function(str) { +openerp.base.str_to_date = function(str) { if(!str) { return str; } @@ -57,7 +57,7 @@ openerp.base.parse_date = function(str) { * @param {String} str A string representing a time. * @returns {Date} */ -openerp.base.parse_time = function(str) { +openerp.base.str_to_time = function(str) { if(!str) { return str; } @@ -96,7 +96,7 @@ var zpad = function(str, size) { * @param {Date} obj * @returns {String} A string representing a datetime. */ -openerp.base.format_datetime = function(obj) { +openerp.base.datetime_to_str = function(obj) { if (!obj) { return false; } @@ -112,7 +112,7 @@ openerp.base.format_datetime = function(obj) { * @param {Date} obj * @returns {String} A string representing a date. */ -openerp.base.format_date = function(obj) { +openerp.base.date_to_str = function(obj) { if (!obj) { return false; } @@ -127,7 +127,7 @@ openerp.base.format_date = function(obj) { * @param {Date} obj * @returns {String} A string representing a time. */ -openerp.base.format_time = function(obj) { +openerp.base.time_to_str = function(obj) { if (!obj) { return false; } -- cgit v1.2.3 From e6d99526f0343c6198804b38de221c1c9b1bf1b7 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 19 Aug 2011 16:55:43 +0200 Subject: [imp] separated apples and cucumbers bzr revid: nicolas.vanhoren@openerp.com-20110819145543-q2q4admsahmawkbd --- addons/base/static/src/js/boot.js | 1 + addons/base/static/src/js/dates.js | 138 +++++++++++++++++++++++++++++++++++ addons/base/static/src/js/formats.js | 134 ---------------------------------- 3 files changed, 139 insertions(+), 134 deletions(-) create mode 100644 addons/base/static/src/js/dates.js (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/boot.js b/addons/base/static/src/js/boot.js index e8807064122..fff710a1d68 100644 --- a/addons/base/static/src/js/boot.js +++ b/addons/base/static/src/js/boot.js @@ -50,6 +50,7 @@ openerp.base = function(instance) { openerp.base.core(instance); + openerp.base.dates(instance); openerp.base.formats(instance); openerp.base.chrome(instance); openerp.base.data(instance); diff --git a/addons/base/static/src/js/dates.js b/addons/base/static/src/js/dates.js new file mode 100644 index 00000000000..3d3948fa524 --- /dev/null +++ b/addons/base/static/src/js/dates.js @@ -0,0 +1,138 @@ + +openerp.base.dates = function(openerp) { + +/** + * Converts a string to a Date javascript object using OpenERP's + * datetime string format (exemple: '2011-12-01 15:12:35'). + * + * The timezone is assumed to be UTC (standard for OpenERP 6.1) + * and will be converted to the browser's timezone. + * + * @param {String} str A string representing a datetime. + * @returns {Date} + */ +openerp.base.str_to_datetime = function(str) { + if(!str) { + return str; + } + var regex = /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/; + var res = regex.exec(str); + if ( res[0] != str ) { + throw "'" + str + "' is not a valid datetime"; + } + var obj = Date.parse(str + " GMT"); + if (! obj) { + throw "'" + str + "' is not a valid datetime"; + } + return obj; +}; + +/** + * Converts a string to a Date javascript object using OpenERP's + * date string format (exemple: '2011-12-01'). + * + * @param {String} str A string representing a date. + * @returns {Date} + */ +openerp.base.str_to_date = function(str) { + if(!str) { + return str; + } + var regex = /\d\d\d\d-\d\d-\d\d/; + var res = regex.exec(str); + if ( res[0] != str ) { + throw "'" + str + "' is not a valid date"; + } + var obj = Date.parse(str); + if (! obj) { + throw "'" + str + "' is not a valid date"; + } + return obj; +}; + +/** + * Converts a string to a Date javascript object using OpenERP's + * time string format (exemple: '15:12:35'). + * + * @param {String} str A string representing a time. + * @returns {Date} + */ +openerp.base.str_to_time = function(str) { + if(!str) { + return str; + } + var regex = /\d\d:\d\d:\d\d/; + var res = regex.exec(str); + if ( res[0] != str ) { + throw "'" + str + "' is not a valid time"; + } + var obj = Date.parse(str); + if (! obj) { + throw "'" + str + "' is not a valid time"; + } + return obj; +}; + +/* + * Left-pad provided arg 1 with zeroes until reaching size provided by second + * argument. + * + * @param {Number|String} str value to pad + * @param {Number} size size to reach on the final padded value + * @returns {String} padded string + */ +var zpad = function(str, size) { + str = "" + str; + return new Array(size - str.length + 1).join('0') + str; +}; + +/** + * Converts a Date javascript object to a string using OpenERP's + * datetime string format (exemple: '2011-12-01 15:12:35'). + * + * The timezone of the Date object is assumed to be the one of the + * browser and it will be converted to UTC (standard for OpenERP 6.1). + * + * @param {Date} obj + * @returns {String} A string representing a datetime. + */ +openerp.base.datetime_to_str = function(obj) { + if (!obj) { + return false; + } + return zpad(obj.getUTCFullYear(),4) + "-" + zpad(obj.getUTCMonth() + 1,2) + "-" + + zpad(obj.getUTCDate(),2) + " " + zpad(obj.getUTCHours(),2) + ":" + + zpad(obj.getUTCMinutes(),2) + ":" + zpad(obj.getUTCSeconds(),2); +}; + +/** + * Converts a Date javascript object to a string using OpenERP's + * date string format (exemple: '2011-12-01'). + * + * @param {Date} obj + * @returns {String} A string representing a date. + */ +openerp.base.date_to_str = function(obj) { + if (!obj) { + return false; + } + return zpad(obj.getFullYear(),4) + "-" + zpad(obj.getMonth() + 1,2) + "-" + + zpad(obj.getDate(),2); +}; + +/** + * Converts a Date javascript object to a string using OpenERP's + * time string format (exemple: '15:12:35'). + * + * @param {Date} obj + * @returns {String} A string representing a time. + */ +openerp.base.time_to_str = function(obj) { + if (!obj) { + return false; + } + return zpad(obj.getHours(),2) + ":" + zpad(obj.getMinutes(),2) + ":" + + zpad(obj.getSeconds(),2); +}; + +}; diff --git a/addons/base/static/src/js/formats.js b/addons/base/static/src/js/formats.js index 59dd7d9a787..750c5a12167 100644 --- a/addons/base/static/src/js/formats.js +++ b/addons/base/static/src/js/formats.js @@ -1,140 +1,6 @@ openerp.base.formats = function(openerp) { -/** - * Converts a string to a Date javascript object using OpenERP's - * datetime string format (exemple: '2011-12-01 15:12:35'). - * - * The timezone is assumed to be UTC (standard for OpenERP 6.1) - * and will be converted to the browser's timezone. - * - * @param {String} str A string representing a datetime. - * @returns {Date} - */ -openerp.base.str_to_datetime = function(str) { - if(!str) { - return str; - } - var regex = /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/; - var res = regex.exec(str); - if ( res[0] != str ) { - throw "'" + str + "' is not a valid datetime"; - } - var obj = Date.parse(str + " GMT"); - if (! obj) { - throw "'" + str + "' is not a valid datetime"; - } - return obj; -}; - -/** - * Converts a string to a Date javascript object using OpenERP's - * date string format (exemple: '2011-12-01'). - * - * @param {String} str A string representing a date. - * @returns {Date} - */ -openerp.base.str_to_date = function(str) { - if(!str) { - return str; - } - var regex = /\d\d\d\d-\d\d-\d\d/; - var res = regex.exec(str); - if ( res[0] != str ) { - throw "'" + str + "' is not a valid date"; - } - var obj = Date.parse(str); - if (! obj) { - throw "'" + str + "' is not a valid date"; - } - return obj; -}; - -/** - * Converts a string to a Date javascript object using OpenERP's - * time string format (exemple: '15:12:35'). - * - * @param {String} str A string representing a time. - * @returns {Date} - */ -openerp.base.str_to_time = function(str) { - if(!str) { - return str; - } - var regex = /\d\d:\d\d:\d\d/; - var res = regex.exec(str); - if ( res[0] != str ) { - throw "'" + str + "' is not a valid time"; - } - var obj = Date.parse(str); - if (! obj) { - throw "'" + str + "' is not a valid time"; - } - return obj; -}; - -/* - * Left-pad provided arg 1 with zeroes until reaching size provided by second - * argument. - * - * @param {Number|String} str value to pad - * @param {Number} size size to reach on the final padded value - * @returns {String} padded string - */ -var zpad = function(str, size) { - str = "" + str; - return new Array(size - str.length + 1).join('0') + str; -}; - -/** - * Converts a Date javascript object to a string using OpenERP's - * datetime string format (exemple: '2011-12-01 15:12:35'). - * - * The timezone of the Date object is assumed to be the one of the - * browser and it will be converted to UTC (standard for OpenERP 6.1). - * - * @param {Date} obj - * @returns {String} A string representing a datetime. - */ -openerp.base.datetime_to_str = function(obj) { - if (!obj) { - return false; - } - return zpad(obj.getUTCFullYear(),4) + "-" + zpad(obj.getUTCMonth() + 1,2) + "-" - + zpad(obj.getUTCDate(),2) + " " + zpad(obj.getUTCHours(),2) + ":" - + zpad(obj.getUTCMinutes(),2) + ":" + zpad(obj.getUTCSeconds(),2); -}; - -/** - * Converts a Date javascript object to a string using OpenERP's - * date string format (exemple: '2011-12-01'). - * - * @param {Date} obj - * @returns {String} A string representing a date. - */ -openerp.base.date_to_str = function(obj) { - if (!obj) { - return false; - } - return zpad(obj.getFullYear(),4) + "-" + zpad(obj.getMonth() + 1,2) + "-" - + zpad(obj.getDate(),2); -}; - -/** - * Converts a Date javascript object to a string using OpenERP's - * time string format (exemple: '15:12:35'). - * - * @param {Date} obj - * @returns {String} A string representing a time. - */ -openerp.base.time_to_str = function(obj) { - if (!obj) { - return false; - } - return zpad(obj.getHours(),2) + ":" + zpad(obj.getMinutes(),2) + ":" - + zpad(obj.getSeconds(),2); -}; - /** * Formats a single atomic value based on a field descriptor * -- cgit v1.2.3 From eb1d3f132975ea179bec83b324cc945e7801c74d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 22 Aug 2011 12:19:34 +0200 Subject: [FIX] Fixed dashboard 'Add Widget' bzr revid: fme@openerp.com-20110822101934-3mkcrbis5h0lj1ez --- addons/base/static/src/js/chrome.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 3aff7b5e402..665efa0e3e3 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -102,6 +102,7 @@ openerp.base.Dialog = openerp.base.OldWidget.extend({ } this.set_options(dialog_options); this.$dialog.dialog(this.dialog_options).dialog('open'); + return this; }, close: function() { // Closes the dialog but leave it in a state where it could be opened again. -- cgit v1.2.3 From eebd0ccfd246c4e9a88574100844e606c18b0683 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 22 Aug 2011 14:26:54 +0200 Subject: [FIX] Normalized formview's do_save behviour between touched and untouched state bzr revid: fme@openerp.com-20110822122654-yh43we5egd52162n --- addons/base/static/src/js/form.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 272848338f7..e7bc2d51eba 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -346,7 +346,10 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormVi }); } } else { - return false; + setTimeout(function() { + self.on_saved({ result: true }, success); + }); + return true; } }, do_save_edit: function() { -- cgit v1.2.3