';
$.blockUI.defaults.css.border = '0';
$.blockUI.defaults.css["background-color"] = '';
- $.blockUI.spinners = [];
}
+
+instance.web.Throbber = instance.web.Widget.extend({
+ template: "Throbber",
+ start: function() {
+ var opts = {
+ lines: 13, // The number of lines to draw
+ length: 7, // The length of each line
+ width: 4, // The line thickness
+ radius: 10, // The radius of the inner circle
+ rotate: 0, // The rotation offset
+ color: '#FFF', // #rgb or #rrggbb
+ speed: 1, // Rounds per second
+ trail: 60, // Afterglow percentage
+ shadow: false, // Whether to render a shadow
+ hwaccel: false, // Whether to use hardware acceleration
+ className: 'spinner', // The CSS class to assign to the spinner
+ zIndex: 2e9, // The z-index (defaults to 2000000000)
+ top: 'auto', // Top position relative to parent in px
+ left: 'auto' // Left position relative to parent in px
+ };
+ this.spin = new Spinner(opts).spin(this.$element[0]);
+ },
+ destroy: function() {
+ if (this.spin)
+ this.spin.stop();
+ this._super();
+ },
+});
+instance.web.Throbber.throbbers = [];
+
instance.web.blockUI = function() {
var tmp = $.blockUI.apply($, arguments);
- var target = $(".oe_blockui_spin")[0];
- var opts = {
- lines: 13, // The number of lines to draw
- length: 7, // The length of each line
- width: 4, // The line thickness
- radius: 10, // The radius of the inner circle
- rotate: 0, // The rotation offset
- color: '#FFF', // #rgb or #rrggbb
- speed: 1, // Rounds per second
- trail: 60, // Afterglow percentage
- shadow: false, // Whether to render a shadow
- hwaccel: false, // Whether to use hardware acceleration
- className: 'spinner', // The CSS class to assign to the spinner
- zIndex: 2e9, // The z-index (defaults to 2000000000)
- top: 'auto', // Top position relative to parent in px
- left: 'auto' // Left position relative to parent in px
- };
- var spinner = new Spinner(opts).spin(target);
- $.blockUI.spinners.push(spinner);
+ var throbber = new instance.web.Throbber();
+ instance.web.Throbber.throbbers.push(throbber);
+ throbber.appendTo($(".oe_blockui_spin_container"));
return tmp;
}
instance.web.unblockUI = function() {
- _.each($.blockUI.spinners, function(el) {
- el.stop();
+ _.each(instance.web.Throbber.throbbers, function(el) {
+ el.destroy();
});
return $.unblockUI.apply($, arguments);
}
/** Setup default session */
-instance.connection = new instance.web.Session();
+instance.session = new instance.web.Session();
/** Configure default qweb */
instance.web._t = new instance.web.TranslationDataBase().build_translation_function();
@@ -604,8 +591,8 @@ instance.web._lt = function (s) {
return {toString: function () { return instance.web._t(s); }}
};
instance.web.qweb = new QWeb2.Engine();
-instance.web.qweb.default_dict['__debug__'] = instance.connection.debug; // Which one ?
-instance.web.qweb.debug = instance.connection.debug;
+instance.web.qweb.default_dict['__debug__'] = instance.session.debug; // Which one ?
+instance.web.qweb.debug = instance.session.debug;
instance.web.qweb.default_dict = {
'_' : _,
'_t' : instance.web._t
@@ -662,7 +649,7 @@ var _t = instance.web._t;
_t('%d years ago');
}
-instance.connection.on('module_loaded', this, function () {
+instance.session.on('module_loaded', this, function () {
// provide timeago.js with our own translator method
$.timeago.settings.translator = instance.web._t;
});
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index 2589afe5503..10fd727e57a 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -58,7 +58,7 @@ instance.web.Query = instance.web.Class.extend({
},
_execute: function () {
var self = this;
- return instance.connection.rpc('/web/dataset/search_read', {
+ return instance.session.rpc('/web/dataset/search_read', {
model: this._model.name,
fields: this._fields || false,
domain: this._model.domain(this._filter),
@@ -233,7 +233,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
kwargs = args;
args = [];
}
- return instance.connection.rpc('/web/dataset/call_kw', {
+ return instance.session.rpc('/web/dataset/call_kw', {
model: this.name,
method: method,
args: args,
@@ -256,7 +256,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
* @param {String} signal signal to trigger on the workflow
*/
exec_workflow: function (id, signal) {
- return instance.connection.rpc('/web/dataset/exec_workflow', {
+ return instance.session.rpc('/web/dataset/exec_workflow', {
model: this.name,
id: id,
signal: signal
@@ -282,7 +282,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
*/
context: function (context) {
return new instance.web.CompoundContext(
- instance.connection.user_context, this._context, context || {});
+ instance.session.user_context, this._context, context || {});
},
/**
* Button action caller, needs to perform cleanup if an action is returned
@@ -292,7 +292,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
* FIXME: remove when evaluator integrated
*/
call_button: function (method, args) {
- return instance.connection.rpc('/web/dataset/call_button', {
+ return instance.session.rpc('/web/dataset/call_button', {
model: this.name,
method: method,
domain_id: null,
@@ -439,7 +439,7 @@ instance.web.data = {
})
};
-instance.web.DataGroup = instance.web.OldWidget.extend( /** @lends openerp.web.DataGroup# */{
+instance.web.DataGroup = instance.web.CallbackEnabled.extend( /** @lends openerp.web.DataGroup# */{
/**
* Management interface between views and grouped collections of OpenERP
* records.
@@ -451,9 +451,9 @@ instance.web.DataGroup = instance.web.OldWidget.extend( /** @lends openerp.web.
* content of the current grouping level.
*
* @constructs instance.web.DataGroup
- * @extends instance.web.OldWidget
+ * @extends instance.web.CallbackEnabled
*
- * @param {instance.web.OldWidget} parent widget
+ * @param {instance.web.CallbackEnabled} parent widget
* @param {String} model name of the model managed by this DataGroup
* @param {Array} domain search domain for this DataGroup
* @param {Object} context context of the DataGroup's searches
@@ -524,13 +524,13 @@ instance.web.StaticDataGroup = instance.web.GrouplessDataGroup.extend( /** @lend
}
});
-instance.web.DataSet = instance.web.OldWidget.extend( /** @lends openerp.web.DataSet# */{
+instance.web.DataSet = instance.web.CallbackEnabled.extend( /** @lends openerp.web.DataSet# */{
/**
* DateaManagement interface between views and the collection of selected
* OpenERP records (represents the view's state?)
*
* @constructs instance.web.DataSet
- * @extends instance.web.OldWidget
+ * @extends instance.web.CallbackEnabled
*
* @param {String} model the OpenERP model this dataset will manage
*/
@@ -706,7 +706,7 @@ instance.web.DataSet = instance.web.OldWidget.extend( /** @lends openerp.web.Da
* @returns {$.Deferred}
*/
call_and_eval: function (method, args, domain_index, context_index, callback, error_callback) {
- return this.rpc('/web/dataset/call', {
+ return instance.session.rpc('/web/dataset/call', {
model: this.model,
method: method,
domain_id: domain_index == undefined ? null : domain_index,
@@ -805,6 +805,22 @@ instance.web.DataSet = instance.web.OldWidget.extend( /** @lends openerp.web.Da
alter_ids: function(n_ids) {
this.ids = n_ids;
},
+ /**
+ * Resequence records.
+ *
+ * @param {Array} ids identifiers of the records to resequence
+ * @returns {$.Deferred}
+ */
+ resequence: function (ids, options) {
+ options = options || {};
+ return instance.session.rpc('/web/dataset/resequence', {
+ model: this.model,
+ ids: ids,
+ context: this._model.context(options.context),
+ }).pipe(function (results) {
+ return results;
+ });
+ },
});
instance.web.DataSetStatic = instance.web.DataSet.extend({
init: function(parent, model, context, ids) {
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index 53daa40ae31..a7625631aa5 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -635,6 +635,16 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
return null;
}
},
+
+ add_common_inputs: function() {
+ // add Filters to this.inputs, need view.controls filled
+ (new instance.web.search.Filters(this));
+ // add custom filters to this.inputs
+ (new instance.web.search.CustomFilters(this));
+ // add Advanced to this.inputs
+ (new instance.web.search.Advanced(this));
+ },
+
on_loaded: function(data) {
var self = this;
this.fields_view = data.fields_view;
@@ -649,20 +659,13 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
data.fields_view['arch'].children,
data.fields_view.fields);
- // add Filters to this.inputs, need view.controls filled
- (new instance.web.search.Filters(this));
- // add custom filters to this.inputs
- (new instance.web.search.CustomFilters(this));
- // add Advanced to this.inputs
- (new instance.web.search.Advanced(this));
+ this.add_common_inputs();
// build drawer
var drawer_started = $.when.apply(
null, _(this.select_for_drawer()).invoke(
'appendTo', this.$element.find('.oe_searchview_drawer')));
- new instance.web.search.AddToReporting(this).appendTo($('.oe_searchview_drawer', this.$element));
-
// load defaults
var defaults_fetched = $.when.apply(null, _(this.inputs).invoke(
'facet_for_defaults', this.defaults)).then(function () {
@@ -683,9 +686,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
case 'advanced_filter':
this.extended_search.on_activate();
break;
- case 'add_to_dashboard':
- this.on_add_to_dashboard();
- break;
case '':
this.do_clear();
}
@@ -1613,7 +1613,7 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
}
var filter = {
name: $name.val(),
- user_id: private_filter ? instance.connection.uid : false,
+ user_id: private_filter ? instance.session.uid : false,
model_id: self.view.model,
context: results.context,
domain: results.domain
@@ -1678,74 +1678,6 @@ instance.web.search.Filters = instance.web.search.Input.extend({
}));
}
});
-instance.web.search.AddToReporting = instance.web.Widget.extend({
- template: 'SearchView.addtoreporting',
- _in_drawer: true,
- start: function () {
- var self = this;
- this.$element
- .on('click', 'h4', this.proxy('show_option'))
- .on('submit', 'form', function (e) {
- e.preventDefault();
- self.add_dashboard();
- });
- return this.load_data().then(this.proxy("render_data"));
- },
- load_data:function(){
- if (!instance.webclient) { return $.Deferred().reject(); }
- var dashboard_menu = instance.webclient.menu.data.data.children;
- return new instance.web.Model('ir.model.data')
- .query(['res_id'])
- .filter([['name','=','menu_reporting_dashboard']])
- .first().pipe(function (result) {
- var menu = _(dashboard_menu).chain()
- .pluck('children')
- .flatten(true)
- .find(function (child) { return child.id === result.res_id; })
- .value();
- return menu ? menu.children : [];
- });
- },
- render_data: function(dashboard_choices){
- var selection = instance.web.qweb.render(
- "SearchView.addtoreporting.selection", {
- selections: dashboard_choices});
- this.$("input").before(selection)
- },
- add_dashboard:function(){
- var self = this;
- var getParent = this.getParent();
- var view_parent = this.getParent().getParent();
- if (! view_parent.action || ! this.$element.find("select").val())
- return this.do_warn("Can't find dashboard action");
- var data = getParent.build_search_data();
- var context = new instance.web.CompoundContext(getParent.dataset.get_context() || []);
- var domain = new instance.web.CompoundDomain(getParent.dataset.get_domain() || []);
- _.each(data.contexts, context.add, context);
- _.each(data.domains, domain.add, domain);
- this.rpc('/web/searchview/add_to_dashboard', {
- menu_id: this.$element.find("select").val(),
- action_id: view_parent.action.id,
- context_to_save: context,
- domain: domain,
- view_mode: view_parent.active_view,
- name: this.$element.find("input").val()
- }, function(r) {
- if (r === false) {
- self.do_warn("Could not add filter to dashboard");
- } else {
- self.$element.toggleClass('oe_opened');
- self.do_notify("Filter added to dashboard", '');
- }
- });
- },
- show_option:function(){
- this.$element.toggleClass('oe_opened');
- if (! this.$element.hasClass('oe_opened'))
- return;
- this.$("input").val(this.getParent().fields_view.name || "" );
- }
-});
instance.web.search.Advanced = instance.web.search.Input.extend({
template: 'SearchView.advanced',
@@ -1805,11 +1737,11 @@ instance.web.search.Advanced = instance.web.search.Input.extend({
}
});
-instance.web.search.ExtendedSearchProposition = instance.web.OldWidget.extend(/** @lends instance.web.search.ExtendedSearchProposition# */{
+instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @lends instance.web.search.ExtendedSearchProposition# */{
template: 'SearchView.extended_search.proposition',
/**
* @constructs instance.web.search.ExtendedSearchProposition
- * @extends instance.web.OldWidget
+ * @extends instance.web.Widget
*
* @param parent
* @param fields
diff --git a/addons/web/static/src/js/test_support.js b/addons/web/static/src/js/test_support.js
index d46366326b7..314a12c91c6 100644
--- a/addons/web/static/src/js/test_support.js
+++ b/addons/web/static/src/js/test_support.js
@@ -1,12 +1,12 @@
openerp.test_support = {
- setup_connection: function (connection) {
+ setup_session: function (session) {
var origin = location.protocol+"//"+location.host;
- _.extend(connection, {
+ _.extend(session, {
origin: origin,
prefix: origin,
server: origin, // keep chs happy
//openerp.web.qweb.default_dict['_s'] = this.origin;
- rpc_function: connection.rpc_json,
+ rpc_function: session.rpc_json,
session_id: false,
uid: false,
username: false,
@@ -22,7 +22,7 @@ openerp.test_support = {
shortcuts: [],
active_id: null
});
- return connection.session_reload();
+ return session.session_reload();
},
module: function (title, tested_core, nonliterals) {
var conf = QUnit.config.openerp = {};
@@ -31,10 +31,10 @@ openerp.test_support = {
QUnit.stop();
var oe = conf.openerp = window.openerp.init();
window.openerp.web[tested_core](oe);
- var done = openerp.test_support.setup_connection(oe.connection);
+ var done = openerp.test_support.setup_session(oe.session);
if (nonliterals) {
done = done.pipe(function () {
- return oe.connection.rpc('/tests/add_nonliterals', {
+ return oe.session.rpc('/tests/add_nonliterals', {
domains: nonliterals.domains || [],
contexts: nonliterals.contexts || []
}).then(function (r) {
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 823bb4b57ad..e2a254773ae 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -255,7 +255,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
/**
*
* @param {Object} [options]
- * @param {Boolean} [editable=false] whether the form should be switched to edition mode. A value of ``false`` will keep the current mode.
+ * @param {Boolean} [mode=undefined] If specified, switch the form to specified mode. Can be "edit" or "view".
* @param {Boolean} [reload=true] whether the form should reload its content on show, or use the currently loaded record
* @return {$.Deferred}
*/
@@ -292,9 +292,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
});
}
return shown.pipe(function() {
- if (options.editable) {
- self.to_edit_mode();
- }
+ self._actualize_mode(options.mode || self.options.initial_mode);
self.$element.css({
opacity: '1',
filter: 'alpha(opacity = 100)'
@@ -634,12 +632,21 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this._actualize_mode("edit");
},
/**
- * Reactualize actual_mode.
+ * Ask the view to switch to a precise mode if possible. The view is free to
+ * not respect this command if the state of the dataset is not compatible with
+ * the new mode. For example, it is not possible to switch to edit mode if
+ * the current record is not yet saved in database.
+ *
+ * @param {string} [new_mode] Can be "edit", "view", "create" or undefined. If
+ * undefined the view will test the actual mode to check if it is still consistent
+ * with the dataset state.
*/
_actualize_mode: function(switch_to) {
var mode = switch_to || this.get("actual_mode");
if (! this.datarecord.id) {
mode = "create";
+ } else if (mode === "create") {
+ mode = "edit";
}
this.set({actual_mode: mode});
},
@@ -1656,7 +1663,7 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi
template = 'WidgetLabel.tooltip';
}
return QWeb.render(template, {
- debug: instance.connection.debug,
+ debug: instance.session.debug,
widget: widget
})},
gravity: $.fn.tipsy.autoBounds(50, 'nw'),
@@ -1733,7 +1740,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
start: function() {
this._super.apply(this, arguments);
this.$element.click(this.on_click);
- if (this.node.attrs.help || instance.connection.debug) {
+ if (this.node.attrs.help || instance.session.debug) {
this.do_attach_tooltip();
}
this.setupFocus(this.$element);
@@ -1930,7 +1937,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
}, this));
}
this.$label = this.view.$element.find('label[for=' + this.id_for_label + ']');
- if (instance.connection.debug) {
+ if (instance.session.debug) {
this.do_attach_tooltip(this, this.$label[0] || this.$element);
this.$label.off('dblclick').on('dblclick', function() {
console.log("Field '%s' of type '%s' in View: %o", self.name, (self.node.attrs.widget || self.field.type), self.view);
@@ -2173,7 +2180,7 @@ instance.web.form.FieldFloat = instance.web.form.FieldChar.extend({
}
});
-instance.web.DateTimeWidget = instance.web.OldWidget.extend({
+instance.web.DateTimeWidget = instance.web.Widget.extend({
template: "web.datepicker",
jqueryui_object: 'datetimepicker',
type_of_date: "datetime",
@@ -2394,44 +2401,54 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
* To find more information about CLEditor configutation: go to
* http://premiumsoftware.net/cleditor/docs/GettingStarted.html
*/
-instance.web.form.FieldTextHtml = instance.web.form.FieldText.extend({
-
- initialize_content: function() {
- this.$textarea = this.$element.find('textarea');
- var width = ((this.node.attrs || {}).editor_width || 468);
- var height = ((this.node.attrs || {}).editor_height || 100);
- this.$textarea.cleditor({
- width: width, // width not including margins, borders or padding
- height: height, // height not including margins, borders or padding
- controls: // controls to add to the toolbar
- "bold italic underline strikethrough | size " +
- "| removeformat | bullets numbering | outdent " +
- "indent | link unlink",
- sizes: // sizes in the font size popup
- "1,2,3,4,5,6,7",
- bodyStyle: // style to assign to document body contained within the editor
- "margin:4px; font:12px monospace; cursor:text; color:#1F1F1F"
- });
- this.$cleditor = this.$textarea.cleditor()[0];
- // call super now, because cleditor resets the disable attr
+instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
+ template: 'FieldTextHtml',
+ init: function() {
this._super.apply(this, arguments);
- // propagate disabled property to cleditor
- this.$cleditor.disable(this.$textarea.prop('disabled'));
+ if (this.field.type !== 'html') {
+ throw new Error(_.str.sprintf(
+ _t("Error with field %s, it is not allowed to use the widget 'html' with any other field type than 'html'"), this.string));
+ }
+ },
+ initialize_content: function() {
+ var self = this;
+ if (! this.get("effective_readonly")) {
+ self._updating_editor = false;
+ this.$textarea = this.$element.find('textarea');
+ var width = ((this.node.attrs || {}).editor_width || 468);
+ var height = ((this.node.attrs || {}).editor_height || 100);
+ this.$textarea.cleditor({
+ width: width, // width not including margins, borders or padding
+ height: height, // height not including margins, borders or padding
+ controls: // controls to add to the toolbar
+ "bold italic underline strikethrough " +
+ "| removeformat | bullets numbering | outdent " +
+ "indent | link unlink | source",
+ bodyStyle: // style to assign to document body contained within the editor
+ "margin:4px; font:12px monospace; cursor:text; color:#1F1F1F"
+ });
+ this.$cleditor = this.$textarea.cleditor()[0];
+ this.$cleditor.change(function() {
+ if (! self._updating_editor) {
+ self.$cleditor.updateTextArea();
+ self.set({'value': self.$textarea.val()});
+ }
+ });
+ }
},
-
set_value: function(value_) {
this._super.apply(this, arguments);
- this._dirty_flag = true;
+ this.render_value();
},
-
render_value: function() {
- this._super.apply(this, arguments);
- this.$cleditor.updateFrame();
- },
-
- get_value: function() {
- this.$cleditor.updateTextArea();
- return this.$textarea.val();
+ if (! this.get("effective_readonly")) {
+ this.$textarea.val(this.get('value'));
+ this._updating_editor = true;
+ this.$cleditor.updateFrame();
+ this._updating_editor = false;
+ } else {
+ this.$element.html(this.get('value'));
+ }
},
});
@@ -2706,6 +2723,11 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
this.floating = false;
this.render_value();
});
+ instance.web.bus.on('click', this, function() {
+ if (!this.get("effective_readonly") && this.$input && this.$input.autocomplete('widget').is(':visible')) {
+ this.$input.autocomplete("close");
+ }
+ });
},
initialize_content: function() {
if (!this.get("effective_readonly"))
@@ -2784,8 +2806,8 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
}
}
});
- var tip_def = $.Deferred();
- var untip_def = $.Deferred();
+ self.tip_def = $.Deferred();
+ self.untip_def = $.Deferred();
var tip_delay = 200;
var tip_duration = 15000;
var anyoneLoosesFocus = function() {
@@ -2807,24 +2829,25 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
}
self.floating = false;
}
- if (used && self.get("value") === false) {
- tip_def.reject();
- untip_def.reject();
- tip_def = $.Deferred();
- tip_def.then(function() {
+ if (used && self.get("value") === false && ! self.no_tipsy) {
+ self.tip_def.reject();
+ self.untip_def.reject();
+ self.tip_def = $.Deferred();
+ self.tip_def.then(function() {
self.$input.tipsy("show");
});
setTimeout(function() {
- tip_def.resolve();
- untip_def.reject();
- untip_def = $.Deferred();
- untip_def.then(function() {
+ self.tip_def.resolve();
+ self.untip_def.reject();
+ self.untip_def = $.Deferred();
+ self.untip_def.then(function() {
self.$input.tipsy("hide");
});
- setTimeout(function() {untip_def.resolve();}, tip_duration);
+ setTimeout(function() {self.untip_def.resolve();}, tip_duration);
}, tip_delay);
} else {
- tip_def.reject();
+ self.no_tipsy = false;
+ self.tip_def.reject();
}
};
this.$input.focusout(anyoneLoosesFocus);
@@ -2953,7 +2976,17 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
},
focus: function () {
this.$input.focus();
- }
+ },
+ _quick_create: function() {
+ this.no_tipsy = true;
+ this.tip_def.reject();
+ return instance.web.form.CompletionFieldMixin._quick_create.apply(this, arguments);
+ },
+ _search_create_popup: function() {
+ this.no_tipsy = true;
+ this.tip_def.reject();
+ return instance.web.form.CompletionFieldMixin._search_create_popup.apply(this, arguments);
+ },
});
/*
@@ -4078,7 +4111,7 @@ instance.web.form.Many2ManyQuickCreate = instance.web.Widget.extend({
/**
* Class with everything which is common between FormOpenPopup and SelectCreatePopup.
*/
-instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({
+instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
template: "AbstractFormPopup.render",
/**
* options:
@@ -4156,7 +4189,10 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({
this.view_form.appendTo(this.$element.find(".oe_popup_form"));
this.view_form.on_loaded.add_last(function() {
var multi_select = self.row_id === null && ! self.options.disable_multiple_selection;
- self.$buttonpane.html(QWeb.render("AbstractFormPopup.buttons", {multi_select: multi_select}));
+ self.$buttonpane.html(QWeb.render("AbstractFormPopup.buttons", {
+ multi_select: multi_select,
+ readonly: self.row_id !== null && self.options.readonly,
+ }));
var $snbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save-new");
$snbutton.click(function() {
$.when(self.view_form.do_save()).then(function() {
@@ -4177,11 +4213,6 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({
$cbutton.click(function() {
self.check_exit();
});
- if (self.row_id !== null && self.options.readonly) {
- $snbutton.hide();
- $sbutton.hide();
- $cbutton.text(_t("Close"));
- }
self.view_form.do_show();
});
},
@@ -4318,11 +4349,12 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
});
},
on_click_element: function(ids) {
+ var self = this;
this.selected_ids = ids || [];
if(this.selected_ids.length > 0) {
- this.$element.find(".oe_selectcreatepopup-search-select").removeAttr('disabled');
+ self.$buttonpane.find(".oe_selectcreatepopup-search-select").removeAttr('disabled');
} else {
- this.$element.find(".oe_selectcreatepopup-search-select").attr('disabled', "disabled");
+ self.$buttonpane.find(".oe_selectcreatepopup-search-select").attr('disabled', "disabled");
}
},
new_object: function() {
@@ -4616,8 +4648,9 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({
if (this.get('value') && ! /^\d+(\.\d*)? \w+$/.test(this.get('value'))) {
url = 'data:image/png;base64,' + this.get('value');
} else if (this.get('value')) {
+ var id = escape(JSON.stringify(this.view.datarecord.id || null));
url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' +
- this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + '&t=' + (new Date().getTime());
+ this.view.dataset.model +'&id=' + id + '&field=' + this.name + '&t=' + (new Date().getTime());
} else {
url = "/web/static/src/img/placeholder.png";
}
@@ -4793,7 +4826,7 @@ instance.web.form.widgets = new instance.web.Registry({
'email' : 'instance.web.form.FieldEmail',
'url' : 'instance.web.form.FieldUrl',
'text' : 'instance.web.form.FieldText',
- 'text_html' : 'instance.web.form.FieldTextHtml',
+ 'html' : 'instance.web.form.FieldTextHtml',
'date' : 'instance.web.form.FieldDate',
'datetime' : 'instance.web.form.FieldDatetime',
'selection' : 'instance.web.form.FieldSelection',
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 986b0e49faf..95dfa78fd63 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -2059,7 +2059,7 @@ instance.web.list.Button = instance.web.list.Column.extend({
title: this.string || '',
additional_attributes: isNaN(row_data["id"].value) && instance.web.BufferedDataSet.virtual_id_regex.test(row_data["id"].value) ?
'disabled="disabled" class="oe_list_button_disabled"' : '',
- prefix: instance.connection.prefix,
+ prefix: instance.session.prefix,
icon: this.icon,
alt: this.string || ''
});
@@ -2086,7 +2086,7 @@ instance.web.list.Binary = instance.web.list.Column.extend({
var text = _t("Download");
var download_url = _.str.sprintf(
'/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d',
- instance.connection.session_id, options.model, this.id, options.id);
+ instance.session.session_id, options.model, this.id, options.id);
if (this.filename) {
download_url += '&filename_field=' + this.filename;
if (row_data[this.filename]) {
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 2845d9afb73..0831d0c5f8e 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -159,7 +159,9 @@ instance.web.ActionManager = instance.web.Widget.extend({
//state = _.extend(this.inner_action.params || {}, state);
}
}
- this.getParent().do_push_state(state);
+ if(!this.dialog) {
+ this.getParent().do_push_state(state);
+ }
}
},
do_load_state: function(state, warm) {
@@ -222,7 +224,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
}
var type = action.type.replace(/\./g,'_');
var popup = action.target === 'new';
- var inline = action.target === 'inline';
+ var inline = action.target === 'inline' || action.target === 'inlineview';
action.flags = _.extend({
views_switcher : !popup && !inline,
search_view : !popup && !inline,
@@ -241,8 +243,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
this.dialog_stop();
this.clear_breadcrumbs();
},
-
- do_ir_actions_common: function(action, on_close) {
+ ir_actions_common: function(action, on_close) {
var self = this, klass, widget, post_process;
if (action.type === 'ir.actions.client') {
var ClientWidget = instance.web.client_actions.get_object(action.tag);
@@ -286,16 +287,8 @@ instance.web.ActionManager = instance.web.Widget.extend({
this.inner_widget.appendTo(this.$element);
}
},
-
ir_actions_act_window: function (action, on_close) {
var self = this;
- if (_(['base.module.upgrade', 'base.setup.installer'])
- .contains(action.res_model)) {
- var old_close = on_close;
- on_close = function () {
- instance.webclient.do_reload().then(old_close);
- };
- }
if (action.target !== 'new') {
if(action.menu_id) {
this.dialog_stop();
@@ -304,10 +297,10 @@ instance.web.ActionManager = instance.web.Widget.extend({
});
}
}
- return this.do_ir_actions_common(action, on_close);
+ return this.ir_actions_common(action, on_close);
},
ir_actions_client: function (action, on_close) {
- return this.do_ir_actions_common(action, on_close);
+ return this.ir_actions_common(action, on_close);
},
ir_actions_act_window_close: function (action, on_closed) {
if (!this.dialog && on_closed) {
@@ -350,9 +343,6 @@ instance.web.ActionManager = instance.web.Widget.extend({
ir_actions_act_url: function (action) {
window.open(action.url, action.target === 'self' ? '_self' : '_blank');
},
- ir_ui_menu: function (action) {
- this.getParent().do_action(action);
- }
});
instance.web.ViewManager = instance.web.Widget.extend({
@@ -475,17 +465,12 @@ instance.web.ViewManager = instance.web.Widget.extend({
// Lazy loading of views
var self = this;
var view = this.views[view_type];
- var controllerclass = this.registry.get_object(view_type);
+ var viewclass = this.registry.get_object(view_type);
var options = _.clone(view.options);
- if (view_type === "form" && this.action) {
- switch (this.action.target) {
- case 'new':
- case 'inline':
- options.initial_mode = 'edit';
- break;
- }
+ if (view_type === "form" && this.action && (this.action.target == 'new' || this.action.target == 'inline')) {
+ options.initial_mode = 'edit';
}
- var controller = new controllerclass(this, this.dataset, view.view_id, options);
+ var controller = new viewclass(this, this.dataset, view.view_id, options);
controller.on('history_back', this, function() {
var am = self.getParent();
@@ -1179,7 +1164,6 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({
});
instance.web.View = instance.web.Widget.extend({
- template: "EmptyComponent",
// name displayed in view switchers
display_name: '',
/**
@@ -1349,12 +1333,10 @@ instance.web.View = instance.web.Widget.extend({
do_search: function(view) {
},
on_sidebar_import: function() {
- var import_view = new instance.web.DataImport(this, this.dataset);
- import_view.start();
+ new instance.web.DataImport(this, this.dataset).open();
},
on_sidebar_export: function() {
- var export_view = new instance.web.DataExport(this, this.dataset);
- export_view.start();
+ new instance.web.DataExport(this, this.dataset).open();
},
on_sidebar_translate: function() {
return this.do_action({
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 75c9904dbf7..8e6f7ffc3cb 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -121,25 +121,25 @@
+
-
-