From 7096a336c084bab9f12aa1d13ae96e82cbf12d7d Mon Sep 17 00:00:00 2001 From: Date: Tue, 28 Aug 2012 16:22:02 +0200 Subject: [FIX] a default value (created using "Set Default" wizard) should never be shared between companies, but assigned on the user's company bzr revid: guewen.baconnier@camptocamp.com-20120828142202-9lwdicrdgc2spp6s --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index b64f34f3aaf..60e3d8361bc 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1007,7 +1007,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM field_to_set, self.fields[field_to_set].get_value(), all_users, - false, + true, condition || false ]).then(function () { d.close(); }); }} -- cgit v1.2.3 From f3ac1341e986640ffa865b1aa746ea079fabf52e Mon Sep 17 00:00:00 2001 From: "RGA(OpenERP)" <> Date: Fri, 5 Oct 2012 19:06:22 +0530 Subject: [FIX] use .html to ecapse string to human redable html format bzr revid: rgaopenerp-20121005133622-3n20h9sva67ry9p3 --- addons/web/static/src/js/view_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index fd34ffddb7b..f31c9d9b3d0 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1321,7 +1321,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we } catch (e) { group_label = row_data[group_column.id].value; } - $group_column.text(_.str.sprintf("%s (%d)", + $group_column.html(_.str.sprintf("%s (%d)", group_label, group.length)); if (group.length && group.openable) { -- cgit v1.2.3 From 884aecd5df0c9760a14888dcab6b8f5d6b1655bb Mon Sep 17 00:00:00 2001 From: Vishmita Date: Tue, 9 Oct 2012 19:07:04 +0530 Subject: [IMP]replace callenabled for on_pager_action bzr revid: vja@tinyerp.com-20121009133704-d2xzc6zssbzzmlwn --- addons/web/static/src/js/view_form.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 8e7364ee50a..898f776db8f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -459,7 +459,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } this.$pager.on('click','a[data-pager-action]',function() { var action = $(this).data('pager-action'); - self.on_pager_action(action); + self.trigger('pager_action',self.on_pager_action(action)); }); this.do_update_pager(); }, @@ -3372,9 +3372,8 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ controller.on_record_loaded.add_last(function() { once.resolve(); }); - controller.on_pager_action.add_first(function() { - self.save_any_view(); - }); + controller.on('pager_action',self,self.save_any_view); + } else if (view_type == "graph") { self.reload_current_view() } -- cgit v1.2.3 From 43217cc2b431135a74830b4e1de7ce3d2d621fb7 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 12:34:39 +0530 Subject: [IMP]replace callbackenable from on_select_elements. bzr revid: vme@tinyerp.com-20121011070439-vzcua4yoiwlz2evk --- addons/web/static/src/js/view_form.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..6c36cb3d6fe 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2877,7 +2877,7 @@ instance.web.form.CompletionFieldMixin = { self.build_domain(), new instance.web.CompoundContext(self.build_context(), context || {}) ); - pop.on_select_elements.add(function(element_ids) { + pop.on("select_elements",self,function(element_ids) { self.add_id(element_ids[0]); self.focus(); }); @@ -3598,7 +3598,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({ form_view_options: {'not_interactible_on_create':true}, readonly: self.o2m.get("effective_readonly") }); - pop.on_select_elements.add_last(function() { + pop.on("select_elements", self, function() { self.o2m.reload_current_view(); }); }, @@ -3684,7 +3684,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ self.o2m.build_domain(), self.o2m.build_context() ); - pop.on_select_elements.add_last(function() { + pop.on("select_elements", self, function() { self.o2m.reload_current_view(); }); } @@ -4121,7 +4121,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in this.m2m_field.build_context() ); var self = this; - pop.on_select_elements.add(function(element_ids) { + pop.on("select_elements", self, function(element_ids) { _.each(element_ids, function(one_id) { if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); @@ -4236,7 +4236,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( new instance.web.CompoundDomain(this.build_domain(), ["!", ["id", "in", this.dataset.ids]]), this.build_context() ); - pop.on_select_elements.add(function(element_ids) { + pop.on("select_elements", self, function(element_ids) { _.each(element_ids, function(one_id) { if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); @@ -4457,6 +4457,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ }); }, on_select_elements: function(element_ids) { + this.trigger("select_elements",element_ids); }, check_exit: function(no_destroy) { if (this.created_elements.length > 0) { -- cgit v1.2.3 From 0d257305d3ea7eb551cc6b323def2d90b1a5cada Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 12:58:54 +0530 Subject: [IMP]replace callbackenable from datetime on_change event. bzr revid: vme@tinyerp.com-20121011072854-l87h37b8apbnzuiu --- addons/web/static/src/js/view_form.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..e30a6b2cea5 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2448,6 +2448,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ return instance.web.format_value(v, {"widget": this.type_of_date}); }, on_change: function() { + this.trigger('datetime_on_change'); if (this.is_valid_()) { this.set_value_from_ui_(); } @@ -2473,9 +2474,9 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc initialize_content: function() { if (!this.get("effective_readonly")) { this.datewidget = this.build_widget(); - this.datewidget.on_change.add_last(_.bind(function() { + this.datewidget.on('datetime_on_change', this,_.bind(function() { this.set({'value': this.datewidget.get_value()}); - }, this)); + }, this)) this.datewidget.appendTo(this.$el); this.setupFocus(this.datewidget.$input); } -- cgit v1.2.3 From c85340e995bc56a7246f18e5bf8fb4332ea70455 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 13:03:31 +0530 Subject: [IMP] bzr revid: vme@tinyerp.com-20121011073331-w5xhv6kbr2taphfz --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e30a6b2cea5..ee119f55e67 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2476,7 +2476,7 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc this.datewidget = this.build_widget(); this.datewidget.on('datetime_on_change', this,_.bind(function() { this.set({'value': this.datewidget.get_value()}); - }, this)) + }, this)); this.datewidget.appendTo(this.$el); this.setupFocus(this.datewidget.$input); } -- cgit v1.2.3 From dd747c096299dbee5f30468541639c8f08081151 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 15:11:32 +0530 Subject: [IMP]replace callbackenable from dateset on_change event. bzr revid: vme@tinyerp.com-20121011094132-9a752zxib2rpy4ji --- addons/web/static/src/js/data.js | 8 +++----- addons/web/static/src/js/view_form.js | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index ce85e0ac43f..bfe4506c679 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -834,7 +834,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ } $.extend(cached.values, record.values); if (dirty) - this.on_change(); + this.trigger("dataset_on_change"); return $.Deferred().resolve(true).promise(); }, unlink: function(ids, callback, error_callback) { @@ -848,7 +848,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.to_write = _.reject(this.to_write, function(x) { return _.include(ids, x.id);}); this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);}); this.set_ids(_.without.apply(_, [this.ids].concat(ids))); - this.on_change(); + this.trigger("dataset_on_change"); return $.async_when({result: true}).then(callback); }, reset_ids: function(ids) { @@ -859,8 +859,6 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.cache = []; this.delete_all = false; }, - on_change: function() { - }, read_ids: function (ids, fields, options) { var self = this; var to_get = []; @@ -947,7 +945,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ }, alter_ids: function(n_ids) { this._super(n_ids); - this.on_change(); + this.trigger("dataset_on_change"); }, }); instance.web.BufferedDataSet.virtual_id_regex = /^one2many_v_id_.*$/; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..ab4b67353aa 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3284,7 +3284,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ this.dataset.o2m = this; this.dataset.parent_view = this.view; this.dataset.child_name = this.name; - this.dataset.on_change.add_last(function() { + this.dataset.on('dataset_on_change', this, function() { self.trigger_on_change(); }); @@ -3581,7 +3581,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({ create_function: function(data) { return self.o2m.dataset.create(data).then(function(r) { self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r])); - self.o2m.dataset.on_change(); + self.o2m.dataset.trigger("dataset_on_change"); }); }, write_function: function(id, data, options) { @@ -3671,7 +3671,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ create_function: function(data, callback, error_callback) { return self.o2m.dataset.create(data).then(function(r) { self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r])); - self.o2m.dataset.on_change(); + self.o2m.dataset.trigger("dataset_on_change"); }).then(callback, error_callback); }, read_function: function() { -- cgit v1.2.3 From 2ba6a7f073592a1c625d31c9a7e5681d1f91e270 Mon Sep 17 00:00:00 2001 From: ggh-openerp Date: Thu, 11 Oct 2012 15:15:38 +0530 Subject: [IMP] Remove add in on_menu_logout method bzr revid: ggh@tinyerp.com-20121011094538-d8xrxa0tygrhljdf --- addons/web/static/src/js/chrome.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index b605f4ad4e1..67e36678040 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -881,6 +881,7 @@ instance.web.UserMenu = instance.web.Widget.extend({ on_action: function() { }, on_menu_logout: function() { + this.trigger('user_logout'); }, on_menu_settings: function() { var self = this; @@ -1039,7 +1040,7 @@ instance.web.WebClient = instance.web.Client.extend({ self.menu.on('menu_click', this, this.on_menu_action); self.user_menu = new instance.web.UserMenu(self); self.user_menu.replace(this.$el.find('.oe_user_menu_placeholder')); - self.user_menu.on_menu_logout.add(this.proxy('on_logout')); + self.user_menu.on('user_logout', self, this.proxy('on_logout')); self.user_menu.on_action.add(this.proxy('on_menu_action')); self.user_menu.do_update(); self.bind_hashchange(); -- cgit v1.2.3 From 5bb6122f73f080f59ca08f310fa7d8e1875d8b4b Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 15:58:49 +0530 Subject: [IMP]change method on_selected_elements to elements_selected. bzr revid: vme@tinyerp.com-20121011102849-yn9nldtgqszp70gq --- addons/web/static/src/js/view_form.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6c36cb3d6fe..377034c0e2a 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4456,12 +4456,12 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ self.view_form.do_show(); }); }, - on_select_elements: function(element_ids) { + elements_selected: function(element_ids) { this.trigger("select_elements",element_ids); }, check_exit: function(no_destroy) { if (this.created_elements.length > 0) { - this.on_select_elements(this.created_elements); + this.elements_selected(this.created_elements); this.created_elements = []; } this.destroy(); @@ -4572,7 +4572,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend }); var $sbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-select"); $sbutton.click(function() { - self.on_select_elements(self.selected_ids); + self.elements_selected(self.selected_ids); self.destroy(); }); }); @@ -4614,7 +4614,7 @@ instance.web.form.SelectCreateListView = instance.web.ListView.extend({ this.popup.new_object(); }, select_record: function(index) { - this.popup.on_select_elements([this.dataset.ids[index]]); + this.popup.elements_selected([this.dataset.ids[index]]); this.popup.destroy(); }, do_select: function(ids, records) { -- cgit v1.2.3 From b13ee21296c151cfb82ac8ede020efe83734649a Mon Sep 17 00:00:00 2001 From: Vishmita Date: Thu, 11 Oct 2012 16:13:41 +0530 Subject: [IMP]replace callenabled for on_controller_inited bzr revid: vja@tinyerp.com-20121011104341-7r4fr4l687bn9qqe --- addons/web/static/src/js/view_form.js | 2 +- addons/web/static/src/js/views.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..efb5b5816f5 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3372,7 +3372,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ var def = $.Deferred().then(function() { self.initial_is_loaded.resolve(); }); - this.viewmanager.on_controller_inited.add_last(function(view_type, controller) { + this.viewmanager.on("controller_inited", self, function(view_type, controller) { controller.o2m = self; if (view_type == "list") { if (self.get("effective_readonly")) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index f985e5f6dc8..ba6c95f96c1 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -409,6 +409,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.flags = flags || {}; this.registry = instance.web.views; this.views_history = []; + this.on("controller_inited",this.on_controller_inited); }, /** * @returns {jQuery.Deferred} initial view loading promise @@ -532,7 +533,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.views[view_type].controller = controller; this.views[view_type].deferred.resolve(view_type); return $.when(view_promise).then(function() { - self.on_controller_inited(view_type, controller); + self.trigger("controller_inited",view_type, controller); if (self.searchview && self.flags.auto_search && view.controller.searchable !== false) { -- cgit v1.2.3 From e50ce70fa79a9b1a6d34c9d2fc7694a4f6d0fc8e Mon Sep 17 00:00:00 2001 From: Vishmita Date: Thu, 11 Oct 2012 16:25:16 +0530 Subject: [Fix]change event name bzr revid: vja@tinyerp.com-20121011105516-h3fuwrgxdqqbtxh8 --- addons/web/static/src/js/chrome.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index b605f4ad4e1..822eda40713 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -154,6 +154,7 @@ instance.web.Dialog = instance.web.Widget.extend({ this.$el.dialog('close'); }, on_close: function() { + this.trigger("dialog_close"); if (this.__tmp_dialog_destroying) return; if (this.dialog_options.destroy_on_close) { -- cgit v1.2.3 From c538db258abdcaa25ff1442c9b4cd3f2bbdb9935 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 14:57:48 +0200 Subject: [IMP] now uses py.eval for options bzr revid: nicolas.vanhoren@openerp.com-20121011125748-8au3gmss2436h5lw --- addons/web/static/src/js/corelib.js | 4 ++++ addons/web/static/src/js/view_form.js | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index b5fbacc7927..8c38724b1d5 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1440,6 +1440,10 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ }, }); +instance.web.py_eval = function(expr, context) { + return py.eval(expr, _.extend({}, context || {}, {"true": true, "false": false, "null": null})); +}; + } // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..97ad0f220e6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2087,11 +2087,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w this.field = this.field_manager.get_field_desc(this.name); this.widget = this.node.attrs.widget; this.string = this.node.attrs.string || this.field.string || this.name; - try { - this.options = JSON.parse(this.node.attrs.options || '{}'); - } catch (e) { - throw new Error(_.str.sprintf(_t("Widget options for field '%s' are not valid JSON."), this.name)); - } + this.options = instance.web.py_eval(this.node.attrs.options || '{}'); this.set({'value': false}); this.on("change:value", this, function() { -- cgit v1.2.3 From d1edeee7f35d3609f3276b69188edf538b32ca15 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 18:30:11 +0530 Subject: [IMP]replace callbackenable method. bzr revid: vme@tinyerp.com-20121011130011-haovxmxr3pj10unp --- addons/web/static/src/js/view_form.js | 2 +- addons/web/static/src/js/views.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index afb5e258c0b..8984c057244 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -956,7 +956,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM var self = this; return this.reload_mutex.exec(function() { if (self.dataset.index == null) { - self.do_prev_view(); + self.trigger("previous_view"); return $.Deferred().reject().promise(); } if (self.dataset.index == null || self.dataset.index < 0) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index f985e5f6dc8..5f90c4215f7 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -525,8 +525,8 @@ instance.web.ViewManager = instance.web.Widget.extend({ controller.set_embedded_view(view.embedded_view); } controller.on('switch_mode', self, this.switch_mode); - - controller.do_prev_view.add_last(this.on_prev_view); + controller.on('previous_view', self, this.prev_view); + var container = this.$el.find(".oe_view_manager_view_" + view_type); var view_promise = controller.appendTo(container); this.views[view_type].controller = controller; @@ -602,7 +602,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ * @param {String} [options.default=null] view to switch to if no previous view * @returns {$.Deferred} switching end signal */ - on_prev_view: function (options) { + prev_view: function (options) { options = options || {}; var current_view = this.views_history.pop(); var previous_view = this.views_history[this.views_history.length - 1] || options['default']; @@ -1266,8 +1266,7 @@ instance.web.View = instance.web.Widget.extend({ * @param {Boolean} [options.created=false] resource was created * @param {String} [options.default=null] view to switch to if no previous view */ - do_prev_view: function (options) { - }, + do_search: function(view) { }, on_sidebar_export: function() { -- cgit v1.2.3 From 126b8b6d4f0814e648727a543febb5658aec3671 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Thu, 11 Oct 2012 18:50:05 +0530 Subject: [FIX]Improve code bzr revid: vja@tinyerp.com-20121011132005-78twkqav8k2ovde2 --- addons/web/static/src/js/views.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index f985e5f6dc8..34909e04c9f 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -287,7 +287,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ dialogClass: executor.klass }); if(on_close) - this.dialog.on_close.add(on_close); + this.dialog.on("dialog_close",this,on_close); } else { this.dialog_widget.destroy(); } -- cgit v1.2.3 From c6fa315737cbbc805c21969654e54068583198f5 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 11 Oct 2012 18:51:22 +0530 Subject: [IMP]do_save method with trigger. bzr revid: vme@tinyerp.com-20121011132122-m8qq603wk4gla0fq --- addons/web/static/src/js/view_form.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ccd46a52cc6..68a47259cec 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -830,6 +830,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM */ do_save: function(prepend_on_create) { var self = this; + this.trigger("form_save"); return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() { try { var form_invalid = false, -- cgit v1.2.3 From 8b2731d819125bec6b67a46d26898be30264933f Mon Sep 17 00:00:00 2001 From: Vishmita Date: Thu, 11 Oct 2012 19:00:31 +0530 Subject: [FIX]Improve code bzr revid: vja@tinyerp.com-20121011133031-83azb0qwjpq1b0aq --- addons/web/static/src/js/views.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index ba6c95f96c1..4172344c66e 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -409,7 +409,6 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.flags = flags || {}; this.registry = instance.web.views; this.views_history = []; - this.on("controller_inited",this.on_controller_inited); }, /** * @returns {jQuery.Deferred} initial view loading promise @@ -533,7 +532,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.views[view_type].controller = controller; this.views[view_type].deferred.resolve(view_type); return $.when(view_promise).then(function() { - self.trigger("controller_inited",view_type, controller); + self.trigger("controller_inited",view_type,controller); if (self.searchview && self.flags.auto_search && view.controller.searchable !== false) { @@ -653,14 +652,6 @@ instance.web.ViewManager = instance.web.Widget.extend({ controller.do_search(results.domain, results.context, groupby || []); }); }, - /** - * Event launched when a controller has been inited. - * - * @param {String} view_type type of view - * @param {String} view the inited controller - */ - on_controller_inited: function(view_type, view) { - }, /** * Called when one of the view want to execute an action */ -- cgit v1.2.3 From 9ff1aa9f4a2f99df7154fef214231284946c33c3 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 16:47:05 +0200 Subject: Removed lot of useless stuff and modified the form rendering engine to let the form view insert the fields. bzr revid: nicolas.vanhoren@openerp.com-20121011144705-cu4c2gzsghc2or2l --- addons/web/static/src/js/view_form.js | 90 +++++++---------------------------- 1 file changed, 17 insertions(+), 73 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 97ad0f220e6..7a0bad0a10c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -118,7 +118,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.__clicked_inside = false; this.__blur_timeout = null; this.rendering_engine = new instance.web.form.FormRenderingEngine(this); - this.qweb = null; // A QWeb instance will be created if the view is a QWeb template self.set({actual_mode: self.options.initial_mode}); this.has_been_loaded.then(function() { self.on("change:actual_mode", self, self.check_actual_mode); @@ -157,11 +156,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.rendering_engine.set_fields_registry(this.fields_registry); this.rendering_engine.set_tags_registry(this.tags_registry); this.rendering_engine.set_widgets_registry(this.widgets_registry); - if (!this.extract_qweb_template(data)) { - this.rendering_engine.set_fields_view(data); - var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container'); - this.rendering_engine.render_to($dest); - } + this.rendering_engine.set_fields_view(data); + var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container'); + var rendering_result = this.rendering_engine.render_to($dest); + _.each(rendering_result.to_replace, function(el) { + el[0].replace(el[1]); + }); this.$el.on('mousedown.formBlur', function () { self.__clicked_inside = true; @@ -214,57 +214,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return $.when(); }, - extract_qweb_template: function(fvg) { - for (var i=0, ii=fvg.arch.children.length; i < ii; i++) { - var child = fvg.arch.children[i]; - if (child.tag === "templates") { - this.qweb = new QWeb2.Engine(); - this.qweb.add_template(instance.web.json_node_to_xml(child)); - if (!this.qweb.has_template('form')) { - throw new Error("No QWeb template found for form view"); - } - return true; - } - } - this.qweb = null; - return false; - }, - get_fvg_from_qweb: function(record) { - var view = this.qweb.render('form', this.get_qweb_context(record)); - var fvg = _.clone(this.fields_view); - fvg.arch = instance.web.xml_to_json(instance.web.str_to_xml(view).firstChild); - return fvg; - }, - get_qweb_context: function(record) { - var self = this, - new_record = {}; - _.each(record, function(value_, name) { - var r = _.clone(self.fields_view.fields[name] || {}); - if ((r.type === 'date' || r.type === 'datetime') && value_) { - r.raw_value = instance.web.auto_str_to_date(value_); - } else { - r.raw_value = value_; - } - r.value = instance.web.format_value(value_, r); - new_record[name] = r; - }); - return { - record : new_record, - new_record : !record.id - }; - }, - kill_current_form: function() { - _.each(this.getChildren(), function(el) { - el.destroy(); - }); - this.fields = {}; - this.fields_order = []; - this.default_focus_field = null; - this.default_focus_button = null; - this.translatable_fields = []; - this.$el.find('.oe_form_container').empty(); - }, - widgetFocused: function() { // Clear click flag if used to focus a widget this.__clicked_inside = false; @@ -368,13 +317,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this._actualize_mode(); this.set({ 'title' : record.id ? record.display_name : "New" }); - if (this.qweb) { - this.kill_current_form(); - this.rendering_engine.set_fields_view(this.get_fvg_from_qweb(record)); - var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container'); - this.rendering_engine.render_to($dest); - } - _(this.fields).each(function (field, f) { field._dirty_flag = false; field._inhibit_on_change_flag = true; @@ -1226,7 +1168,12 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt this.$form.appendTo(this.$target); - var ws = _.map(this.fields_to_init, function($elem) { + var res = { + target: $target, + to_replace: [], + }; + + _.each(this.fields_to_init, function($elem) { var name = $elem.attr("name"); if (!self.fvg.fields[name]) { throw new Error("Field '" + name + "' specified in view could not be found."); @@ -1242,24 +1189,21 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } self.alter_field(w); self.view.register_field(w, $elem.attr("name")); - return [w, $elem]; - }); - _.each(ws, function(w) { - w[0].replace(w[1]); + res.to_replace.push([w, $elem]); }); _.each(this.tags_to_init, function($elem) { var tag_name = $elem[0].tagName.toLowerCase(); var obj = self.tags_registry.get_object(tag_name); var w = new (obj)(self.view, instance.web.xml_to_json($elem[0])); - w.replace($elem); + res.to_replace.push([w, $elem]); }); _.each(this.widgets_to_init, function($elem) { var widget_type = $elem.attr("type"); var obj = self.widgets_registry.get_object(widget_type); var w = new (obj)(self.view, instance.web.xml_to_json($elem[0])); - w.replace($elem); + res.to_replace.push([w, $elem]); }); - // TODO: return a deferred + return res; }, render_element: function(template /* dictionaries */) { var dicts = [].slice.call(arguments).slice(1); @@ -4991,7 +4935,7 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ */ render_elements: function () { var self = this; - var content = instance.web.qweb.render("FieldStatus.content", {widget: this}); + var content = QWeb.render("FieldStatus.content", {widget: this}); this.$el.html(content); var colors = JSON.parse((this.node.attrs || {}).statusbar_colors || "{}"); var color = colors[this.selected_value]; -- cgit v1.2.3 From 3da22818fa25bd73d584f058af925c477908ac26 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 16:51:48 +0200 Subject: Modified the way the fields are inserted a little bit more bzr revid: nicolas.vanhoren@openerp.com-20121011145148-ii0p0t704gdmmf24 --- addons/web/static/src/js/view_form.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 7a0bad0a10c..ea2e9fa289d 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -158,10 +158,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.rendering_engine.set_widgets_registry(this.widgets_registry); this.rendering_engine.set_fields_view(data); var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container'); - var rendering_result = this.rendering_engine.render_to($dest); - _.each(rendering_result.to_replace, function(el) { - el[0].replace(el[1]); - }); + this.rendering_engine.render_to($dest); + this.rendering_engine.init_fields(); this.$el.on('mousedown.formBlur', function () { self.__clicked_inside = true; @@ -1168,10 +1166,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt this.$form.appendTo(this.$target); - var res = { - target: $target, - to_replace: [], - }; + this.to_replace = []; _.each(this.fields_to_init, function($elem) { var name = $elem.attr("name"); @@ -1189,21 +1184,27 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } self.alter_field(w); self.view.register_field(w, $elem.attr("name")); - res.to_replace.push([w, $elem]); + self.to_replace.push([w, $elem]); }); _.each(this.tags_to_init, function($elem) { var tag_name = $elem[0].tagName.toLowerCase(); var obj = self.tags_registry.get_object(tag_name); var w = new (obj)(self.view, instance.web.xml_to_json($elem[0])); - res.to_replace.push([w, $elem]); + self.to_replace.push([w, $elem]); }); _.each(this.widgets_to_init, function($elem) { var widget_type = $elem.attr("type"); var obj = self.widgets_registry.get_object(widget_type); var w = new (obj)(self.view, instance.web.xml_to_json($elem[0])); - res.to_replace.push([w, $elem]); + self.to_replace.push([w, $elem]); + }); + }, + init_fields: function() { + var defs = []; + _.each(this.to_replace, function(el) { + defs.push(el[0].replace(el[1])); }); - return res; + return $.when.apply($, defs); }, render_element: function(template /* dictionaries */) { var dicts = [].slice.call(arguments).slice(1); -- cgit v1.2.3 From 5f55a091fac7894d8ea843b724587f0ca2ecc6ec Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 11 Oct 2012 17:19:48 +0200 Subject: [FIX] push_state of client actions: push also params bzr revid: chs@openerp.com-20121011151948-82zk0icmw8zoyfis --- addons/web/static/src/js/views.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 5f90c4215f7..4dfdd92f5e5 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -172,7 +172,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ state['action'] = this.inner_action.id; } else if (this.inner_action.type == 'ir.actions.client') { state['action'] = this.inner_action.tag; - //state = _.extend(this.inner_action.params || {}, state); + state = _.extend(this.inner_action.params || {}, state); } } if(!this.dialog) { -- cgit v1.2.3 From 4757e5287e1ebca9508730413d94c63059531907 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 17:21:40 +0200 Subject: Modified fields up to m2o bzr revid: nicolas.vanhoren@openerp.com-20121011152140-c4edgpmamqgiwx9s --- addons/web/static/src/js/view_form.js | 74 +++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ea2e9fa289d..6381cf5fe6c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -159,7 +159,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.rendering_engine.set_fields_view(data); var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container'); this.rendering_engine.render_to($dest); - this.rendering_engine.init_fields(); this.$el.on('mousedown.formBlur', function () { self.__clicked_inside = true; @@ -335,6 +334,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }); } self.on_form_changed(); + this.rendering_engine.init_fields(); self.is_initialized.resolve(); self.do_update_pager(record.id == null); if (self.sidebar) { @@ -1204,6 +1204,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt _.each(this.to_replace, function(el) { defs.push(el[0].replace(el[1])); }); + this.to_replace = []; return $.when.apply($, defs); }, render_element: function(template /* dictionaries */) { @@ -2066,6 +2067,14 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w this.field_manager.on("change:display_invalid_fields", this, this._check_css_flags); this._check_css_flags(); }, + start: function() { + var tmp = this._super(); + this.on("change:value", this, function() { + if (! this.no_rerender) + this.render(); + }); + this.render(); + }, /** * Private. Do not use. */ @@ -2078,6 +2087,20 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w get_value: function() { return this.get('value'); }, + /** + Utility method that all implementations should use to change the + value without triggering a re-rendering. + */ + internal_set_value: function(value_) { + var tmp = this.no_render; + this.no_rerender = true; + this.set({'value': value_}); + this.no_rerender = tmp; + }, + /** + This method is called each time the value is modified. + */ + render_value: function() {}, is_valid: function() { return this.is_syntax_valid() && !(this.get('required') && this.is_false()); }, @@ -2161,10 +2184,6 @@ instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.Reini instance.web.form.ReinitializeWidgetMixin.reinitialize.call(this); this.render_value(); }, - /** - * Called to render the value. Should also be explicitly called at the end of a set_value(). - */ - render_value: function() {}, }); instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { @@ -2178,14 +2197,10 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we var self = this; var $input = this.$el.find('input'); $input.change(function() { - self.set({'value': self.parse_value($input.val())}); + self.internal_set_value(self.parse_value($input.val())); }); this.setupFocus($input); }, - set_value: function(value_) { - this._super(value_); - this.render_value(); - }, render_value: function() { var show_value = this.format_value(this.get('value'), ''); if (!this.get("effective_readonly")) { @@ -2289,7 +2304,7 @@ instance.web.form.FieldFloat = instance.web.form.FieldChar.extend({ widget_class: 'oe_form_field_float', init: function (field_manager, node) { this._super(field_manager, node); - this.set({'value': 0}); + this.internal_set_value(0); if (this.node.attrs.digits) { this.digits = this.node.attrs.digits; } else { @@ -2415,16 +2430,12 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc if (!this.get("effective_readonly")) { this.datewidget = this.build_widget(); this.datewidget.on_change.add_last(_.bind(function() { - this.set({'value': this.datewidget.get_value()}); + this.internal_set_value(this.datewidget.get_value()); }, this)); this.datewidget.appendTo(this.$el); this.setupFocus(this.datewidget.$input); } }, - set_value: function(value_) { - this._super(value_); - this.render_value(); - }, render_value: function() { if (!this.get("effective_readonly")) { this.datewidget.set_value(this.get('value')); @@ -2466,7 +2477,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we this.default_height = this.$textarea.css('height'); if (!this.get("effective_readonly")) { this.$textarea.change(_.bind(function() { - self.set({'value': instance.web.parse_value(self.$textarea.val(), self)}); + self.internal_set_value(instance.web.parse_value(self.$textarea.val(), self)); }, this)); } else { this.$textarea.attr('disabled', 'disabled'); @@ -2478,12 +2489,8 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we }); this.setupFocus(this.$textarea); }, - set_value: function(value_) { - this._super(value_); - this.render_value(); - $(window).resize(); - }, render_value: function() { + $(window).resize(); var show_value = instance.web.format_value(this.get('value'), this, ''); if (show_value === '') { this.$textarea.css('height', parseInt(this.default_height)+"px"); @@ -2543,15 +2550,11 @@ instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instanc this.$cleditor.change(function() { if (! self._updating_editor) { self.$cleditor.updateTextArea(); - self.set({'value': self.$textarea.val()}); + self.internal_set_value(self.$textarea.val()); } }); } }, - set_value: function(value_) { - this._super.apply(this, arguments); - this.render_value(); - }, render_value: function() { if (! this.get("effective_readonly")) { this.$textarea.val(this.get('value') || ''); @@ -2572,7 +2575,7 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ this.$checkbox = $("input", this.$el); this.setupFocus(this.$checkbox); this.$el.click(_.bind(function() { - this.set({'value': this.$checkbox.is(':checked')}); + this.internal_set_value(this.$checkbox.is(':checked')); }, this)); var check_readonly = function() { self.$checkbox.prop('disabled', self.get("effective_readonly")); @@ -2580,10 +2583,9 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ this.on("change:effective_readonly", this, check_readonly); check_readonly.call(this); }, - set_value: function(value_) { - this._super.apply(this, arguments); - this.$checkbox[0].checked = value_; - }, + render_value: function() { + this.$checkbox[0].checked = this.get('value'); + } focus: function() { this.$checkbox.focus(); } @@ -2598,9 +2600,8 @@ instance.web.form.FieldProgressBar = instance.web.form.AbstractField.extend({ disabled: this.get("effective_readonly") }); }, - set_value: function(value_) { - this._super.apply(this, arguments); - var show_value = Number(value_); + render_value: function() { + var show_value = Number(this.get('value')); if (isNaN(show_value)) { show_value = 0; } @@ -2638,7 +2639,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan var ischanging = false; var $select = this.$el.find('select') .change(_.bind(function() { - this.set({'value': this.values[this.$el.find('select')[0].selectedIndex][0]}); + this.internal_set_value(this.values[this.$el.find('select')[0].selectedIndex][0]); }, this)) .change(function () { ischanging = true; }) .click(function () { ischanging = false; }) @@ -2653,7 +2654,6 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan value_ = value_ === null ? false : value_; value_ = value_ instanceof Array ? value_[0] : value_; this._super(value_); - this.render_value(); }, render_value: function() { if (!this.get("effective_readonly")) { -- cgit v1.2.3 From 7cd873f86fb38996bab4ec3b9b8640669171095f Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 17:23:08 +0200 Subject: fix typo bzr revid: nicolas.vanhoren@openerp.com-20121011152308-exmq8zruqba7u4fw --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6381cf5fe6c..e599256de00 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2585,7 +2585,7 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ }, render_value: function() { this.$checkbox[0].checked = this.get('value'); - } + }, focus: function() { this.$checkbox.focus(); } -- cgit v1.2.3 From 2fadf797e56a15e7b3a6b19422876e1ce3752d03 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 17:35:06 +0200 Subject: Ported the m2o bzr revid: nicolas.vanhoren@openerp.com-20121011153506-b91c4xm2jsf6a6t7 --- addons/web/static/src/js/view_form.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e599256de00..dad787374a1 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2873,26 +2873,28 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.display_value = {}; this.last_search = []; this.floating = false; - this.inhibit_on_change = false; this.current_display = null; + this.is_started = false; }, start: function() { this._super(); instance.web.form.ReinitializeFieldMixin.start.call(this); - this.on("change:value", this, function() { - this.floating = false; - this.render_value(); - }); + this.is_started = true; instance.web.bus.on('click', this, function() { if (!this.get("effective_readonly") && this.$input && this.$input.autocomplete('widget').is(':visible')) { this.$input.autocomplete("close"); } }); }, + reinit_value: function(val) { + this.internal_set_value(val); + this.floating = false; + if (this.is_started) + this.render_value(); + }, initialize_content: function() { if (!this.get("effective_readonly")) this.render_editable(); - this.render_value(); }, init_error_displayer: function() { // nothing @@ -2943,7 +2945,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc if (self.current_display !== self.$input.val()) { self.current_display = self.$input.val(); if (self.$input.val() === "") { - self.set({value: false}); + self.internal_set_value(false); self.floating = false; } else { self.floating = true; @@ -2975,15 +2977,14 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc if (self.last_search[0][0] != self.get("value")) { self.display_value = {}; self.display_value["" + self.last_search[0][0]] = self.last_search[0][1]; - self.set({value: self.last_search[0][0]}); + self.reinit_value(self.last_search[0][0]); } else { used = true; self.render_value(); } } else { used = true; - self.set({value: false}); - self.render_value(); + self.reinit_value(false); } self.floating = false; } @@ -3038,7 +3039,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc if (item.id) { self.display_value = {}; self.display_value["" + item.id] = item.name; - self.set({value: item.id}); + self.reinit_value(item.id); } else if (item.action) { item.action(); // Cancel widget blurring, to avoid form blur event @@ -3129,16 +3130,14 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc value_ = value_[0]; } value_ = value_ || false; - this.inhibit_on_change = true; - this._super(value_); - this.inhibit_on_change = false; + this.reinit_value(value_); }, get_displayed: function() { return this.display_value["" + this.get("value")]; }, add_id: function(id) { this.display_value = {}; - this.set({value: id}); + this.reinit_value(id); }, is_false: function() { return ! this.get("value"); -- cgit v1.2.3 From b164a96535e66313ed6502e17d1f8bee45a9a9c6 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 17:47:00 +0200 Subject: Ported m2mtags, reference and binary, still need to port o2m & m2m bzr revid: nicolas.vanhoren@openerp.com-20121011154700-nm1j0nibq3xazaix --- addons/web/static/src/js/view_form.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index dad787374a1..add396df790 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3830,7 +3830,6 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in start: function() { this._super(); instance.web.form.ReinitializeFieldMixin.start.call(this); - this.on("change:value", this, this.render_value); }, initialize_content: function() { if (this.get("effective_readonly")) @@ -4624,10 +4623,6 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan is_false: function() { return typeof(this.get_value()) !== 'string'; }, - set_value: function(value_) { - this._super(value_); - this.render_value(); - }, render_value: function() { this.reference_ready = false; var vals = [], sel_val, m2o_val; @@ -4647,9 +4642,9 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan var model = this.selection.get_value(), id = this.m2o.get_value(); if (typeof(model) === 'string' && typeof(id) === 'number') { - this.set({'value': model + ',' + id}); + this.internal_set_value(model + ',' + id); } else { - this.set({'value': false}); + this.internal_set_value(false); } }, }); @@ -4748,7 +4743,7 @@ instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance. on_clear: function() { if (this.get('value') !== false) { this.binary_value = false; - this.set({'value': false}); + this.internal_set_value(false); } return false; } @@ -4768,10 +4763,6 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({ }); } }, - set_value: function(value_) { - this._super.apply(this, arguments); - this.render_value(); - }, render_value: function() { if (!this.get("effective_readonly")) { var show_value; @@ -4793,7 +4784,7 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({ }, on_file_uploaded_and_valid: function(size, name, content_type, file_base64) { this.binary_value = true; - this.set({'value': file_base64}); + this.internal_set_value(file_base64); var show_value = name + " (" + this.human_filesize(size) + ")"; this.$el.find('input').eq(0).val(show_value); this.set_filename(name); @@ -4807,10 +4798,6 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ template: 'FieldBinaryImage', - set_value: function(value_) { - this._super.apply(this, arguments); - this.render_value(); - }, render_value: function() { var self = this; var url; @@ -4843,7 +4830,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ this._super.apply(this, arguments); }, on_file_uploaded_and_valid: function(size, name, content_type, file_base64) { - this.set({'value': file_base64}); + this.internal_set_value(file_base64); this.binary_value = true; this.render_value(); this.set_filename(name); -- cgit v1.2.3 From f5b1729758010c319aba4381c5231203f486f828 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 18:09:02 +0200 Subject: Fixed lot of stuff and rewritten partially field status bzr revid: nicolas.vanhoren@openerp.com-20121011160902-llwsclos30nju80s --- addons/web/static/src/js/view_form.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index add396df790..3d8f4a96ae1 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -334,7 +334,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }); } self.on_form_changed(); - this.rendering_engine.init_fields(); + self.rendering_engine.init_fields(); self.is_initialized.resolve(); self.do_update_pager(record.id == null); if (self.sidebar) { @@ -2071,9 +2071,9 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w var tmp = this._super(); this.on("change:value", this, function() { if (! this.no_rerender) - this.render(); + this.render_value(); }); - this.render(); + this.render_value(); }, /** * Private. Do not use. @@ -2148,8 +2148,8 @@ instance.web.form.ReinitializeWidgetMixin = { * Default implementation of start(), use it or call explicitly initialize_field(). */ start: function() { - this._super(); this.initialize_field(); + this._super(); }, initialize_field: function() { this.on("change:effective_readonly", this, this.reinitialize); @@ -2571,7 +2571,6 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ template: 'FieldBoolean', start: function() { var self = this; - this._super.apply(this, arguments); this.$checkbox = $("input", this.$el); this.setupFocus(this.$checkbox); this.$el.click(_.bind(function() { @@ -2582,6 +2581,7 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ }; this.on("change:effective_readonly", this, check_readonly); check_readonly.call(this); + this._super.apply(this, arguments); }, render_value: function() { this.$checkbox[0].checked = this.get('value'); @@ -4851,7 +4851,6 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ this.selected_value = null; }, start: function() { - this._super(); // backward compatibility this.loaded = new $.Deferred(); if (this.options.clickable) { @@ -4861,18 +4860,13 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ if (this.$el.parent().is('header')) { this.$el.after('
'); } + this._super(); }, set_value: function(value_) { - var self = this; - this._super(value_); - // find selected value: - // - many2one: [2, "New"] -> 2 - // - selection: new -> new - if (this.field.type == "many2one") { - this.selected_value = value_[0]; - } else { - this.selected_value = value_; + if (value_ instanceof Array) { + value_ = value_[0]; } + this._super(value_); // trick to be sure all values are loaded in the form, therefore // enabling the evaluation of dynamic domains self.selection = []; @@ -4881,6 +4875,9 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ }); return this.loaded; }, + render_value: function() { + this.get_selection(); + }, /** Get the selection and render it * selection: [[identifier, value_to_display], ...] * For selection fields: this is directly given by this.field.selection -- cgit v1.2.3 From fb944a77faff92a79d25957a89af47212e005afb Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 18:18:16 +0200 Subject: Ported field status bzr revid: nicolas.vanhoren@openerp.com-20121011161816-lnz7prb3ag6nrbi3 --- addons/web/static/src/js/view_form.js | 53 ++++++++++++----------------------- 1 file changed, 18 insertions(+), 35 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3d8f4a96ae1..c708d56a7ef 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4848,15 +4848,12 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ this._super(field_manager, node); this.options.clickable = this.options.clickable || (this.node.attrs || {}).clickable || false; this.options.visible = this.options.visible || (this.node.attrs || {}).statusbar_visible || false; - this.selected_value = null; + this.set({value: false}); }, start: function() { - // backward compatibility - this.loaded = new $.Deferred(); if (this.options.clickable) { this.$el.on('click','li',this.on_click_stage); } - // TODO move the following into css :after if (this.$el.parent().is('header')) { this.$el.after('
'); } @@ -4867,16 +4864,18 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ value_ = value_[0]; } this._super(value_); - // trick to be sure all values are loaded in the form, therefore - // enabling the evaluation of dynamic domains - self.selection = []; - $.async_when().then(function() { - self.get_selection(); - }); - return this.loaded; }, render_value: function() { - this.get_selection(); + var self = this; + self.get_selection().then(function() { + var content = QWeb.render("FieldStatus.content", {widget: self}); + self.$el.html(content); + var colors = JSON.parse((self.node.attrs || {}).statusbar_colors || "{}"); + var color = colors[self.get('value')]; + if (color) { + self.$("oe_active").css("color", color); + } + }); }, /** Get the selection and render it * selection: [[identifier, value_to_display], ...] @@ -4885,53 +4884,37 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ */ get_selection: function() { var self = this; + self.selection = []; if (this.field.type == "many2one") { var domain = []; if(!_.isEmpty(this.field.domain) || !_.isEmpty(this.node.attrs.domain)) { - domain = new instance.web.CompoundDomain(['|'], self.build_domain(), [['id', '=', self.selected_value]]); + domain = new instance.web.CompoundDomain(['|'], self.build_domain(), [['id', '=', self.get('value')]]); } var ds = new instance.web.DataSetSearch(this, this.field.relation, self.build_context(), domain); - ds.read_slice(['name'], {}).done( function (records) { + return ds.read_slice(['name'], {}).pipe(function (records) { for(var i = 0; i < records.length; i++) { self.selection.push([records[i].id, records[i].name]); } - self.render_elements(); - self.loaded.resolve(); }); } else { - this.loaded.resolve(); // For field type selection filter values according to // statusbar_visible attribute of the field. For example: // statusbar_visible="draft,open". var selection = this.field.selection; - for(var i=0; i< selection.length; i++) { + for(var i=0; i < selection.length; i++) { var key = selection[i][0]; - if(key == this.selected_value || !this.options.visible || this.options.visible.indexOf(key) != -1) { + if(key == this.get('value') || !this.options.visible || this.options.visible.indexOf(key) != -1) { this.selection.push(selection[i]); } } - this.render_elements(); - } - }, - /** Renders the widget. This function also checks for statusbar_colors='{"pending": "blue"}' - * attribute in the widget. This allows to set a given color to a given - * state (given by the key of (key, label)). - */ - render_elements: function () { - var self = this; - var content = QWeb.render("FieldStatus.content", {widget: this}); - this.$el.html(content); - var colors = JSON.parse((this.node.attrs || {}).statusbar_colors || "{}"); - var color = colors[this.selected_value]; - if (color) { - this.$("oe_active").css("color", color); + return $.when(); } }, on_click_stage: function (ev) { var self = this; var $li = $(ev.currentTarget); var val = parseInt($li.data("id")); - if (val != self.selected_value) { + if (val != self.get('value')) { this.view.recursive_save().then(function() { var change = {}; change[self.name] = val; -- cgit v1.2.3 From 55a5f51aebe7fd4dc08759654d3649952ce8cb0e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Oct 2012 18:29:18 +0200 Subject: Ported o2m bzr revid: nicolas.vanhoren@openerp.com-20121011162918-d15ip9ci4o24axzy --- addons/web/static/src/js/view_form.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c708d56a7ef..3905501e6cd 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2877,7 +2877,6 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.is_started = false; }, start: function() { - this._super(); instance.web.form.ReinitializeFieldMixin.start.call(this); this.is_started = true; instance.web.bus.on('click', this, function() { @@ -2885,6 +2884,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.$input.autocomplete("close"); } }); + this._super(); }, reinit_value: function(val) { this.internal_set_value(val); @@ -3213,20 +3213,22 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ this.is_setted = $.Deferred(); this.form_last_update = $.Deferred(); this.init_form_last_update = this.form_last_update; - }, - start: function() { - this._super.apply(this, arguments); - this.$el.addClass('oe_form_field oe_form_field_one2many'); - - var self = this; - + this.is_started = false; this.dataset = new instance.web.form.One2ManyDataSet(this, this.field.relation); this.dataset.o2m = this; this.dataset.parent_view = this.view; this.dataset.child_name = this.name; + var self = this; this.dataset.on_change.add_last(function() { self.trigger_on_change(); }); + this.set_value([]); + }, + start: function() { + this._super.apply(this, arguments); + this.$el.addClass('oe_form_field oe_form_field_one2many'); + + var self = this; this.is_setted.then(function() { self.load_views(); @@ -3241,6 +3243,8 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ }); }); }); + this.is_started = true; + this.reload_current_view(); }, trigger_on_change: function() { var tmp = this.doing_on_change; @@ -3429,7 +3433,11 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ } self.is_setted.resolve(); this.trigger_on_change(); - return self.reload_current_view(); + if (this.is_started) { + return self.reload_current_view(); + } else { + return $.when(); + } }, get_value: function() { var self = this; -- cgit v1.2.3 From 2f31d1a2ed3b9a190555e8851f0b28b386771dd0 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 11 Oct 2012 18:41:14 +0200 Subject: [FIX] revert client action params in url bzr revid: al@openerp.com-20121011164114-3y7rfbdrg5hdg39c --- addons/web/static/src/js/views.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 4dfdd92f5e5..5f90c4215f7 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -172,7 +172,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ state['action'] = this.inner_action.id; } else if (this.inner_action.type == 'ir.actions.client') { state['action'] = this.inner_action.tag; - state = _.extend(this.inner_action.params || {}, state); + //state = _.extend(this.inner_action.params || {}, state); } } if(!this.dialog) { -- cgit v1.2.3 From 25181d3f51904b86e84a1ff8b6be8aaf98790090 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 11 Oct 2012 22:03:46 +0200 Subject: [FIX] view_form copy bzr revid: al@openerp.com-20121011200346-p0gq5tq1wsoqyx0a --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 08c071c7d0e..963aafc1db8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -784,7 +784,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM var def = $.Deferred(); $.when(this.has_been_loaded).then(function() { self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) { - return self.record_created({ result : new_id }); + return self.record_created(new_id); }).then(function() { return self.to_edit_mode(); }).then(function() { -- cgit v1.2.3 From e50cb5b2c7b6b8d0c213613afdffaa1296b2a759 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 11 Oct 2012 22:15:23 +0200 Subject: [FIX] dont show errors on reload bzr revid: al@openerp.com-20121011201523-d4t500g4nnfq9ce6 --- addons/web/static/src/js/chrome.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 67e36678040..d7272d8d83f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -627,6 +627,7 @@ instance.web.Reload = function(parent, params) { hash = "#menu_id=" + menu_id; } var url = l.protocol + "//" + l.host + l.pathname + search + hash; + window.onerror = function() {}; window.location = url; }; instance.web.client_actions.add("reload", "instance.web.Reload"); -- cgit v1.2.3 From 833c7bdc521783aac25efe63b7f59bed65be7570 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 12 Oct 2012 11:50:04 +0530 Subject: [FIX]Change name of the event and 'on_pager_action' function bzr revid: vja@tinyerp.com-20121012062004-2an59ci8z5o9ijpu --- addons/web/static/src/js/view_form.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a648bbe10e9..75ab275d80b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -431,8 +431,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM do_notify_change: function() { this.$el.add(this.$buttons).addClass('oe_form_dirty'); }, - on_pager_action: function(action) { + execute_pager_action: function(action) { if (this.can_be_discarded()) { + this.trigger('pager_action_executed'); switch (action) { case 'first': this.dataset.index = 0; @@ -464,7 +465,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } this.$pager.on('click','a[data-pager-action]',function() { var action = $(this).data('pager-action'); - self.trigger('pager_action',self.on_pager_action(action)); + self.execute_pager_action(action); }); this.do_update_pager(); }, @@ -799,7 +800,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM $.when(this.has_been_loaded).then(function() { if (self.datarecord.id && confirm(_t("Do you really want to delete this record?"))) { self.dataset.unlink([self.datarecord.id]).then(function() { - self.on_pager_action('next'); + self.execute_pager_action('next'); def.resolve(); }); } else { @@ -3387,7 +3388,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ controller.on("load_record", self, function(){ once.resolve(); }); - controller.on('pager_action',self,self.save_any_view); + controller.on('pager_action_executed',self,self.save_any_view); } else if (view_type == "graph") { self.reload_current_view() } -- cgit v1.2.3 From ffb5a9c802ba4b0eed4196ff109c20e1c3381625 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 12 Oct 2012 14:08:27 +0530 Subject: [IMP]method name change. bzr revid: vme@tinyerp.com-20121012083827-hq8xrnn333foyiu3 --- addons/web/static/src/js/view_form.js | 22 +++++++++++----------- addons/web/static/src/js/view_list_editable.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 68a47259cec..54540fba801 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -747,7 +747,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, on_button_save: function() { var self = this; - return this.do_save().then(function(result) { + return this.save().then(function(result) { + self.trigger("save"); self.to_view_mode(); }); }, @@ -824,13 +825,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM * record or saving an existing one depending on whether the record * already has an id property. * - * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new + * @param {Boolean} [prepend_on_create=false] if ``save`` creates a new * record, should that record be inserted at the start of the dataset (by * default, records are added at the end) */ - do_save: function(prepend_on_create) { + save: function(prepend_on_create) { var self = this; - this.trigger("form_save"); return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() { try { var form_invalid = false, @@ -1001,7 +1001,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, recursive_save: function() { var self = this; - return $.when(this.do_save()).pipe(function(res) { + return $.when(this.save()).pipe(function(res) { if (self.dataset.parent_view) return self.dataset.parent_view.recursive_save(); }); @@ -1032,7 +1032,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return true; }, sidebar_context: function () { - return this.do_save().pipe(_.bind(function() {return this.get_fields_values();}, this)); + return this.save().pipe(_.bind(function() {return this.get_fields_values();}, this)); }, open_defaults_dialog: function () { var self = this; @@ -3521,7 +3521,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ if (!view.is_initialized.isResolved()) { return false; } - var res = $.when(view.do_save()); + var res = $.when(view.save()); if (!res.isResolved() && !res.isRejected()) { console.warn("Asynchronous get_value() is not supported in form view."); } @@ -3717,7 +3717,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ var self = this; this.ensure_saved().pipe(function () { if (parent_form) - return parent_form.do_save(); + return parent_form.save(); else return $.when(); }).then(function () { @@ -3856,7 +3856,7 @@ instance.web.form.One2ManyFormView = instance.web.FormView.extend({ this._super(data); var self = this; this.$buttons.find('button.oe_form_button_create').click(function() { - self.do_save().then(self.on_button_new); + self.save().then(self.on_button_new); }); }, do_notify_change: function() { @@ -4432,7 +4432,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ })); var $snbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save-new"); $snbutton.click(function() { - $.when(self.view_form.do_save()).then(function() { + $.when(self.view_form.save()).then(function() { self.view_form.reload_mutex.exec(function() { self.view_form.on_button_new(); }); @@ -4440,7 +4440,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ }); var $sbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save"); $sbutton.click(function() { - $.when(self.view_form.do_save()).then(function() { + $.when(self.view_form.save()).then(function() { self.view_form.reload_mutex.exec(function() { self.check_exit(); }); diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index fe0f525fe3f..4bf61895a09 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -724,7 +724,7 @@ openerp.web.list_editable = function (instance) { save: function () { var self = this; return this.form - .do_save(this.delegate.prepends_on_create()) + .save(this.delegate.prepends_on_create()) .pipe(function (result) { var created = result.created && !self.record.id; if (created) { -- cgit v1.2.3 From 7314375acacbd6561a3baaf045fb86974a4a165d Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 10:43:37 +0200 Subject: Ported m2m, still has to port m2mtags bzr revid: nicolas.vanhoren@openerp.com-20121012084337-7etwh54ugl4k01mu --- addons/web/static/src/js/view_form.js | 47 +++++++++++++---------------------- 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3905501e6cd..eda2c8a64f4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3210,7 +3210,6 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ lazy_build_o2m_kanban_view(); this.is_loaded = $.Deferred(); this.initial_is_loaded = this.is_loaded; - this.is_setted = $.Deferred(); this.form_last_update = $.Deferred(); this.init_form_last_update = this.form_last_update; this.is_started = false; @@ -3230,9 +3229,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ var self = this; - this.is_setted.then(function() { - self.load_views(); - }); + self.load_views(); this.is_loaded.then(function() { self.on("change:effective_readonly", self, function() { self.is_loaded = self.is_loaded.pipe(function() { @@ -3348,10 +3345,8 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ } }); }); - this.is_setted.then(function() { - $.async_when().then(function () { - self.viewmanager.appendTo(self.$el); - }); + $.async_when().then(function () { + self.viewmanager.appendTo(self.$el); }); return def; }, @@ -3431,7 +3426,6 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ if (this.dataset.index === null && this.dataset.ids.length > 0) { this.dataset.index = 0; } - self.is_setted.resolve(); this.trigger_on_change(); if (this.is_started) { return self.reload_current_view(); @@ -3960,36 +3954,33 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({ disable_utility_classes: true, init: function(field_manager, node) { this._super(field_manager, node); - this.set({"value": []}); this.is_loaded = $.Deferred(); this.initial_is_loaded = this.is_loaded; - this.is_setted = $.Deferred(); - }, - start: function() { - this._super.apply(this, arguments); - this.$el.addClass('oe_form_field oe_form_field_many2many'); - - var self = this; - this.dataset = new instance.web.form.Many2ManyDataSet(this, this.field.relation); this.dataset.m2m = this; + var self = this; this.dataset.on('unlink', self, function(ids) { self.dataset_changed(); }); + this.set_value([]); + }, + start: function() { + this.$el.addClass('oe_form_field oe_form_field_many2many'); - this.is_setted.then(function() { - self.load_view(); - }); + var self = this; + + self.load_view(); this.is_loaded.then(function() { self.on("change:effective_readonly", self, function() { self.is_loaded = self.is_loaded.pipe(function() { self.list_view.destroy(); return $.when(self.load_view()).then(function() { - self.reload_content(); + self.render_value(); }); }); }); }); + this._super.apply(this, arguments); }, set_value: function(value_) { value_ = value_ || []; @@ -3997,17 +3988,12 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({ value_ = value_[0][2]; } this._super(value_); - this.dataset.set_ids(value_); - var self = this; - self.reload_content(); - this.is_setted.resolve(); }, get_value: function() { return [commands.replace_with(this.get('value'))]; }, - is_false: function () { - return _(this.dataset.ids).isEmpty(); + return _(this.get("value")).isEmpty(); }, load_view: function() { var self = this; @@ -4034,14 +4020,15 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({ }); return loaded; }, - reload_content: function() { + render_value: function() { var self = this; + this.dataset.set_ids(this.get("value")); this.is_loaded = this.is_loaded.pipe(function() { return self.list_view.reload_content(); }); }, dataset_changed: function() { - this.set({'value': this.dataset.ids}); + this.internal_set_value(this.dataset.ids); }, }); -- cgit v1.2.3 From 31a42989a7e35641d4241c3c88e846c8d71dcfa5 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 12 Oct 2012 14:19:00 +0530 Subject: [IMP]Improve Code bzr revid: vja@tinyerp.com-20121012084900-zja87nszeh3q1ree --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 75ab275d80b..55b5434d1c5 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -433,7 +433,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, execute_pager_action: function(action) { if (this.can_be_discarded()) { - this.trigger('pager_action_executed'); switch (action) { case 'first': this.dataset.index = 0; @@ -449,6 +448,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM break; } this.reload(); + this.trigger('pager_action_executed'); } }, init_pager: function() { -- cgit v1.2.3 From f5216c706ae47ba23d265121f101e9d78d3f1407 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 12 Oct 2012 14:24:17 +0530 Subject: [FIX]move the trigger function bzr revid: vja@tinyerp.com-20121012085417-rrql4iyrevscyt80 --- addons/web/static/src/js/views.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 4172344c66e..e6439c28efe 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -532,12 +532,12 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.views[view_type].controller = controller; this.views[view_type].deferred.resolve(view_type); return $.when(view_promise).then(function() { - self.trigger("controller_inited",view_type,controller); if (self.searchview && self.flags.auto_search && view.controller.searchable !== false) { self.searchview.ready.then(self.searchview.do_search); } + self.trigger("controller_inited",view_type,controller); }); }, set_title: function(title) { -- cgit v1.2.3 From d17b33aea6cf3a198eb243a281e4feea48f22a6a Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 11:06:44 +0200 Subject: [FIX] problem with field reference bzr revid: nicolas.vanhoren@openerp.com-20121012090644-8wy3z4mr6080oa7b --- addons/web/static/src/js/view_form.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 963aafc1db8..fe49dc1b514 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1660,6 +1660,8 @@ instance.web.form.FormDialog = instance.web.Dialog.extend({ }); instance.web.form.compute_domain = function(expr, fields) { + if (! (expr instanceof Array)) + return !! expr; var stack = []; for (var i = expr.length - 1; i >= 0; i--) { var ex = expr[i]; @@ -4638,6 +4640,7 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan destroy_content: function() { if (this.fm) { this.fm.destroy(); + this.fm = undefined; } }, initialize_content: function() { @@ -4659,9 +4662,7 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan modifiers: JSON.stringify({readonly: this.get('effective_readonly')}), }}); this.selection.on("change:value", this, this.on_selection_changed); - this.selection.setElement(this.$(".oe_form_view_reference_selection")); - this.selection.renderElement(); - this.selection.start(); + this.selection.appendTo(this.$(".oe_form_view_reference_selection")); this.selection .on('focused', null, function () {self.trigger('focused')}) .on('blurred', null, function () {self.trigger('blurred')}); @@ -4671,9 +4672,7 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan modifiers: JSON.stringify({readonly: this.get('effective_readonly')}), }}); this.m2o.on("change:value", this, this.data_changed); - this.m2o.setElement(this.$(".oe_form_view_reference_m2o")); - this.m2o.renderElement(); - this.m2o.start(); + this.m2o.appendTo(this.$(".oe_form_view_reference_m2o")); this.m2o .on('focused', null, function () {self.trigger('focused')}) .on('blurred', null, function () {self.trigger('blurred')}); -- cgit v1.2.3 From dbe370f5851182427fcafb0484354a5672a89189 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 11:18:20 +0200 Subject: Ported m2mkanban and corrected bug in selection bzr revid: nicolas.vanhoren@openerp.com-20121012091820-u712bie1h2a84l8a --- addons/web/static/src/js/view_form.js | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a3a61168f17..69cb549203b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2671,13 +2671,6 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan this.$el.text(option ? option[1] : this.values[0][1]); } }, - is_syntax_valid: function() { - if (this.get("effective_readonly")) { - return true; - } - var value_ = this.values[this.$el.find('select')[0].selectedIndex]; - return !! value_; - }, focus: function() { this.$el.find('select:first').focus(); } @@ -4086,28 +4079,26 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( m2m_kanban_lazy_init(); this.is_loaded = $.Deferred(); this.initial_is_loaded = this.is_loaded; - this.is_setted = $.Deferred(); - }, - start: function() { - this._super.apply(this, arguments); var self = this; - this.dataset = new instance.web.form.Many2ManyDataSet(this, this.field.relation); this.dataset.m2m = this; this.dataset.on('unlink', self, function(ids) { self.dataset_changed(); }); + }, + start: function() { + this._super.apply(this, arguments); - this.is_setted.then(function() { - self.load_view(); - }); + var self = this; + + self.load_view(); this.is_loaded.then(function() { self.on("change:effective_readonly", self, function() { self.is_loaded = self.is_loaded.pipe(function() { self.kanban_view.destroy(); return $.when(self.load_view()).then(function() { - self.reload_content(); + self.render_value(); }); }); }); @@ -4119,10 +4110,6 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( value_ = value_[0][2]; } this._super(value_); - this.dataset.set_ids(value_); - var self = this; - self.reload_content(); - this.is_setted.resolve(); }, load_view: function() { var self = this; @@ -4149,8 +4136,9 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( }); return loaded; }, - reload_content: function() { + render_value: function() { var self = this; + this.dataset.set_ids(this.get("value")); this.is_loaded = this.is_loaded.pipe(function() { return self.kanban_view.do_search(self.build_domain(), self.dataset.get_context(), []); }); @@ -4177,7 +4165,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); self.dataset_changed(); - self.reload_content(); + self.render_value(); } }); }); @@ -4188,7 +4176,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( title: _t("Open: ") + self.string, write_function: function(id, data, options) { return self.dataset.write(id, data, {}).then(function() { - self.reload_content(); + self.render_value(); }); }, alternative_form_view: self.field.views ? self.field.views["form"] : undefined, -- cgit v1.2.3 From 942ca6cf164e0faf3f2b75c712c916f91ebf6a3a Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 12 Oct 2012 15:57:28 +0530 Subject: [IMP] bzr revid: vme@tinyerp.com-20121012102728-coosthdgxz17z20q --- addons/web/static/src/js/view_form.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d03c95d6192..a7026a7181e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2378,7 +2378,10 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ var self = this; this.$input = this.$el.find('input.oe_datepicker_master'); this.$input_picker = this.$el.find('input.oe_datepicker_container'); - this.$input.change(this.on_change); + this.$input.change(function(){ + self.datetime_changed(); + }); + this.picker({ onClose: this.on_picker_select, onSelect: this.on_picker_select, @@ -2446,11 +2449,11 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ format_client: function(v) { return instance.web.format_value(v, {"widget": this.type_of_date}); }, - on_change: function() { - this.trigger('datetime_on_change'); + datetime_changed: function() { if (this.is_valid_()) { this.set_value_from_ui_(); } + this.trigger("datetime_changed"); } }); @@ -2473,7 +2476,7 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc initialize_content: function() { if (!this.get("effective_readonly")) { this.datewidget = this.build_widget(); - this.datewidget.on('datetime_on_change', this,_.bind(function() { + this.datewidget.on('datetime_changed', this, _.bind(function() { this.set({'value': this.datewidget.get_value()}); }, this)); this.datewidget.appendTo(this.$el); -- cgit v1.2.3 From 0602cd5748c46582175109208af58e40af96bb59 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 12 Oct 2012 16:01:04 +0530 Subject: [IMP]trigger event when date is valid. bzr revid: vme@tinyerp.com-20121012103104-pe3w6qs02nygfyb7 --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a7026a7181e..fa8b8713a8f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2452,8 +2452,8 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ datetime_changed: function() { if (this.is_valid_()) { this.set_value_from_ui_(); + this.trigger("datetime_changed"); } - this.trigger("datetime_changed"); } }); -- cgit v1.2.3 From 36fa302c351846b09cd530a7e7674e489346f2d3 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 13:14:40 +0200 Subject: Fixed bug in m2m tags bzr revid: nicolas.vanhoren@openerp.com-20121012111440-2y1q0745nv7nouiy --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 69cb549203b..3297b60e60d 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3825,8 +3825,8 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in this._drop_shown = false; }, start: function() { - this._super(); instance.web.form.ReinitializeFieldMixin.start.call(this); + this._super(); }, initialize_content: function() { if (this.get("effective_readonly")) -- cgit v1.2.3 From 4112f2b3a76f2ad924fa35a2ddfc9c654d7ac8cd Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 12 Oct 2012 17:49:11 +0530 Subject: [IMP]method name change bzr revid: vme@tinyerp.com-20121012121911-nmzuomg2p87qiszp --- addons/web/static/src/js/data.js | 6 +++--- addons/web/static/src/js/view_form.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index bfe4506c679..1731f1effaa 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -834,7 +834,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ } $.extend(cached.values, record.values); if (dirty) - this.trigger("dataset_on_change"); + this.trigger("dataset_changed", id); return $.Deferred().resolve(true).promise(); }, unlink: function(ids, callback, error_callback) { @@ -848,7 +848,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.to_write = _.reject(this.to_write, function(x) { return _.include(ids, x.id);}); this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);}); this.set_ids(_.without.apply(_, [this.ids].concat(ids))); - this.trigger("dataset_on_change"); + this.trigger("dataset_changed", ids); return $.async_when({result: true}).then(callback); }, reset_ids: function(ids) { @@ -945,7 +945,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ }, alter_ids: function(n_ids) { this._super(n_ids); - this.trigger("dataset_on_change"); + this.trigger("dataset_changed", n_ids); }, }); instance.web.BufferedDataSet.virtual_id_regex = /^one2many_v_id_.*$/; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 7fa4860a67c..c3a94838cf6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3287,7 +3287,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ this.dataset.o2m = this; this.dataset.parent_view = this.view; this.dataset.child_name = this.name; - this.dataset.on('dataset_on_change', this, function() { + this.dataset.on('dataset_changed', this, function() { self.trigger_on_change(); }); @@ -3582,7 +3582,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({ create_function: function(data) { return self.o2m.dataset.create(data).then(function(r) { self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r])); - self.o2m.dataset.trigger("dataset_on_change"); + self.o2m.dataset.trigger("dataset_changed", r); }); }, write_function: function(id, data, options) { @@ -3672,7 +3672,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ create_function: function(data, callback, error_callback) { return self.o2m.dataset.create(data).then(function(r) { self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r])); - self.o2m.dataset.trigger("dataset_on_change"); + self.o2m.dataset.trigger("dataset_changed", r); }).then(callback, error_callback); }, read_function: function() { -- cgit v1.2.3 From ccfa2e83d4784b4ea165ae12b5befbdae3ef1a67 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 14:37:13 +0200 Subject: Modified documentation. bzr revid: nicolas.vanhoren@openerp.com-20121012123713-6cmnayk7pr3mgs4p --- addons/web/static/src/js/view_form.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3297b60e60d..20c796a1d8b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1954,12 +1954,9 @@ instance.web.form.FieldInterface = { /** * Called by the form view to indicate the value of the field. * - * set_value() may return an object that can be passed to $.when() that represents the moment when - * the field has finished all operations necessary before the user can effectively use the widget. - * * Multiple calls to set_value() can occur at any time and must be handled correctly by the implementation, - * regardless of any asynchronous operation currently running and the status of any promise that a - * previous call to set_value() could have returned. + * regardless of any asynchronous operation currently running. Calls to set_value() can and will also occur + * before the widget is inserted into the DOM. * * set_value() must be able, at any moment, to handle the syntax returned by the "read" method of the * osv class in the OpenERP server as well as the syntax used by the set_value() (see below). It must -- cgit v1.2.3 From db64cf70977a774ca5890ace6fb119bccadb4f7f Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Fri, 12 Oct 2012 15:01:40 +0200 Subject: [FIX] Fixed naming related to datetime widget changes. bzr revid: vta@openerp.com-20121012130140-a1nzawstkgy8a9lx --- addons/web/static/src/js/view_form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 983dd5e6f82..ee790d8f94a 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2380,7 +2380,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ this.$input = this.$el.find('input.oe_datepicker_master'); this.$input_picker = this.$el.find('input.oe_datepicker_container'); this.$input.change(function(){ - self.datetime_changed(); + self.change_datetime(); }); this.picker({ @@ -2450,7 +2450,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ format_client: function(v) { return instance.web.format_value(v, {"widget": this.type_of_date}); }, - datetime_changed: function() { + change_datetime: function() { if (this.is_valid_()) { this.set_value_from_ui_(); this.trigger("datetime_changed"); -- cgit v1.2.3 From e70d879accfd93751fa6ecd7fea1acfd9cc7e4ef Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 12 Oct 2012 14:54:18 +0200 Subject: [FIX] add option to avoid actions to be pushed as state. Used for login and action extracted from hash. Full state of client actions is pushed. bzr revid: chs@openerp.com-20121012125418-jbw3iut85riepz47 --- addons/web/static/src/js/chrome.js | 9 ++++----- addons/web/static/src/js/views.js | 6 +++++- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index d7272d8d83f..2cf7ab4e5f8 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1021,15 +1021,13 @@ instance.web.WebClient = instance.web.Client.extend({ var state = $.bbq.getState(true); var action = { - 'type': 'ir.actions.client', - 'tag': 'login', - 'params': state + type: 'ir.actions.client', + tag: 'login', + _push_me: false, }; this.action_manager.do_action(action); this.action_manager.inner_widget.on('login_successful', this, function() { - this.do_push_state(state); - this._current_state = null; // ensure the state will be loaded this.show_application(); // will load the state we just pushed }); }, @@ -1105,6 +1103,7 @@ instance.web.WebClient = instance.web.Client.extend({ }); }); } else { + state._push_me = false; // no need to push state back... this.action_manager.do_load_state(state, !!this._current_state); } } diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 47a06e37ddc..cb4f440110d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -164,6 +164,10 @@ instance.web.ActionManager = instance.web.Widget.extend({ state = state || {}; if (this.getParent() && this.getParent().do_push_state) { if (this.inner_action) { + if (this.inner_action._push_me === false) { + // this action has been explicitly marked as not pushable + return; + } state['title'] = this.inner_action.name; if(this.inner_action.type == 'ir.actions.act_window') { state['model'] = this.inner_action.res_model; @@ -172,7 +176,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ state['action'] = this.inner_action.id; } else if (this.inner_action.type == 'ir.actions.client') { state['action'] = this.inner_action.tag; - //state = _.extend(this.inner_action.params || {}, state); + state = _.extend(this.inner_action.params || {}, state); } } if(!this.dialog) { -- cgit v1.2.3 From 5f4e81d2bb84c9986ac9bd9959806affba7e11e3 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 14:56:20 +0200 Subject: Corrected multiple rendering problem in m2o bzr revid: nicolas.vanhoren@openerp.com-20121012125620-h2pgav1nyj5tpq2z --- addons/web/static/src/js/view_form.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 20c796a1d8b..c37264c258f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2144,7 +2144,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w */ instance.web.form.ReinitializeWidgetMixin = { /** - * Default implementation of start(), use it or call explicitly initialize_field(). + * Default implementation of, you should not override it, use initialize_field() instead. */ start: function() { this.initialize_field(); @@ -2175,10 +2175,6 @@ instance.web.form.ReinitializeWidgetMixin = { * switch. */ instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.ReinitializeWidgetMixin, { - initialize_field: function() { - instance.web.form.ReinitializeWidgetMixin.initialize_field.call(this); - this.render_value(); - }, reinitialize: function() { instance.web.form.ReinitializeWidgetMixin.reinitialize.call(this); this.render_value(); @@ -2868,21 +2864,20 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.current_display = null; this.is_started = false; }, - start: function() { - instance.web.form.ReinitializeFieldMixin.start.call(this); + reinit_value: function(val) { + this.internal_set_value(val); + this.floating = false; + if (this.is_started) + this.render_value(); + }, + initialize_field: function() { this.is_started = true; instance.web.bus.on('click', this, function() { if (!this.get("effective_readonly") && this.$input && this.$input.autocomplete('widget').is(':visible')) { this.$input.autocomplete("close"); } }); - this._super(); - }, - reinit_value: function(val) { - this.internal_set_value(val); - this.floating = false; - if (this.is_started) - this.render_value(); + instance.web.form.ReinitializeFieldMixin.initialize_field.call(this); }, initialize_content: function() { if (!this.get("effective_readonly")) @@ -3821,10 +3816,6 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in this._display_orderer = new instance.web.DropMisordered(); this._drop_shown = false; }, - start: function() { - instance.web.form.ReinitializeFieldMixin.start.call(this); - this._super(); - }, initialize_content: function() { if (this.get("effective_readonly")) return; -- cgit v1.2.3 From 40d2a376ca8e6ea7c66ebf77a13b11f48257977e Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 12 Oct 2012 15:01:40 +0200 Subject: [IMP] help debugging xhr calls bzr revid: chs@openerp.com-20121012130140-qgi8ret2oxoeko6d --- addons/web/static/src/js/data.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index ce85e0ac43f..8338ce8c7c0 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -280,7 +280,8 @@ instance.web.Model = instance.web.Class.extend({ kwargs = args; args = []; } - return instance.session.rpc('/web/dataset/call_kw', { + var debug = instance.session.debug ? '/'+this.name+':'+method : ''; + return instance.session.rpc('/web/dataset/call_kw' + debug, { model: this.name, method: method, args: args, -- cgit v1.2.3 From 48118a7afe17c45aa331511db6f0152ca7d7c0e1 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Fri, 12 Oct 2012 15:02:54 +0200 Subject: [IMP] Improved on close code. bzr revid: vta@openerp.com-20121012130254-kthondab91jph64x --- addons/web/static/src/js/chrome.js | 9 +++------ addons/web/static/src/js/views.js | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index a3fc3b80ea0..99e1a67f51b 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -70,7 +70,7 @@ instance.web.Dialog = instance.web.Widget.extend({ autoOpen: false, position: [false, 40], buttons: {}, - beforeClose: function () { self.on_close(); }, + beforeClose: function () { self.close(); }, resizeStop: this.on_resized }; for (var f in this) { @@ -150,17 +150,14 @@ instance.web.Dialog = instance.web.Widget.extend({ var res = this.start(); return res; }, - close: function() { - this.$el.dialog('close'); - }, - on_close: function() { - this.trigger("dialog_close"); + close: function() { if (this.__tmp_dialog_destroying) return; if (this.dialog_options.destroy_on_close) { this.__tmp_dialog_closing = true; this.destroy(); this.__tmp_dialog_closing = undefined; + this.trigger("dialog_close"); } }, on_resized: function() { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index a59e19f1609..c7f7049bd5e 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -286,8 +286,9 @@ instance.web.ActionManager = instance.web.Widget.extend({ buttons: { "Close": function() { $(this).dialog("close"); }}, dialogClass: executor.klass }); - if(on_close) - this.dialog.on("dialog_close",this,on_close); + if (on_close) { + this.dialog.on("dialog_close", this, on_close); + } } else { this.dialog_widget.destroy(); } -- cgit v1.2.3 From 49c1c88962dbd4c47fefa33d190a8a6ff6b940c2 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Fri, 12 Oct 2012 15:10:44 +0200 Subject: [FIX] Fixed naming related to selected_elements. bzr revid: vta@openerp.com-20121012131044-w4afp0shefzwlo7t --- addons/web/static/src/js/view_form.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ee790d8f94a..266092ebdfe 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2881,7 +2881,7 @@ instance.web.form.CompletionFieldMixin = { self.build_domain(), new instance.web.CompoundContext(self.build_context(), context || {}) ); - pop.on("select_elements",self,function(element_ids) { + pop.on("elements_selected", self, function(element_ids) { self.add_id(element_ids[0]); self.focus(); }); @@ -3600,7 +3600,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({ form_view_options: {'not_interactible_on_create':true}, readonly: self.o2m.get("effective_readonly") }); - pop.on("select_elements", self, function() { + pop.on("elements_selected", self, function() { self.o2m.reload_current_view(); }); }, @@ -3686,7 +3686,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ self.o2m.build_domain(), self.o2m.build_context() ); - pop.on("select_elements", self, function() { + pop.on("elements_selected", self, function() { self.o2m.reload_current_view(); }); } @@ -4123,7 +4123,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in this.m2m_field.build_context() ); var self = this; - pop.on("select_elements", self, function(element_ids) { + pop.on("elements_selected", self, function(element_ids) { _.each(element_ids, function(one_id) { if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); @@ -4238,7 +4238,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( new instance.web.CompoundDomain(this.build_domain(), ["!", ["id", "in", this.dataset.ids]]), this.build_context() ); - pop.on("select_elements", self, function(element_ids) { + pop.on("elements_selected", self, function(element_ids) { _.each(element_ids, function(one_id) { if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); @@ -4458,12 +4458,12 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ self.view_form.do_show(); }); }, - elements_selected: function(element_ids) { - this.trigger("select_elements",element_ids); + select_elements: function(element_ids) { + this.trigger("elements_selected", element_ids); }, check_exit: function(no_destroy) { if (this.created_elements.length > 0) { - this.elements_selected(this.created_elements); + this.select_elements(this.created_elements); this.created_elements = []; } this.destroy(); @@ -4574,7 +4574,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend }); var $sbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-select"); $sbutton.click(function() { - self.elements_selected(self.selected_ids); + self.select_elements(self.selected_ids); self.destroy(); }); }); @@ -4616,7 +4616,7 @@ instance.web.form.SelectCreateListView = instance.web.ListView.extend({ this.popup.new_object(); }, select_record: function(index) { - this.popup.elements_selected([this.dataset.ids[index]]); + this.popup.select_elements([this.dataset.ids[index]]); this.popup.destroy(); }, do_select: function(ids, records) { -- cgit v1.2.3 From 496d2035124fe7904ea22a2aa8d2edce0f1186ec Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 12 Oct 2012 16:08:58 +0200 Subject: [FIX] client action only serialize scalar values bzr revid: al@openerp.com-20121012140858-mzkv5ef8ozqqxq13 --- addons/web/static/src/js/views.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 589c034af38..b5bb3a7259d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -176,7 +176,13 @@ instance.web.ActionManager = instance.web.Widget.extend({ state['action'] = this.inner_action.id; } else if (this.inner_action.type == 'ir.actions.client') { state['action'] = this.inner_action.tag; - state = _.extend(this.inner_action.params || {}, state); + var params = {}; + _.each(this.inner_action.params, function(v, k) { + if(_.isString(v) || _.isNumber(v)) { + params[k] = v; + } + }); + state = _.extend(params || {}, state); } } if(!this.dialog) { -- cgit v1.2.3 From e3b7890ac30c4524b9ff919b91073b703a9d2e7e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 16:40:37 +0200 Subject: fixed bug with datetimes bzr revid: nicolas.vanhoren@openerp.com-20121012144037-u29a479c1oa4b3bw --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 259f1aee44c..63ef5ee21d0 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2445,7 +2445,7 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc } }, is_syntax_valid: function() { - if (!this.get("effective_readonly")) { + if (!this.get("effective_readonly") && this.datewidget) { return this.datewidget.is_valid_(); } return true; -- cgit v1.2.3 From 0bd69bd176c69abb9ec4d6bd98123296aad2d62b Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 16:43:52 +0200 Subject: Corrected some more problems with is_syntax_valid() bzr revid: nicolas.vanhoren@openerp.com-20121012144352-jejnnpu18otgrnvp --- addons/web/static/src/js/view_form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 63ef5ee21d0..9c25e11d748 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2210,7 +2210,7 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we } }, is_syntax_valid: function() { - if (!this.get("effective_readonly")) { + if (!this.get("effective_readonly") && this.$("input").size() > 0) { try { var value_ = this.parse_value(this.$el.find('input').val(), ''); return true; @@ -2500,7 +2500,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we this.$textarea.autosize(); }, is_syntax_valid: function() { - if (!this.get("effective_readonly")) { + if (!this.get("effective_readonly") && this.$textarea) { try { var value_ = instance.web.parse_value(this.$textarea.val(), this, ''); return true; -- cgit v1.2.3 From b399708ab80366ee34c0b5db6d3176ea554a7a12 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 12 Oct 2012 16:49:43 +0200 Subject: [MERGE] trunk-trigger-on_action manual bzr revid: al@openerp.com-20121012144943-h9wr9wtd59xe2pv8 --- addons/web/static/src/js/chrome.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 968b1acb0de..c993f3e3ad1 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -877,8 +877,6 @@ instance.web.UserMenu = instance.web.Widget.extend({ }; this.update_promise = this.update_promise.pipe(fct, fct); }, - on_action: function() { - }, on_menu_logout: function() { this.trigger('user_logout'); }, @@ -897,8 +895,7 @@ instance.web.UserMenu = instance.web.Widget.extend({ var $help = $(QWeb.render("UserMenu.about", {version_info: res})); $help.find('a.oe_activate_debug_mode').click(function (e) { e.preventDefault(); - window.location = $.param.querystring( - window.location.href, 'debug'); + window.location = $.param.querystring( window.location.href, 'debug'); }); instance.web.dialog($help, {autoOpen: true, modal: true, width: 507, height: 290, resizable: false, title: _t("About")}); @@ -1037,8 +1034,7 @@ instance.web.WebClient = instance.web.Client.extend({ self.menu.on('menu_click', this, this.on_menu_action); self.user_menu = new instance.web.UserMenu(self); self.user_menu.replace(this.$el.find('.oe_user_menu_placeholder')); - self.user_menu.on('user_logout', self, this.proxy('on_logout')); - self.user_menu.on_action.add(this.proxy('on_menu_action')); + self.user_menu.on('user_logout', self, self.on_logout); self.user_menu.do_update(); self.bind_hashchange(); self.set_title(); -- cgit v1.2.3 From 0c1b8b5a4cf0987af967dd206d451d9a95639430 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Oct 2012 16:51:43 +0200 Subject: Fix problem with focus called before the field is started bzr revid: nicolas.vanhoren@openerp.com-20121012145143-oooxbdovspsjcxfk --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9c25e11d748..f16773829ab 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -678,7 +678,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } for (var i = 0; i < fields_order.length; i += 1) { var field = this.fields[fields_order[i]]; - if (!field.get('effective_invisible') && !field.get('effective_readonly')) { + if (!field.get('effective_invisible') && !field.get('effective_readonly') && field.$label) { if (field.focus() !== false) { break; } -- cgit v1.2.3 From e273ccce6394f0cc092aff81f9e33310b9bc6310 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 14 Oct 2012 21:55:14 +0200 Subject: [FIX] fix of r3147 bzr revid: fp@openerp.com-20121014195514-xnw8b23qtnjm1it2 --- addons/web/static/src/css/base.css | 31 ++++++++++++++++--------------- addons/web/static/src/css/base.sass | 12 +++++++----- 2 files changed, 23 insertions(+), 20 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index c8f1567bee9..8925c3a0964 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -25,6 +25,7 @@ display: none !important; } } + .openerp.openerp_webclient_container { height: 100%; position: relative; @@ -1184,7 +1185,7 @@ color: white; padding: 2px 4px; margin: 1px 6px 0 0; - border: 1px solid lightgrey; + border: 1px solid lightGray; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); -moz-border-radius: 4px; -webkit-border-radius: 4px; @@ -1209,7 +1210,7 @@ transform: scale(1.1); } .openerp .oe_secondary_submenu .oe_active { - border-top: 1px solid lightgrey; + border-top: 1px solid lightGray; border-bottom: 1px solid #dedede; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2), inset 0 -1px 3px rgba(40, 40, 40, 0.2); @@ -2054,36 +2055,36 @@ width: 400px; padding-bottom: 0; } -.openerp .oe_form header .oe_tags div.oe_chatter { +.openerp .oe_form div.oe_chatter { min-width: 650px; max-width: 860px; margin: 0 auto; padding: 16px 0 48px; } -.openerp .oe_form header .oe_tags div.oe_form_configuration p, .openerp .oe_form header .oe_tags div.oe_form_configuration ul, .openerp .oe_form header .oe_tags div.oe_form_configuration ol { +.openerp .oe_form div.oe_form_configuration p, .openerp .oe_form div.oe_form_configuration ul, .openerp .oe_form div.oe_form_configuration ol { color: #aaaaaa; max-width: 650px; } -.openerp .oe_form header .oe_tags div.oe_form_configuration label { +.openerp .oe_form div.oe_form_configuration label { min-width: 150px; } -.openerp .oe_form header .oe_tags div.oe_form_configuration .oe_form_group_cell_label { +.openerp .oe_form div.oe_form_configuration .oe_form_group_cell_label { padding: 1px 0; } -.openerp .oe_form header .oe_tags div.oe_form_configuration .oe_form_group_cell div div { +.openerp .oe_form div.oe_form_configuration .oe_form_group_cell div div { padding: 1px 0; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer { +.openerp .oe_form .oe_subtotal_footer { width: 1% !important; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer td.oe_form_group_cell { +.openerp .oe_form .oe_subtotal_footer td.oe_form_group_cell { text-align: right; padding: 0 !important; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer td.oe_form_group_cell_label { +.openerp .oe_form .oe_subtotal_footer td.oe_form_group_cell_label { border-right: none; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer .oe_subtotal_footer_separator { +.openerp .oe_form .oe_subtotal_footer .oe_subtotal_footer_separator { width: 108px; border-top: 1px solid #cacaca; margin-top: 4px; @@ -2091,14 +2092,14 @@ font-weight: bold; font-size: 18px; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer label:after { +.openerp .oe_form .oe_subtotal_footer label:after { content: ":"; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer label.oe_subtotal_footer_separator { +.openerp .oe_form .oe_subtotal_footer label.oe_subtotal_footer_separator { font-weight: bold !important; padding: 2px 11px 2px 0px !important; } -.openerp .oe_form header .oe_tags .oe_subtotal_footer label.oe_form_label_help { +.openerp .oe_form .oe_subtotal_footer label.oe_form_label_help { font-weight: normal; } .openerp .oe_form .oe_form_button { @@ -2130,7 +2131,7 @@ } .openerp .oe_form .oe_form_label_help[for] span, .openerp .oe_form .oe_form_label[for] span { font-size: 80%; - color: darkgreen; + color: darkGreen; vertical-align: top; position: relative; top: -4px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 823ced4e24f..a1adfe67e75 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1616,16 +1616,18 @@ $sheet-max-width: 860px ul display: inline-block float: right - .oe_button, + .oe_button margin: 3px 2px 1px &:first-child margin-left: 6px // }}} // FormView.custom tags and classes {{{ - .oe_form header .oe_tags - margin: 5px 0 0 5px - width: 400px - padding-bottom: 0 + .oe_form + header + .oe_tags + margin: 5px 0 0 5px + width: 400px + padding-bottom: 0 div.oe_chatter min-width: 650px max-width: $sheet-max-width -- cgit v1.2.3 From 76fe8893311de8e12b62d74a0e6df134bae9068c Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 15 Oct 2012 09:53:20 +0200 Subject: [FIX] Fixed some small issues concerning event triggering. bzr revid: vta@openerp.com-20121015075320-2zgo32vy5fengm7b --- addons/web/static/src/js/data.js | 10 +++++----- addons/web/static/src/js/view_form.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 48210007dcd..fe7632d0612 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -568,7 +568,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ */ write: function (id, data, options) { options = options || {}; - return this._model.call('write', [[id], data], {context: this._model.context(options.context)}); + return this._model.call('write', [[id], data], {context: this._model.context(options.context)}).then(this.trigger('dataset_changed', id, data, options)); }, /** * Deletes an existing record from the database @@ -576,8 +576,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * @param {Number|String} ids identifier of the record to delete */ unlink: function(ids) { - this.trigger('unlink', ids); - return this._model.call('unlink', [ids], {context: this._model.context()}); + return this._model.call('unlink', [ids], {context: this._model.context()}).then(this.trigger('dataset_changed', ids)); }, /** * Calls an arbitrary RPC method @@ -779,6 +778,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ self.index = self.index <= self.ids.length - 1 ? self.index : (self.ids.length > 0 ? self.ids.length -1 : 0); } + this.trigger("dataset_changed", ids, callback, error_callback); }); }, size: function () { @@ -835,7 +835,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ } $.extend(cached.values, record.values); if (dirty) - this.trigger("dataset_changed", id); + this.trigger("dataset_changed", id, data, options); return $.Deferred().resolve(true).promise(); }, unlink: function(ids, callback, error_callback) { @@ -849,7 +849,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.to_write = _.reject(this.to_write, function(x) { return _.include(ids, x.id);}); this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);}); this.set_ids(_.without.apply(_, [this.ids].concat(ids))); - this.trigger("dataset_changed", ids); + this.trigger("dataset_changed", ids, callback, error_callback); return $.async_when({result: true}).then(callback); }, reset_ids: function(ids) { diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 67a36661b12..60c33090c56 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -749,7 +749,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM on_button_save: function() { var self = this; return this.save().then(function(result) { - self.trigger("save"); + self.trigger("save", result); self.to_view_mode(); }); }, -- cgit v1.2.3 From faf49e3fcbdac0091ee141b7bbe080738f92666d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 15 Oct 2012 12:21:35 +0200 Subject: [FIX] Action counter: renamed filter automatically added when clicking on the counter, from needaction_pending to message_unread. bzr revid: tde@openerp.com-20121015102135-hnnd57fi187m0j0a --- addons/web/static/src/js/chrome.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index c993f3e3ad1..9fe1940d85f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1116,7 +1116,7 @@ instance.web.WebClient = instance.web.Client.extend({ .pipe(function (result) { var action = result; if (options.needaction) { - action.context.search_default_needaction_pending = true; + action.context.search_default_message_unread = true; } return $.when(self.action_manager.do_action(action, null, true)).fail(function() { self.menu.open_menu(options.previous_menu_id); -- cgit v1.2.3 From 38582c8410f77ef4b105f634fd543f630dd43613 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 15 Oct 2012 14:38:56 +0200 Subject: [FIX] Problem in editable list view: in sale orders, when we add a line in the order lines o2m then select a product, some strange numbers appear on the top left of the list view. bzr revid: nicolas.vanhoren@openerp.com-20121015123856-j4sgaqtf3oexg6of --- addons/web/static/src/js/view_list_editable.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 4bf61895a09..cd6b018ea0d 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -201,10 +201,7 @@ openerp.web.list_editable = function (instance) { }, function () { return self.editor.edit(item, function (field_name, field) { var cell = cells[field_name]; - if (!cell || field.get('effective_readonly')) { - // Readonly fields can just remain the list's, - // form's usually don't have backgrounds &al - field.set({invisible: true}); + if (!cell) { return; } @@ -400,6 +397,21 @@ openerp.web.list_editable = function (instance) { }, setup_events: function () { var self = this; + _.each(this.editor.form.fields, function(field, field_name) { + var field; + var setting = false; + var set_invisible = function() { + if (!setting && field.get("effective_readonly")) { + setting = true; + field.set({invisible: true}); + setting = false; + } + }; + field.on("change:effective_readonly", self, set_invisible); + field.on("change:invisible", self, set_invisible); + set_invisible(); + }); + this.editor.$el.on('keyup keydown', function (e) { if (!self.editor.is_editing()) { return; } var key = _($.ui.keyCode).chain() -- cgit v1.2.3 From 87ea306997c8b23b59cc5e35f71ec8e8d78e57a2 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 15 Oct 2012 14:51:23 +0200 Subject: [IMP] Modified formatting of m2o to be consistent with the m2o in form view bzr revid: nicolas.vanhoren@openerp.com-20121015125123-cyosgswtdxgtcom7 --- addons/web/static/src/js/formats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 3e5e6fecd5e..dd1fd95c97e 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -135,7 +135,7 @@ instance.web.format_value = function (value, descriptor, value_if_empty) { Math.round((value % 1) * 60)); case 'many2one': // name_get value format - return value[1]; + return value[1].split("\n")[0]; case 'one2many': case 'many2many': if (typeof value === 'string') { -- cgit v1.2.3 From 3db503e42373e734e63f021d574c9e2ce4e30375 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 15 Oct 2012 15:24:44 +0200 Subject: [IMP] Now form view relation popups use $buttons. bzr revid: nicolas.vanhoren@openerp.com-20121015132444-v3379ccn5xau8220 --- addons/web/static/src/js/view_form.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 60c33090c56..a3c6a4d7722 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4404,9 +4404,8 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ self.check_exit(true); }, title: this.options.title || "", - buttons: [{text:"tmp"}], }, this.$el).open(); - this.$buttonpane = dialog.$el.dialog("widget").find(".ui-dialog-buttonpane").html(""); + this.$buttonpane = dialog.$buttons; this.start(); }, setup_form_view: function() { -- cgit v1.2.3 From ed445ff91a15f18ee98cd8af202e7799d8480f6b Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 15 Oct 2012 15:38:15 +0200 Subject: [REVERT] revert commit 3224 because it didn't reproduced the original behavior and some on_close were forgotten bzr revid: nicolas.vanhoren@openerp.com-20121015133815-hmkz6h1bkhnbq7up --- addons/web/static/src/js/chrome.js | 8 +++++--- addons/web/static/src/js/views.js | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index c993f3e3ad1..078082d07fd 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -70,7 +70,7 @@ instance.web.Dialog = instance.web.Widget.extend({ autoOpen: false, position: [false, 40], buttons: {}, - beforeClose: function () { self.close(); }, + beforeClose: function () { self.on_close(); }, resizeStop: this.on_resized }; for (var f in this) { @@ -150,14 +150,16 @@ instance.web.Dialog = instance.web.Widget.extend({ var res = this.start(); return res; }, - close: function() { + close: function() { + this.$el.dialog('close'); + }, + on_close: function() { if (this.__tmp_dialog_destroying) return; if (this.dialog_options.destroy_on_close) { this.__tmp_dialog_closing = true; this.destroy(); this.__tmp_dialog_closing = undefined; - this.trigger("dialog_close"); } }, on_resized: function() { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index b5bb3a7259d..78cab1c3e33 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -296,9 +296,8 @@ instance.web.ActionManager = instance.web.Widget.extend({ buttons: { "Close": function() { $(this).dialog("close"); }}, dialogClass: executor.klass }); - if (on_close) { - this.dialog.on("dialog_close", this, on_close); - } + if(on_close) + this.dialog.on_close.add(on_close); } else { this.dialog_widget.destroy(); } -- cgit v1.2.3 From 04353719e97715a64c105a45aed36480dc6d02f0 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 15 Oct 2012 15:52:36 +0200 Subject: [IMP] removed on_close in Dialog bzr revid: nicolas.vanhoren@openerp.com-20121015135236-r5809kwwbcqo67tj --- addons/web/static/src/js/chrome.js | 5 +++-- addons/web/static/src/js/views.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 078082d07fd..5f05095d880 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -70,7 +70,7 @@ instance.web.Dialog = instance.web.Widget.extend({ autoOpen: false, position: [false, 40], buttons: {}, - beforeClose: function () { self.on_close(); }, + beforeClose: function () { self.trigger("closing") }, resizeStop: this.on_resized }; for (var f in this) { @@ -84,6 +84,7 @@ instance.web.Dialog = instance.web.Widget.extend({ } _.extend(this.dialog_options, options); } + this.on("closing", this, this._closing); }, get_options: function(options) { var self = this, @@ -153,7 +154,7 @@ instance.web.Dialog = instance.web.Widget.extend({ close: function() { this.$el.dialog('close'); }, - on_close: function() { + _closing: function() { if (this.__tmp_dialog_destroying) return; if (this.dialog_options.destroy_on_close) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 78cab1c3e33..1554d347552 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -297,7 +297,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ dialogClass: executor.klass }); if(on_close) - this.dialog.on_close.add(on_close); + this.dialog.on("closing", null, on_close); } else { this.dialog_widget.destroy(); } -- cgit v1.2.3 From a2399bc651137e27409b4c6d533b912ec8f47627 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 15 Oct 2012 15:56:07 +0200 Subject: [FIX] Small problem with formatting bzr revid: nicolas.vanhoren@openerp.com-20121015135607-j2c3dedpxaiuivd3 --- addons/web/static/src/js/formats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index dd1fd95c97e..03b2c5b775d 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -135,7 +135,7 @@ instance.web.format_value = function (value, descriptor, value_if_empty) { Math.round((value % 1) * 60)); case 'many2one': // name_get value format - return value[1].split("\n")[0]; + return value[1] ? value[1].split("\n")[0] : value[1]; case 'one2many': case 'many2many': if (typeof value === 'string') { -- cgit v1.2.3 From 8743b1f85ad19f1fb0aca5948370f3dff96ed9ff Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 16 Oct 2012 10:52:49 +0200 Subject: [FIX] problem with field status bzr revid: nicolas.vanhoren@openerp.com-20121016085249-2qpvp31br5kd4knk --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index a09897862f6..320ac37eb1b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1078,7 +1078,7 @@ -
  • +
  • -- cgit v1.2.3 From 5a6158bb5ff58ef9d2ea9540ea348fec466c1a7e Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 16 Oct 2012 11:38:34 +0200 Subject: [FIX] Broken Dataset#unlink bzr revid: fme@openerp.com-20121016093834-ulhdzbhvasw9msp5 --- addons/web/static/src/js/data.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index fe7632d0612..76c2eb41ec1 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -774,11 +774,11 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ if (self._length) { self._length -= 1; } - if (this.index !== null) { + if (self.index !== null) { self.index = self.index <= self.ids.length - 1 ? self.index : (self.ids.length > 0 ? self.ids.length -1 : 0); } - this.trigger("dataset_changed", ids, callback, error_callback); + self.trigger("dataset_changed", ids, callback, error_callback); }); }, size: function () { -- cgit v1.2.3 From 97cb5f4dc417f60e8f2598ea82a1fa3cc5a80383 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 16 Oct 2012 11:58:24 +0200 Subject: [FIX] small problems in dialog actions bzr revid: nicolas.vanhoren@openerp.com-20121016095824-woasfpauu7unye5n --- addons/web/static/src/js/chrome.js | 4 +++- addons/web/static/src/js/views.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index a281745faa0..54d26c5ec5b 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -70,7 +70,9 @@ instance.web.Dialog = instance.web.Widget.extend({ autoOpen: false, position: [false, 40], buttons: {}, - beforeClose: function () { self.trigger("closing") }, + beforeClose: function () { + self.trigger("closing"); + }, resizeStop: this.on_resized }; for (var f in this) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 1554d347552..7cbc346b59f 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -290,13 +290,13 @@ instance.web.ActionManager = instance.web.Widget.extend({ } var widget = executor.widget(); if (executor.action.target === 'new') { - if (this.dialog === null) { + if (this.dialog === null || this.dialog.isDestroyed()) { // These buttons will be overwrited by