* @returns {$.Deferred} switching end signal
*/
on_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'];
if (options.created && current_view === 'form' && previous_view === 'list') {
var groupby = results.group_by.length
? results.group_by
: action_context.group_by;
+ if (_.isString(groupby)) {
+ groupby = [groupby];
+ }
controller.do_search(results.domain, results.context, groupby || []);
});
},
var $logs_list = $logs.find('ul').empty();
$logs.toggleClass('oe-has-more', log_records.length > cutoff);
_(log_records.reverse()).each(function (record) {
+ var context = {};
+ if (record.context) {
+ try { context = py.eval(record.context).toJSON(); }
+ catch (e) { /* TODO: what do I do now? */ }
+ }
$(_.str.sprintf('<li><a href="#">%s</a></li>', record.name))
.appendTo($logs_list)
- .delegate('a', 'click', function (e) {
+ .delegate('a', 'click', function () {
self.do_action({
type: 'ir.actions.act_window',
res_model: record.res_model,
res_id: record.res_id,
// TODO: need to have an evaluated context here somehow
- //context: record.context,
- views: [[false, 'form']]
+ context: context,
+ views: [[context.view_id || false, 'form']]
});
return false;
});
}, {
label: _t("Export"),
callback: view.on_sidebar_export
- }, {
- label: _t("View Log"),
- callback: view.on_sidebar_view_log,
- classname: 'oe_hide oe_sidebar_view_log'
}
]);
},
}
return $section;
},
-
+ /**
+ * For each item added to the section:
+ *
+ * ``label``
+ * will be used as the item's name in the sidebar
+ *
+ * ``action``
+ * descriptor for the action which will be executed, ``action`` and
+ * ``callback`` should be exclusive
+ *
+ * ``callback``
+ * function to call when the item is clicked in the sidebar, called
+ * with the item descriptor as its first argument (so information
+ * can be stored as additional keys on the object passed to
+ * ``add_items``)
+ *
+ * ``classname`` (optional)
+ * ``@class`` set on the sidebar serialization of the item
+ *
+ * ``title`` (optional)
+ * will be set as the item's ``@title`` (tooltip)
+ *
+ * @param {String} section_code
+ * @param {Array<{label, action | callback[, classname][, title]}>} items
+ */
add_items: function(section_code, items) {
- // An item is a dictonary : {
- // label: label to be displayed for the link,
- // action: action to be launch when the link is clicked,
- // callback: a function to be executed when the link is clicked,
- // classname: optional dom class name for the line,
- // title: optional title for the link
- // }
- // Note: The item should have one action or/and a callback
- //
-
var self = this,
$section = this.add_section(_.str.titleize(section_code.replace('_', ' ')), section_code),
section_id = $section.attr('id');
// TODO fme: should add the language to fields_view_get because between the fields view get
// and the moment the user opens the translation dialog, the user language could have been changed
this.view_language = view.session.user_context.lang;
- this['on_button' + _t("Save")] = this.on_button_Save;
- this['on_button' + _t("Close")] = this.on_button_Close;
+ this['on_button_' + _t("Save")] = this.on_btn_save;
+ this['on_button_' + _t("Close")] = this.on_btn_close;
this._super(view, {
width: '80%',
height: '80%'
}
});
},
- on_button_Save: function() {
+ on_btn_save: function() {
var trads = {},
- self = this;
+ self = this,
+ trads_mutex = new $.Mutex();
self.$fields_form.find('.oe_trad_field.touched').each(function() {
var field = $(this).attr('name').split('-');
if (!trads[field[0]]) {
_.each(data, function(value, field) {
self.view.fields[field].set_value(value);
});
- } else {
- self.view.dataset.write(self.view.datarecord.id, data, { 'lang': code });
}
+ trads_mutex.exec(function() {
+ return self.view.dataset.write(self.view.datarecord.id, data, { context : { 'lang': code } });
+ });
});
this.close();
},
- on_button_Close: function() {
+ on_btn_close: function() {
this.close();
}
});
view_mode : "list"
});
},
- on_sidebar_view_log: function() {
- },
sidebar_context: function () {
return $.when();
},