From bc82a989f2449165f28955e7a11f944dbdf2e036 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 11 Apr 2011 10:30:32 +0200 Subject: [IMP] Renamed Notification methods 'default' -> notify , 'alert' -> warn bzr revid: fme@openerp.com-20110411083032-zc87gltpnw2z7s0r --- addons/base/static/src/js/chrome.js | 9 ++------- addons/base/static/src/js/data.js | 2 +- addons/base/static/src/js/form.js | 12 ++++++------ addons/base/static/src/js/search.js | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index b26dccffb2e..920973e640a 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -245,12 +245,7 @@ openerp.base.Notification = openerp.base.BasicController.extend({ text: text }); }, - // TODO remove to avoid default as attribute - 'default': function(title, text) { - this.notify(title,text); - }, - // TODO change into warn to avoid alert - alert: function(title, text) { + warn: function(title, text) { this.$element.notify('create', 'oe_notification_alert', { title: title, text: text @@ -907,7 +902,7 @@ openerp.base.WebClient = openerp.base.Controller.extend({ this.header.start(); this.login.start(); this.menu.start(); - this.notification['default']("OpenERP Client", "The openerp client has been initialized."); + this.notification.notify("OpenERP Client", "The openerp client has been initialized."); }, on_logged: function() { this.action = new openerp.base.ActionManager(this.session, "oe_app"); diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js index 8f5d6168e75..c16bf8eb81b 100644 --- a/addons/base/static/src/js/data.js +++ b/addons/base/static/src/js/data.js @@ -100,7 +100,7 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base. }, callback); }, unlink: function(ids) { - this.notification['default']("Unlink", ids); + this.notification.notify("Unlink", ids); }, call: function (method, ids, args, callback) { ids = ids || []; diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index bf42fc4fd7f..e31f03510d8 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -234,24 +234,24 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base } }); msg += ""; - this.notification.alert("The following fields are invalid :", msg); + this.notification.warn("The following fields are invalid :", msg); }, on_saved: function(r) { if (!r.result) { this.log("Record was not saved"); } else { // Check response for exceptions, display error - this.notification['default']("Record saved", "The record #" + this.datarecord.id + " has been saved."); + this.notification.notify("Record saved", "The record #" + this.datarecord.id + " has been saved."); } }, do_search: function (domains, contexts, groupbys) { - this.notification['default']("Searching form"); + this.notification.notify("Searching form"); }, on_action: function (action) { - this.notification['default']('Executing action ' + action); + this.notification.notify('Executing action ' + action); }, do_cancel: function () { - this.notification['default']("Cancelling form"); + this.notification.notify("Cancelling form"); } }); @@ -720,7 +720,7 @@ openerp.base.form.FieldOne2ManyDatasSet = openerp.base.DataSetStatic.extend({ this._super(id, data, callback); }, unlink: function() { - this.notification['default']('Unlinking o2m ' + this.ids); + this.notification.notify('Unlinking o2m ' + this.ids); } }); diff --git a/addons/base/static/src/js/search.js b/addons/base/static/src/js/search.js index ef10992d75f..21d1408f087 100644 --- a/addons/base/static/src/js/search.js +++ b/addons/base/static/src/js/search.js @@ -215,7 +215,7 @@ openerp.base.SearchView = openerp.base.Controller.extend({ * @param {Array} errors a never-empty array of error objects */ on_invalid: function (errors) { - this.notification['default']("Invalid Search", "triggered from search view"); + this.notification.notify("Invalid Search", "triggered from search view"); }, do_clear: function (e) { if (e && e.preventDefault) { e.preventDefault(); } -- cgit v1.2.3 From 86c1b252e69224c39851598d68acc5a6ead6b5c9 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 11 Apr 2011 13:35:16 +0200 Subject: [ADD] Added record creation. Refactored form view. bzr revid: fme@openerp.com-20110411113516-s8ydhmknehgbwp2n --- addons/base/static/src/js/data.js | 7 +- addons/base/static/src/js/form.js | 135 ++++++++++++++++++++++---------------- 2 files changed, 83 insertions(+), 59 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js index c16bf8eb81b..7b1a930c88f 100644 --- a/addons/base/static/src/js/data.js +++ b/addons/base/static/src/js/data.js @@ -89,7 +89,12 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base. context: this.context }, callback); }, - create: function() { + create: function(data, callback) { + return this.rpc('/base/dataset/create', { + model: this.model, + data: data, + context: this.context + }, callback); }, write: function (id, data, callback) { return this.rpc('/base/dataset/save', { diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index e31f03510d8..3de0bbfd32a 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -27,6 +27,7 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base this.fields = {}; this.datarecord = {}; this.ready = false; + this.show_invalid = true; }, start: function() { //this.log('Starting FormView '+this.model+this.view_id) @@ -69,16 +70,18 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base if (record) { this.datarecord = record; for (var f in this.fields) { - this.fields[f].set_value(this.datarecord[f]); + this.fields[f].set_value(this.datarecord[f] || false); + this.fields[f].validate(); } if (!record.id) { + this.show_invalid = false; // Second pass in order to trigger the onchanges in case of new record for (var f in record) { - this.fields[f].on_ui_change(); + this.on_form_changed(this.fields[f]); } } this.on_form_changed(); - this.ready = true; + this.show_invalid = this.ready = true; } else { this.log("No record received"); } @@ -197,6 +200,7 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base }); }, do_save: function() { + var self = this; if (!this.ready) { return false; } @@ -206,6 +210,7 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base f = this.fields[f]; if (f.invalid) { invalid = true; + f.update_dom(); } else if (f.touched) { values[f.name] = f.get_value(); } @@ -214,13 +219,19 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base this.on_invalid(); } else { this.log("About to save", values); - this.dataset.write(this.datarecord.id, values, this.on_saved); + if (!this.datarecord.id) { + this.dataset.create(values, function() { + self.datarecord.id = arguments[0].result; + self.on_saved.apply(self, arguments); + }); + } else { + this.dataset.write(this.datarecord.id, values, this.on_saved); + } } }, do_save_edit: function() { - if (this.do_save()) { - this.switch_readonly(); - } + this.do_save(); + //this.switch_readonly(); Use promises }, switch_readonly: function() { }, @@ -499,6 +510,9 @@ openerp.base.form.Field = openerp.base.form.Widget.extend({ this.invalid = false; this.update_dom(); }, + set_value_from_ui: function() { + this.value = undefined; + }, get_value: function() { return this.value; }, @@ -506,10 +520,17 @@ openerp.base.form.Field = openerp.base.form.Widget.extend({ this._super.apply(this, arguments); this.$element.toggleClass('disabled', this.readonly); this.$element.toggleClass('required', this.required); - this.$element.toggleClass('invalid', this.invalid); + if (this.view.show_invalid) { + this.$element.toggleClass('invalid', this.invalid); + } }, on_ui_change: function() { this.touched = true; + this.set_value_from_ui(); + this.validate(); + this.view.on_form_changed(this); + }, + validate: function() { } }); @@ -531,31 +552,41 @@ openerp.base.form.FieldChar = openerp.base.form.Field.extend({ this._super.apply(this, arguments); this.$element.find('input').attr('disabled', this.readonly); }, - on_ui_change: function() { - this._super.apply(this, arguments); + set_value_from_ui: function() { this.value = this.$element.find('input').val(); - this.invalid = this.required && this.value == ""; - this.view.on_form_changed(this); + }, + validate: function() { + this.invalid = false; + if (this.value === false || this.value === "") { + this.invalid = this.required; + } else if (this.validation_regex) { + this.invalid = !this.validation_regex.test(this.value); + } } }); openerp.base.form.FieldEmail = openerp.base.form.FieldChar.extend({ + init: function(view, node) { + this._super(view, node); + this.validation_regex = /@/; + } }); openerp.base.form.FieldUrl = openerp.base.form.FieldChar.extend({ }); openerp.base.form.FieldFloat = openerp.base.form.FieldChar.extend({ + init: function(view, node) { + this._super(view, node); + this.validation_regex = /^\d+(\.\d+)?$/; + }, set_value: function(value) { this._super.apply(this, arguments); var show_value = (value != null && value !== false) ? value.toFixed(2) : ''; - this.$element.find('input').val(value); + this.$element.find('input').val(show_value); }, - on_ui_change: function() { - this._super.apply(this, arguments); + set_value_from_ui: function() { this.value = this.$element.find('input').val().replace(/,/g, '.'); - this.invalid = (this.required && this.value == "") || !this.value.match(/^\d+(\.\d+)?$/) ; - this.view.on_form_changed(this); } }); @@ -563,23 +594,13 @@ openerp.base.form.FieldDate = openerp.base.form.FieldChar.extend({ init: function(view, node) { this._super(view, node); this.template = "FieldDate"; + this.validation_regex = /^\d+-\d+-\d+$/; }, start: function() { this._super.apply(this, arguments); this.$element.find('input').change(this.on_ui_change).datepicker({ dateFormat: 'yy-mm-dd' }); - }, - set_value: function(value) { - this._super.apply(this, arguments); - var show_value = (value != null && value !== false) ? value : ''; - this.$element.find('input').val(show_value); - }, - on_ui_change: function() { - this._super.apply(this, arguments); - this.value = this.$element.find('input').val(); - this.invalid = this.required && this.value == ""; - this.view.on_form_changed(this); } }); @@ -587,6 +608,7 @@ openerp.base.form.FieldDatetime = openerp.base.form.FieldChar.extend({ init: function(view, node) { this._super(view, node); this.template = "FieldDatetime"; + this.validation_regex = /^\d+-\d+-\d+( \d+:\d+(:\d+)?)?$/; }, start: function() { this._super.apply(this, arguments); @@ -594,17 +616,6 @@ openerp.base.form.FieldDatetime = openerp.base.form.FieldChar.extend({ dateFormat: 'yy-mm-dd', timeFormat: 'hh:mm:ss' }); - }, - set_value: function(value) { - this._super.apply(this, arguments); - var show_value = (value != null && value !== false) ? value : ''; - this.$element.find('input').val(show_value); - }, - on_ui_change: function() { - this._super.apply(this, arguments); - this.value = this.$element.find('input').val(); - this.invalid = this.required && this.value == ""; - this.view.on_form_changed(this); } }); @@ -612,6 +623,7 @@ openerp.base.form.FieldText = openerp.base.form.Field.extend({ init: function(view, node) { this._super(view, node); this.template = "FieldText"; + this.validation_regex = null; }, start: function() { this._super.apply(this, arguments); @@ -626,11 +638,16 @@ openerp.base.form.FieldText = openerp.base.form.Field.extend({ this._super.apply(this, arguments); this.$element.find('textarea').attr('disabled', this.readonly); }, - on_ui_change: function() { - this._super.apply(this, arguments); + set_value_from_ui: function() { this.value = this.$element.find('textarea').val(); - this.invalid = this.required && this.value == ""; - this.view.on_form_changed(this); + }, + validate: function() { + this.invalid = false; + if (this.value === false || this.value === "") { + this.invalid = this.required; + } else if (this.validation_regex) { + this.invalid = !this.validation_regex.test(this.value); + } } }); @@ -652,15 +669,15 @@ openerp.base.form.FieldBoolean = openerp.base.form.Field.extend({ this._super.apply(this, arguments); this.$element.find('input')[0].checked = value; }, + set_value_from_ui: function() { + this.value = this.$element.find('input').is(':checked'); + }, update_dom: function() { this._super.apply(this, arguments); - this.$element.find('textarea').attr('disabled', this.readonly); + this.$element.find('input').attr('disabled', this.readonly); }, - on_ui_change: function() { - this._super.apply(this, arguments); - this.value = this.$element.find('input').is(':checked'); + validate: function() { this.invalid = this.required && !this.value; - this.view.on_form_changed(this); } }); @@ -685,15 +702,15 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({ this.$element.find('select')[0].selectedIndex = 0; } }, + set_value_from_ui: function() { + this.value = this.$element.find('select').val(); + }, update_dom: function() { this._super.apply(this, arguments); this.$element.find('select').attr('disabled', this.readonly); }, - on_ui_change: function() { - this._super.apply(this, arguments); - this.value = this.$element.find('select').val(); - this.invalid = this.required && this.value == ""; - this.view.on_form_changed(this); + validate: function() { + this.invalid = this.required && this.value === ""; } }); @@ -744,12 +761,14 @@ openerp.base.form.FieldOne2Many = openerp.base.form.Field.extend({ this.viewmanager = new openerp.base.form.FieldOne2ManyViewManager(this.view.session, this.element_id, this.dataset, views); this.viewmanager.start(); }, - set_value_CASSEEEEEEEEEEEEEEEEE: function(value) { + set_value: function(value) { this.value = value; - this.log("o2m.set_value",value); - this.viewmanager.dataset.ids = value; - this.viewmanager.dataset.ids.count = value.length; - this.viewmanager.views.list.controller.do_update(); + if (value != false) { + this.log("o2m.set_value",value); + this.viewmanager.dataset.ids = value; + this.viewmanager.dataset.count = value.length; + this.viewmanager.views.list.controller.do_update(); + } }, get_value: function(value) { return this.operations; -- cgit v1.2.3 From bfacf53e04731b039c79e1c442e6843f6e12b629 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 11 Apr 2011 13:45:29 +0200 Subject: [IMP] Open new window. bzr revid: nicolas.vanhoren@openerp.com-20110411114529-332vb6wtrocrwjm0 --- addons/base/static/src/base.html | 1 + addons/base/static/src/js/views.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/base.html b/addons/base/static/src/base.html index 3c8f76a6e23..bd717d32f34 100644 --- a/addons/base/static/src/base.html +++ b/addons/base/static/src/base.html @@ -15,6 +15,7 @@ + diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index 1e3851c218f..890f69448a5 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -228,8 +228,9 @@ openerp.base.ExternalActionManager = openerp.base.Controller.extend({ viewmanager.start(); } else if (action.target == "current") { this.rpc("/base/session/save_session_action", {the_action:action}, function(key) { - var url = window.location.href; - //window.open(); + var url = window.location.protocol + "//" + window.location.host + + window.location.pathname + "?" + jQuery.param({s_action:""+key}); + window.open(url); }); } } -- cgit v1.2.3 From b1f219c5025ff1f116e054a74292ba79a0832214 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 11 Apr 2011 13:55:07 +0200 Subject: [IMP] Update dataset and pager in case of new record bzr revid: fme@openerp.com-20110411115507-p8x1jb11iok2xusr --- addons/base/static/src/js/form.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 3de0bbfd32a..69185628ffb 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -85,7 +85,7 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base } else { this.log("No record received"); } - this.do_update_pager(); + this.do_update_pager(record.id == null); }, on_form_changed: function(widget) { if (widget && widget.node.attrs.on_change) { @@ -115,11 +115,10 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base } this.dataset.read_index(_.keys(this.fields_view.fields), this.on_record_loaded); }, - do_update_pager: function() { + do_update_pager: function(hide_index) { var $pager = this.$element.find('div.oe_form_pager'); - $pager.find("button[data-pager-action='first'], button[data-pager-action='previous']").attr('disabled', this.dataset.index == 0); - $pager.find("button[data-pager-action='next'], button[data-pager-action='last']").attr('disabled', this.dataset.index == this.dataset.ids.length - 1); - this.$element.find('span.oe_pager_index').html(this.dataset.index + 1); + var index = hide_index ? '-' : this.dataset.index + 1; + this.$element.find('span.oe_pager_index').html(index); this.$element.find('span.oe_pager_count').html(this.dataset.count); }, do_onchange: function(widget, processed) { @@ -222,6 +221,10 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base if (!this.datarecord.id) { this.dataset.create(values, function() { self.datarecord.id = arguments[0].result; + self.dataset.ids.push(self.datarecord.id); + self.dataset.index = self.dataset.ids.length - 1; + self.dataset.count++; + self.do_update_pager(); self.on_saved.apply(self, arguments); }); } else { -- cgit v1.2.3 From 5c774c82fb4c117b3a63595c3080cff8f7d067e5 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 11 Apr 2011 13:59:33 +0200 Subject: [IMP] Implemented working saved actions. bzr revid: nicolas.vanhoren@openerp.com-20110411115933-xjmrhnsgrbhqlzfa --- addons/base/static/src/js/chrome.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 920973e640a..f567def9a23 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -473,8 +473,10 @@ openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.b continue; openerp[mod] = {}; // init module mod - openerp._openerp[mod](openerp); - self.module_loaded[mod] = true; + if(openerp._openerp[mod] != undefined) { + openerp._openerp[mod](openerp); + self.module_loaded[mod] = true; + } } } }); @@ -907,6 +909,17 @@ openerp.base.WebClient = openerp.base.Controller.extend({ on_logged: function() { this.action = new openerp.base.ActionManager(this.session, "oe_app"); this.action.start(); + + // if using saved actions, load the action and give it to action manager + debugger; + var parameters = jQuery.deparam(jQuery.param.querystring()); + if(parameters["s_action"] != undefined) { + var key = parseInt(parameters["s_action"]); + var self = this; + this.rpc("/base/session/get_session_action", {key:key}, function(action) { + self.action.do_action(action); + }); + } }, on_menu_action: function(action) { this.action.do_action(action); -- cgit v1.2.3 From b6ff5848b0ec8f9f90fb5aee7d7b78eba674aeec Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 11 Apr 2011 14:32:07 +0200 Subject: [FIX] Use parent element id for form header bzr revid: fme@openerp.com-20110411123207-q3ka2w9qg7z7n4jp --- addons/base/static/src/js/form.js | 14 +++++++------- addons/base/static/src/xml/base.xml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 69185628ffb..0eec8c79ebb 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -49,10 +49,10 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base self.on_pager_action(action); }); - this.$element.find('div.oe_form_buttons button.oe_form_button_save').click(this.do_save); - this.$element.find('div.oe_form_buttons button.oe_form_button_save_edit').click(this.do_save_edit); - this.$element.find('div.oe_form_buttons button.oe_form_button_cancel').click(this.do_cancel); - this.$element.find('div.oe_form_buttons button.oe_form_button_new').click(this.on_button_new); + this.$element.find('#' + this.element_id + '_header button.oe_form_button_save').click(this.do_save); + this.$element.find('#' + this.element_id + '_header button.oe_form_button_save_edit').click(this.do_save_edit); + this.$element.find('#' + this.element_id + '_header button.oe_form_button_cancel').click(this.do_cancel); + this.$element.find('#' + this.element_id + '_header button.oe_form_button_new').click(this.on_button_new); // sidebar stuff if (this.view_manager.sidebar) { @@ -116,10 +116,10 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base this.dataset.read_index(_.keys(this.fields_view.fields), this.on_record_loaded); }, do_update_pager: function(hide_index) { - var $pager = this.$element.find('div.oe_form_pager'); + var $pager = this.$element.find('#' + this.element_id + '_header div.oe_form_pager').eq(0); var index = hide_index ? '-' : this.dataset.index + 1; - this.$element.find('span.oe_pager_index').html(index); - this.$element.find('span.oe_pager_count').html(this.dataset.count); + $pager.find('span.oe_pager_index').html(index); + $pager.find('span.oe_pager_count').html(this.dataset.count); }, do_onchange: function(widget, processed) { processed = processed || []; diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index caf463cf4e0..57f9c81559e 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -224,7 +224,7 @@

-
+
-- cgit v1.2.3 From 9d3b604724298c2b078debc4591401853acd83af Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 11 Apr 2011 17:10:59 +0200 Subject: [FIX] Removed debugger keyword. bzr revid: nicolas.vanhoren@openerp.com-20110411151059-q7gfmt0qjfmbv1kh --- addons/base/static/src/css/base.css | 19 +++++++++++++++++-- addons/base/static/src/js/chrome.js | 1 - 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 7b686f53fb4..4a3aea4bb52 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -311,7 +311,7 @@ body.openerp { /* Main Application */ .openerp .application { - padding: 6px; + padding: 0px; } .openerp h2.oe_view_title { @@ -481,8 +481,19 @@ body.openerp { /* Sidebar */ .openerp .view-manager-main-table { + margin: 0; width:100%; + border-collapse:collapse; +} + +.openerp .view-manager-main-table tbody { + vertical-align: top; } + +.openerp .view-manager-main-content { + padding: 6px; +} + .openerp .view-manager-main-sidebar { vertical-align: top; width:0; @@ -493,6 +504,11 @@ body.openerp { .openerp .view-manager-main-sidebar .sidebar-main-div { padding:0; margin:0; + width:180px; + border-color: #1F1F1F; + border-style: solid; + border-width: 1px; + height:100%; } .openerp .view-manager-main-sidebar .sidebar-sub-div { @@ -504,7 +520,6 @@ body.openerp { list-style-type: none; margin: 0; padding: 0; - width: 120px; border-bottom: solid 1px #1F1F1F; } diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index f567def9a23..ec6462cac30 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -911,7 +911,6 @@ openerp.base.WebClient = openerp.base.Controller.extend({ this.action.start(); // if using saved actions, load the action and give it to action manager - debugger; var parameters = jQuery.deparam(jQuery.param.querystring()); if(parameters["s_action"] != undefined) { var key = parseInt(parameters["s_action"]); -- cgit v1.2.3 From 25a65bfc999af9086940d8c4e8709f886f189cd4 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 11 Apr 2011 17:59:46 +0200 Subject: [ADD] form: basic support of buttons type=object bzr revid: fme@openerp.com-20110411155946-oqk9qlaxxcdtv32r --- addons/base/static/src/js/form.js | 106 +++++++++++++++++++++++++++++++++----- 1 file changed, 93 insertions(+), 13 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 0eec8c79ebb..ce6a203a52d 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -113,7 +113,7 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base this.dataset.index = this.dataset.ids.length - 1; break; } - this.dataset.read_index(_.keys(this.fields_view.fields), this.on_record_loaded); + this.reload(); }, do_update_pager: function(hide_index) { var $pager = this.$element.find('#' + this.element_id + '_header div.oe_form_pager').eq(0); @@ -198,7 +198,7 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base self.on_record_loaded(result.result); }); }, - do_save: function() { + do_save: function(success) { var self = this; if (!this.ready) { return false; @@ -216,20 +216,19 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base } if (invalid) { this.on_invalid(); + return false; } else { this.log("About to save", values); if (!this.datarecord.id) { - this.dataset.create(values, function() { - self.datarecord.id = arguments[0].result; - self.dataset.ids.push(self.datarecord.id); - self.dataset.index = self.dataset.ids.length - 1; - self.dataset.count++; - self.do_update_pager(); - self.on_saved.apply(self, arguments); + this.dataset.create(values, function(r) { + self.on_created(r, success); }); } else { - this.dataset.write(this.datarecord.id, values, this.on_saved); + this.dataset.write(this.datarecord.id, values, function(r) { + self.on_saved(r, success); + }); } + return true; } }, do_save_edit: function() { @@ -250,12 +249,29 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base msg += ""; this.notification.warn("The following fields are invalid :", msg); }, - on_saved: function(r) { + on_saved: function(r, success) { if (!r.result) { - this.log("Record was not saved"); + this.notification.warn("Record not saved", "Problem while saving record."); } else { - // Check response for exceptions, display error this.notification.notify("Record saved", "The record #" + this.datarecord.id + " has been saved."); + if (success) { + success(r); + } + } + }, + on_created: function(r, success) { + if (!r.result) { + this.notification.warn("Record not created", "Problem while creating record."); + } else { + this.datarecord.id = arguments[0].result; + this.dataset.ids.push(this.datarecord.id); + this.dataset.index = this.dataset.ids.length - 1; + this.dataset.count++; + this.do_update_pager(); + this.notification.notify("Record created", "The record has been created with id #" + this.datarecord.id); + if (success) { + success(r); + } } }, do_search: function (domains, contexts, groupbys) { @@ -266,6 +282,15 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base }, do_cancel: function () { this.notification.notify("Cancelling form"); + }, + reload: function() { + if (this.datarecord.id) { + this.dataset.read_index(_.keys(this.fields_view.fields), this.on_record_loaded); + } else { + this.dataset.default_get(_.keys(this.fields), function(result) { + self.on_record_loaded(result.result); + }); + } } }); @@ -464,6 +489,61 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({ init: function(view, node) { this._super(view, node); this.template = "WidgetButton"; + }, + start: function() { + this._super.apply(this, arguments); + this.$element.click(this.on_click); + }, + on_click: function(saved) { + var self = this; + if (saved !== true) { + this.view.do_save(function() { + self.on_click(true); + }); + } else { + if (this.node.attrs.confirm) { + var dialog = $('
' + this.node.attrs.confirm + '
').dialog({ + title: 'Confirm', + modal: true, + buttons: { + Ok: function() { + self.on_confirmed(); + $(this).dialog("close"); + }, + Cancel: function() { + $(this).dialog("close"); + } + } + }); + } else { + this.on_confirmed(); + } + } + }, + on_confirmed: function() { + var attrs = this.node.attrs; + if (attrs.special) { + return this.log("Should close the popup"); + } else { + var type = attrs.type || 'workflow'; + var context = _.extend({}, this.view.dataset.context, attrs.context || {}); + switch(type) { + case 'object': + return this.view.dataset.call(attrs.name, [this.view.datarecord.id], [context], this.on_button_object); + break; + default: + this.log(_.sprintf("Unsupported button type : %s", type)); + } + } + }, + on_button_object: function(r) { + if (r.result === false) { + this.log("Button object returns false"); + } else if (r.result.constructor == Object) { + console.log("TODO: send action to action manager", r.result); + } else { + this.view.reload(); + } } }); -- cgit v1.2.3 From 0d42418698a35de7890f8917b29ea274b5603492 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 11 Apr 2011 18:22:39 +0200 Subject: [IMP] Updated css for sidebar. bzr revid: nicolas.vanhoren@openerp.com-20110411162239-70r6yom0hqnkbius --- addons/base/static/src/css/base.css | 45 +++++++++++++++++++------ addons/base/static/src/img/sideheader-a-bg.png | Bin 0 -> 126 bytes addons/base/static/src/js/views.js | 6 ++-- addons/base/static/src/xml/base.xml | 1 + 4 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 addons/base/static/src/img/sideheader-a-bg.png (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 4a3aea4bb52..5c619aa4fb2 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -484,6 +484,7 @@ body.openerp { margin: 0; width:100%; border-collapse:collapse; + height:100%; } .openerp .view-manager-main-table tbody { @@ -495,35 +496,59 @@ body.openerp { } .openerp .view-manager-main-sidebar { - vertical-align: top; width:0; padding:0; margin:0; } -.openerp .view-manager-main-sidebar .sidebar-main-div { +.openerp .sidebar-main-div { padding:0; margin:0; width:180px; - border-color: #1F1F1F; - border-style: solid; - border-width: 1px; + border-left-color: #D2CFCF; + border-left-style: solid; + border-left-width: 1px; height:100%; + font-family: Ubuntu, Helvetica, sans-serif; + font-size: 0.9em; +} + +.openerp .sidebar-main-div a { + color: #555; + text-decoration: none; } -.openerp .view-manager-main-sidebar .sidebar-sub-div { - border: solid 1px #1F1F1F; - border-bottom-width: 0; +.openerp .sidebar-main-div a:hover { + color: black; +} + +.openerp .view-manager-main-sidebar h2 { + margin:0; + font-family: Ubuntu, Helvetica, sans-serif; + font-size: 1.15em; + color: #8E8E8E; + text-shadow: white 0px 1px 0px; + padding-left: 10px; + padding-right: 21px; + height: 21px; + background: url(../img/sideheader-a-bg.png) repeat-x; + border-color: #D2CFCF; + border-style: solid; + border-top-width: 1px; + border-bottom-width: 1px; + border-left-width: 0; + border-right-width: 0; } .openerp .view-manager-main-sidebar ul { list-style-type: none; margin: 0; padding: 0; - border-bottom: solid 1px #1F1F1F; + display: block; } .openerp .view-manager-main-sidebar li { - padding: 3px; + display: block; + padding: 3px 3px 3px 10px; } diff --git a/addons/base/static/src/img/sideheader-a-bg.png b/addons/base/static/src/img/sideheader-a-bg.png new file mode 100644 index 00000000000..ca9b64b8b01 Binary files /dev/null and b/addons/base/static/src/img/sideheader-a-bg.png differ diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index 890f69448a5..12935c72132 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -188,10 +188,10 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({ set_toolbar: function(toolbar) { this.sections = []; var self = this; - _.each(["print", "action", "relate"], function(type) { - if (toolbar[type].length == 0) + _.each([["print", "Reports"], ["action", "Actions"], ["relate", "Links"]], function(type) { + if (toolbar[type[0]].length == 0) return; - var section = {elements:toolbar[type]}; + var section = {elements:toolbar[type[0]], label:type[1]}; self.sections.push(section); }); this.refresh(); diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 57f9c81559e..47e4c705364 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -530,6 +530,7 @@ +

    -- cgit v1.2.3 From 6c697ac27e65a9a2783eb4eddee4956ba80b8072 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 12 Apr 2011 00:54:30 +0200 Subject: [IMP] Improved styles bzr revid: fme@openerp.com-20110411225430-bdb1vfbl1tju8fe7 --- addons/base/static/src/css/base.css | 39 ++++++++++++++++++++++++++++++++++++- addons/base/static/src/xml/base.xml | 10 ++++++---- 2 files changed, 44 insertions(+), 5 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 5c619aa4fb2..cf78c0f3ae5 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -305,9 +305,29 @@ body.openerp { } /* Footer */ -.openerp .footer { +.openerp div.oe_footer { + background: none repeat scroll 0 0 #CCCCCC; + overflow: hidden; + padding: 5px 0; + position: relative; + -moz-box-shadow: inset 0px 3px 5px rgba(0, 0, 0, 0.4); + -webkit-box-shadow: inset 0px 3px 5px rgba(0, 0, 0, 0.4); + box-shadow: inset 0px 3px 5px rgba(0, 0, 0, 0.4); +} +.openerp div.oe_footer p.oe_footer_powered { + left: 50%; + margin: 0; + padding: 0 15px; + color: #666666; + font-weight: bold; + font-size: 0.8em; + font-family: Ubuntu, Helvetica, sans-serif; text-align: center; } +.openerp div.oe_footer p.oe_footer_powered a { + text-decoration: none; + color: #666666; +} /* Main Application */ .openerp .application { @@ -426,6 +446,22 @@ body.openerp { float: right; } +.openerp label.oe_form_label_help { + cursor: help; +} +.openerp label.oe_form_label, .openerp label.oe_form_label_help { + display: block; + text-align: right; +} +.openerp label.oe_form_label_help span { + font-size: 80%; + color: darkgreen; + vertical-align:top; + position: relative; + top: -4px; + padding: 0 2px; +} + /* Inputs */ .openerp input[type="text"], .openerp input[type="password"], .openerp select, .openerp textarea { -moz-box-sizing: border-box; @@ -438,6 +474,7 @@ body.openerp { -webkit-border-radius: 3px; border-radius: 3px; background: white; + min-width: 90px; } .openerp input[type="text"], .openerp input[type="password"], .openerp select, .openerp .button { height: 22px; diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 47e4c705364..9f5d45742f3 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -40,8 +40,8 @@ - - -- cgit v1.2.3 From 66e8ba68c58f59172137397217ab59ab301dc141 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 12 Apr 2011 01:48:24 +0200 Subject: [IMP] Improved accordion but can't fix nested problems. See Administration -> Customization -> Low Level Object No support for third + level. I think we should use something else because jQuery ui accordion is not meant to be nested bzr revid: fme@openerp.com-20110411234824-hoioajas8opji2jk --- addons/base/static/src/css/base.css | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index cf78c0f3ae5..2f4aa0b3faf 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -172,7 +172,10 @@ body.openerp { padding: 0 0 2px; border: none; background: none; - padding-left: 20px; + padding-left: 10px; +} +.openerp .secondary_menu h3 span, .openerp .secondary_menu h4 span { + left: 0 !important; } .openerp .secondary_menu a { display: block; @@ -201,6 +204,9 @@ body.openerp { text-shadow: #fff 0 1px 0; border: none !important; } +.openerp div.submenu_accordion div.menu_content a span { + padding-left: 20px; +} /* Header */ .openerp .header { -- cgit v1.2.3 From 9f780dd615953b28fcc2d7f388f005daaf554b0e Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 12 Apr 2011 10:38:31 +0200 Subject: [FIX] form: use boolean attributes (readonly, required,...) from field too bzr revid: fme@openerp.com-20110412083831-1a8e37ozysgrs6y1 --- addons/base/static/src/js/form.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index ce6a203a52d..65cb5498c54 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -435,12 +435,12 @@ openerp.base.form.WidgetFrame = openerp.base.form.Widget.extend({ } } }, - handle_node: function(n) { - var type = this.view.fields_view.fields[n.attrs.name] || {}; - var widget_type = n.attrs.widget || type.type || n.tag; - var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, n); - if (n.tag == 'field' && n.attrs.nolabel != '1') { - var label = new (openerp.base.form.widgets.get_object('label')) (this.view, n); + handle_node: function(node) { + var type = this.view.fields_view.fields[node.attrs.name] || {}; + var widget_type = node.attrs.widget || type.type || node.tag; + var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, node); + if (node.tag == 'field' && node.attrs.nolabel != '1') { + var label = new (openerp.base.form.widgets.get_object('label')) (this.view, node); label["for"] = widget; this.add_widget(label); } @@ -579,12 +579,13 @@ openerp.base.form.Field = openerp.base.form.Widget.extend({ if (node.attrs.nolabel != '1' && this.colspan > 1) { this.colspan--; } - this.field = view.fields_view.fields[node.attrs.name]; + this.field = view.fields_view.fields[node.attrs.name] || {}; this.string = node.attrs.string || this.field.string; this.help = node.attrs.help || this.field.help; - this.nolabel = (node.attrs.nolabel == '1'); - this.readonly = (node.attrs.readonly == '1'); - this.required = (node.attrs.required == '1'); + this.invisible = (this.invisible || this.field.invisible == '1'); + this.nolabel = (this.field.nolabel || node.attrs.nolabel) == '1'; + this.readonly = (this.field.readonly || node.attrs.readonly) == '1'; + this.required = (this.field.required || node.attrs.required) == '1'; this.invalid = false; this.touched = false; }, -- cgit v1.2.3 From 54cf1b688ee229218fc85c30107f1ced0bc635fc Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 12 Apr 2011 11:26:31 +0200 Subject: [ADD] Added progressbar widget bzr revid: fme@openerp.com-20110412092631-dvyi1w223yfjm7ot --- addons/base/static/src/js/form.js | 16 +++++++++++++++- addons/base/static/src/xml/base.xml | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'addons/base/static/src') diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 65cb5498c54..92bc44afd2b 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -765,6 +765,20 @@ openerp.base.form.FieldBoolean = openerp.base.form.Field.extend({ } }); +openerp.base.form.FieldProgressBar = openerp.base.form.Field.extend({ + init: function(view, node) { + this._super(view, node); + this.template = "FieldProgressBar"; + }, + start: function() { + this._super.apply(this, arguments); + this.$element.find('div').progressbar({ + value: this.value, + disabled: this.readonly + }); + } +}); + openerp.base.form.FieldTextXml = openerp.base.form.Field.extend({ // to replace view editor }); @@ -904,7 +918,7 @@ openerp.base.form.widgets = new openerp.base.Registry({ 'boolean' : 'openerp.base.form.FieldBoolean', 'float' : 'openerp.base.form.FieldFloat', 'integer': 'openerp.base.form.FieldFloat', - 'progressbar': 'openerp.base.form.FieldFloat', + 'progressbar': 'openerp.base.form.FieldProgressBar', 'float_time': 'openerp.base.form.FieldFloat' }); diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 9f5d45742f3..4c8e0d07f36 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -360,6 +360,9 @@ t-att-id="widget.element_id + '_field'" t-att-class="'field_' + widget.type"/> + +
    +