merge from trunk

bzr revid: mit@openerp.com-20120830112713-9wh0qe2wevd3ljmu
This commit is contained in:
Minh Tran 2012-08-30 13:27:13 +02:00
commit c9635ff6b3
10 changed files with 315 additions and 76 deletions

View File

@ -12,6 +12,62 @@ This module provides the core of the OpenERP Web Client.
'auto_install': True,
'post_load': 'wsgi_postload',
'js' : [
"static/lib/datejs/globalization/en-US.js",
"static/lib/datejs/core.js",
"static/lib/datejs/parser.js",
"static/lib/datejs/sugarpak.js",
"static/lib/datejs/extras.js",
"static/lib/jquery/jquery-1.7.2.js",
"static/lib/jquery.MD5/jquery.md5.js",
"static/lib/jquery.form/jquery.form.js",
"static/lib/jquery.validate/jquery.validate.js",
"static/lib/jquery.ba-bbq/jquery.ba-bbq.js",
"static/lib/spinjs/spin.js",
"static/lib/jquery.blockUI/jquery.blockUI.js",
"static/lib/jquery.ui/js/jquery-ui-1.8.17.custom.min.js",
"static/lib/jquery.ui.timepicker/js/jquery-ui-timepicker-addon.js",
"static/lib/jquery.ui.notify/js/jquery.notify.js",
"static/lib/jquery.deferred-queue/jquery.deferred-queue.js",
"static/lib/jquery.scrollTo/jquery.scrollTo-min.js",
"static/lib/jquery.tipsy/jquery.tipsy.js",
"static/lib/jquery.textext/jquery.textext.js",
"static/lib/jquery.timeago/jquery.timeago.js",
"static/lib/qweb/qweb2.js",
"static/lib/underscore/underscore.js",
"static/lib/underscore/underscore.string.js",
"static/lib/backbone/backbone.js",
"static/lib/cleditor/jquery.cleditor.js",
"static/lib/py.js/lib/py.js",
"static/lib/jquery.autosize/jquery.autosize.js",
"static/src/js/boot.js",
"static/src/js/corelib.js",
"static/src/js/coresetup.js",
"static/src/js/dates.js",
"static/src/js/formats.js",
"static/src/js/chrome.js",
"static/src/js/views.js",
"static/src/js/data.js",
"static/src/js/data_export.js",
"static/src/js/data_import.js",
"static/src/js/search.js",
"static/src/js/view_form.js",
"static/src/js/view_list.js",
"static/src/js/view_list_editable.js",
"static/src/js/view_tree.js",
],
'css' : [
"static/lib/jquery.ui.bootstrap/css/custom-theme/jquery-ui-1.8.16.custom.css",
"static/lib/jquery.ui.timepicker/css/jquery-ui-timepicker-addon.css",
"static/lib/jquery.ui.notify/css/ui.notify.css",
"static/lib/jquery.tipsy/tipsy.css",
"static/lib/jquery.textext/jquery.textext.css",
"static/src/css/base.css",
"static/src/css/data_export.css",
"static/src/css/data_import.css",
"static/lib/cleditor/jquery.cleditor.css",
],
'qweb' : [
"static/src/xml/*.xml",
'static/lib/datejs/globalization/en-US.js',
'static/lib/datejs/core.js',
'static/lib/datejs/parser.js',

View File

@ -0,0 +1,160 @@
// Autosize 1.10 - jQuery plugin for textareas
// (c) 2012 Jack Moore - jacklmoore.com
// license: www.opensource.org/licenses/mit-license.php
(function ($) {
var
hidden = 'hidden',
borderBox = 'border-box',
lineHeight = 'lineHeight',
copy = '<textarea tabindex="-1" style="position:absolute; top:-9999px; left:-9999px; right:auto; bottom:auto; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden">',
// line-height is omitted because IE7/IE8 doesn't return the correct value.
copyStyle = [
'fontFamily',
'fontSize',
'fontWeight',
'fontStyle',
'letterSpacing',
'textTransform',
'wordSpacing',
'textIndent'
],
oninput = 'oninput',
onpropertychange = 'onpropertychange',
test = $(copy)[0];
// For testing support in old FireFox
test.setAttribute(oninput, "return");
if ($.isFunction(test[oninput]) || onpropertychange in test) {
// test that line-height can be accurately copied to avoid
// incorrect value reporting in old IE and old Opera
$(test).css(lineHeight, '99px');
if ($(test).css(lineHeight) === '99px') {
copyStyle.push(lineHeight);
}
$.fn.autosize = function (className) {
return this.each(function () {
var
ta = this,
$ta = $(ta),
mirror,
minHeight = $ta.height(),
maxHeight = parseInt($ta.css('maxHeight'), 10),
active,
i = copyStyle.length,
resize,
boxOffset = 0;
if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox){
boxOffset = $ta.outerHeight() - $ta.height();
}
if ($ta.data('mirror') || $ta.data('ismirror')) {
// if autosize has already been applied, exit.
// if autosize is being applied to a mirror element, exit.
return;
} else {
mirror = $(copy).data('ismirror', true).addClass(className || 'autosizejs')[0];
resize = $ta.css('resize') === 'none' ? 'none' : 'horizontal';
$ta.data('mirror', $(mirror)).css({
overflow: hidden,
overflowY: hidden,
wordWrap: 'break-word',
resize: resize
});
}
// Opera returns '-1px' when max-height is set to 'none'.
maxHeight = maxHeight && maxHeight > 0 ? maxHeight : 9e4;
// Using mainly bare JS in this function because it is going
// to fire very often while typing, and needs to very efficient.
function adjust() {
var height, overflow;
// the active flag keeps IE from tripping all over itself. Otherwise
// actions in the adjust function will cause IE to call adjust again.
if (!active) {
active = true;
mirror.value = ta.value;
mirror.style.overflowY = ta.style.overflowY;
// Update the width in case the original textarea width has changed
mirror.style.width = $ta.css('width');
// Needed for IE to reliably return the correct scrollHeight
mirror.scrollTop = 0;
// Set a very high value for scrollTop to be sure the
// mirror is scrolled all the way to the bottom.
mirror.scrollTop = 9e4;
height = mirror.scrollTop;
overflow = hidden;
if (height > maxHeight) {
height = maxHeight;
overflow = 'scroll';
} else if (height < minHeight) {
height = minHeight;
}
ta.style.overflowY = overflow;
ta.style.height = height + boxOffset + 'px';
// This small timeout gives IE a chance to draw it's scrollbar
// before adjust can be run again (prevents an infinite loop).
setTimeout(function () {
active = false;
}, 1);
}
}
// mirror is a duplicate textarea located off-screen that
// is automatically updated to contain the same text as the
// original textarea. mirror always has a height of 0.
// This gives a cross-browser supported way getting the actual
// height of the text, through the scrollTop property.
while (i--) {
mirror.style[copyStyle[i]] = $ta.css(copyStyle[i]);
}
$('body').append(mirror);
if (onpropertychange in ta) {
if (oninput in ta) {
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those occassions. There is no way that I
// know of to detect something like 'cut' in IE9.
ta[oninput] = ta.onkeyup = adjust;
} else {
// IE7 / IE8
ta[onpropertychange] = adjust;
}
} else {
// Modern Browsers
ta[oninput] = adjust;
}
$(window).resize(adjust);
// Allow for manual triggering if needed.
$ta.bind('autosize', adjust);
// Call adjust in case the textarea already contains text.
adjust();
});
};
} else {
// Makes no changes for older browsers (FireFox3- and Safari4-)
$.fn.autosize = function () {
return this;
};
}
}(jQuery));

View File

@ -69,6 +69,7 @@
display: none !important;
}
}
.openerp.openerp_webclient_container {
height: 100%;
position: relative;
@ -84,7 +85,7 @@
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
/* http://www.quirksmode.org/dom/inputfile.html
* http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image
*/
*/ */
}
.openerp :-moz-placeholder {
color: #afafb6 !important;
@ -1949,8 +1950,10 @@
margin: 0 auto;
padding: 16px 0 48px;
}
.openerp .oe_form div.oe_form_configuration div.oe_horizontal_separator {
margin: 12px 0 8px 0;
.openerp .oe_form .oe_grey {
color: #aaaaaa;
max-width: 650px;
margin: 0 0 10px 0;
}
.openerp .oe_form div.oe_form_configuration p {
color: #aaaaaa;
@ -2001,7 +2004,6 @@
padding-left: 24px;
margin: 0;
position: relative;
z-index: 10;
}
.openerp ul.oe_form_steps li .arrow, .openerp ul.oe_form_steps_clickable li .arrow {
width: 17px;
@ -2012,7 +2014,6 @@
}
.openerp ul.oe_form_steps li .arrow span, .openerp ul.oe_form_steps_clickable li .arrow span {
position: relative;
z-index: 11;
width: 24px;
height: 24px;
display: inline-block;
@ -2187,7 +2188,7 @@
.openerp .oe_horizontal_separator {
font-weight: bold;
font-size: 20px;
margin: 8px 0px 8px 0px;
margin: 15px 0px 10px 0px;
color: #7c7bad;
}
.openerp .oe_horizontal_separator:empty {
@ -2401,6 +2402,13 @@
float: right;
padding-left: 2px;
}
.openerp.ui-autocomplete li.oe_m2o_dropdown_option a {
font-style: italic;
padding-left: 2em;
}
.openerp.ui-autocomplete li:not(.oe_m2o_dropdown_option) + li.oe_m2o_dropdown_option {
margin-top: 10px;
}
.openerp .oe_form .oe_form_field_one2many > .oe_view_manager .oe_list_pager_single_page {
display: none;
}

View File

@ -1516,9 +1516,11 @@ $sheet-max-width: 860px
max-width: $sheet-max-width
margin: 0 auto
padding: 16px 0 48px
.oe_grey
color: #aaa
max-width: 650px
margin: 0 0 10px 0
div.oe_form_configuration
div.oe_horizontal_separator
margin: 12px 0 8px 0
p
color: #aaa
max-width: 650px
@ -1554,7 +1556,6 @@ $sheet-max-width: 860px
padding-left: 24px
margin: 0
position: relative
z-index: 10
.arrow
width: 17px
display: inline-block
@ -1563,7 +1564,6 @@ $sheet-max-width: 860px
margin-left: -5px
span
position: relative
z-index: 11
width: 24px
height: 24px
display: inline-block
@ -1679,7 +1679,7 @@ $sheet-max-width: 860px
.oe_horizontal_separator
font-weight: bold
font-size: 20px
margin: 8px 0px 8px 0px
margin: 15px 0px 10px 0px
color: $section-title-color
.oe_horizontal_separator:empty
height: 5px
@ -1853,6 +1853,12 @@ $sheet-max-width: 860px
line-height: 14px
float: right
padding-left: 2px
&.ui-autocomplete
li.oe_m2o_dropdown_option a
font-style: italic
padding-left: 2em
li:not(.oe_m2o_dropdown_option) + li.oe_m2o_dropdown_option
margin-top: 10px
// }}}
// FormView.one2many {{{
.oe_form .oe_form_field_one2many > .oe_view_manager

View File

@ -689,7 +689,7 @@ 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.do_save().then(function(result) {
self.to_view_mode();
});
},
@ -759,10 +759,11 @@ 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 {Function} [success] callback on save success
* @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new record, should that record be inserted at the start of the dataset (by default, records are added at the end)
* @param {Boolean} [prepend_on_create=false] if ``do_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(success, prepend_on_create) {
do_save: function(prepend_on_create) {
var self = this;
return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() {
try {
@ -797,21 +798,21 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
self.set({'display_invalid_fields': false});
var save_deferral;
if (!self.datarecord.id) {
// console.log("FormView(", self, ") : About to create", values);
// Creation save
save_deferral = self.dataset.create(values).pipe(function(r) {
return self.on_created(r, undefined, prepend_on_create);
return self.on_created(r, prepend_on_create);
}, null);
} else if (_.isEmpty(values) && ! self.force_dirty) {
// console.log("FormView(", self, ") : Nothing to save");
// Not dirty, noop save
save_deferral = $.Deferred().resolve({}).promise();
} else {
self.force_dirty = false;
// console.log("FormView(", self, ") : About to save", values);
// Write save
save_deferral = self.dataset.write(self.datarecord.id, values, {}).pipe(function(r) {
return self.on_saved(r);
}, null);
}
return save_deferral.then(success);
return save_deferral;
}
} catch (e) {
console.error(e);
@ -830,14 +831,19 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
warnings.push('</ul>');
this.do_warn("The following fields are invalid :", warnings.join(''));
},
on_saved: function(r, success) {
/**
* Reload the form after saving
*
* @param {Object} r result of the write function.
*/
on_saved: function(r) {
if (!r.result) {
// should not happen in the server, but may happen for internal purpose
return $.Deferred().reject();
} else {
return $.when(this.reload()).pipe(function () {
return r; })
.then(success);
return r;
});
}
},
/**
@ -850,10 +856,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
* * Updates the pager and sidebar displays
*
* @param {Object} r
* @param {Function} success callback to execute after having updated the dataset
* @param {Boolean} [prepend_on_create=false] adds the newly created record at the beginning of the dataset instead of the end
* @param {Boolean} [prepend_on_create=false] adds the newly created record
* at the beginning of the dataset instead of the end
*/
on_created: function(r, success, prepend_on_create) {
on_created: function(r, prepend_on_create) {
if (!r.result) {
// should not happen in the server, but may happen for internal purpose
return $.Deferred().reject();
@ -872,8 +878,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}
//openerp.log("The record has been created with id #" + this.datarecord.id);
return $.when(this.reload()).pipe(function () {
return _.extend(r, {created: true}); })
.then(success);
return _.extend(r, {created: true});
});
}
},
on_action: function (action) {
@ -2318,6 +2324,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
template: 'FieldText',
initialize_content: function() {
this.$textarea = this.$el.find('textarea');
this.default_height = this.$textarea.css('height');
if (!this.get("effective_readonly")) {
this.$textarea.change(_.bind(function() {
this.set({'value': instance.web.parse_value(this.$textarea.val(), this)});
@ -2339,9 +2346,8 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
render_value: function() {
var show_value = instance.web.format_value(this.get('value'), this, '');
this.$textarea.val(show_value);
if (show_value && this.view.options.resize_textareas) {
this.do_resize(this.view.options.resize_textareas);
}
this.$textarea.autosize();
this.$textarea.css('height', parseInt(this.default_height)+"px");
},
is_syntax_valid: function() {
if (!this.get("effective_readonly")) {
@ -2360,26 +2366,6 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
focus: function($el) {
this.$textarea.focus();
},
do_resize: function(max_height) {
max_height = parseInt(max_height, 10);
var $input = this.$textarea,
$div = $('<div style="position: absolute; z-index: 1000; top: 0"/>').width($input.width()),
new_height;
$div.text($input.val());
_.each('font-family,font-size,white-space'.split(','), function(style) {
$div.css(style, $input.css(style));
});
$div.appendTo($('body'));
new_height = $div.height();
if (new_height < 90) {
new_height = 90;
}
if (!isNaN(max_height) && new_height > max_height) {
new_height = max_height;
}
$div.remove();
$input.height(new_height);
},
});
/**
@ -2404,7 +2390,7 @@ instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instanc
self._updating_editor = false;
this.$textarea = this.$el.find('textarea');
var width = ((this.node.attrs || {}).editor_width || 468);
var height = ((this.node.attrs || {}).editor_height || 100);
var height = ((this.node.attrs || {}).editor_height || 250);
this.$textarea.cleditor({
width: width, // width not including margins, borders or padding
height: height, // height not including margins, borders or padding
@ -2557,7 +2543,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
}
});
// jquery autocomplete tweak to allow html
// jquery autocomplete tweak to allow html and classnames
(function() {
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
@ -2584,7 +2570,8 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) )
.appendTo( ul );
.appendTo( ul )
.addClass(item.classname);
}
});
})();
@ -2624,25 +2611,36 @@ instance.web.form.CompletionFieldMixin = {
// search more... if more results that max
if (values.length > self.limit) {
values = values.slice(0, self.limit);
values.push({label: _t("<em>   Search More...</em>"), action: function() {
dataset.name_search(search_val, self.build_domain(), 'ilike'
, false, function(data) {
self._search_create_popup("search", data);
});
}});
values.push({
label: _t("Search More..."),
action: function() {
dataset.name_search(search_val, self.build_domain(), 'ilike', false, function(data) {
self._search_create_popup("search", data);
});
},
classname: 'oe_m2o_dropdown_option'
});
}
// quick create
var raw_result = _(data.result).map(function(x) {return x[1];});
if (search_val.length > 0 && !_.include(raw_result, search_val)) {
values.push({label: _.str.sprintf(_t('<em>   Create "<strong>%s</strong>"</em>'),
$('<span />').text(search_val).html()), action: function() {
self._quick_create(search_val);
}});
values.push({
label: _.str.sprintf(_t('Create "<strong>%s</strong>"'),
$('<span />').text(search_val).html()),
action: function() {
self._quick_create(search_val);
},
classname: 'oe_m2o_dropdown_option'
});
}
// create...
values.push({label: _t("<em>   Create and Edit...</em>"), action: function() {
self._search_create_popup("form", undefined, self._create_context(search_val));
}});
values.push({
label: _t("Create and Edit..."),
action: function() {
self._search_create_popup("form", undefined, self._create_context(search_val));
},
classname: 'oe_m2o_dropdown_option'
});
return values;
});

View File

@ -716,7 +716,7 @@ openerp.web.list_editable = function (instance) {
save: function () {
var self = this;
return this.form
.do_save(null, this.delegate.prepends_on_create())
.do_save(this.delegate.prepends_on_create())
.pipe(function (result) {
var created = result.created && !self.record.id;
if (created) {

View File

@ -874,7 +874,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
var view = this.getParent();
this.sections = [
{ 'name' : 'print', 'label' : _t('Print'), },
{ 'name' : 'files', 'label' : _t('Attachment'), },
{ 'name' : 'files', 'label' : _t('Attachment(s)'), },
{ 'name' : 'other', 'label' : _t('More'), }
];
this.items = {
@ -1077,14 +1077,13 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({
start: function() {
var self = this;
this._super();
$.when(this.languages_loaded).then(function() {
return $.when(this.languages_loaded).then(function() {
self.$el.html(instance.web.qweb.render('TranslateDialog', { widget: self }));
self.$fields_form = self.$el.find('.oe_translation_form');
self.$fields_form.find('.oe_trad_field').change(function() {
$(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value')));
});
});
return this;
},
on_languages_loaded: function(langs) {
this.languages = langs;
@ -1136,9 +1135,9 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({
});
},
on_btn_save: function() {
var trads = {},
self = this,
trads_mutex = new $.Mutex();
var trads = {};
var self = this;
var trads_mutex = new $.Mutex();
self.$fields_form.find('.oe_trad_field.touched').each(function() {
var field = $(this).attr('name').split('-');
if (!trads[field[0]]) {
@ -1157,6 +1156,7 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({
});
});
this.close();
return trads_mutex;
},
on_btn_close: function() {
this.close();

View File

@ -540,6 +540,7 @@
<t t-foreach="widget.sections" t-as="section">
<div class="oe_form_dropdown_section">
<button class="oe_dropdown_toggle oe_dropdown_arrow">
<t t-if="section.name == 'files'" t-raw="widget.items[section.name].length || ''"/>
<t t-esc="section.label"/>
</button>
<ul class="oe_dropdown_menu">

View File

@ -313,7 +313,6 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
do_create_event_with_formdialog: function(event_id, event_obj) {
var self = this;
$.when(! self.form_dialog.dialog_inited ? self.form_dialog.init_dialog() : true).then(function() {
debugger;
if (!event_obj) {
event_obj = scheduler.getEvent(event_id);
}

View File

@ -121,7 +121,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
case 'button':
case 'a':
var type = node.attrs.type || '';
if (_.indexOf('action,object,edit,delete'.split(','), type) !== -1) {
if (_.indexOf('action,object,edit,open,delete'.split(','), type) !== -1) {
_.each(node.attrs, function(v, k) {
if (_.indexOf('icon,type,name,args,string,context,states,kanban_states'.split(','), k) != -1) {
node.attrs['data-' + k] = v;
@ -286,6 +286,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
start: function(event, ui) {
self.currently_dragging.index = ui.item.index();
self.currently_dragging.group = ui.item.parents('.oe_kanban_column:first').data('widget');
ui.item.find('*').on('click.prevent', function(ev) {
return false;
});
},
stop: function(event, ui) {
var record = ui.item.data('widget');
@ -296,6 +299,11 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
if (!(old_group.title === new_group.title && old_group.value === new_group.value && old_index == new_index)) {
self.on_record_moved(record, old_group, old_index, new_group, new_index);
}
setTimeout(function() {
// A bit hacky but could not find a better solution for Firefox (problem not present in chrome)
// http://stackoverflow.com/questions/274843/preventing-javascript-click-event-with-scriptaculous-drag-and-drop
ui.item.find('*').off('click.prevent');
}, 0);
},
scroll: false
});
@ -819,6 +827,9 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
do_action_edit: function($action) {
this.view.open_record(this.id, true);
},
do_action_open: function($action) {
this.view.open_record(this.id);
},
do_action_object: function ($action) {
var button_attrs = $action.data();
this.view.do_execute_action(button_attrs, this.view.dataset, this.id, this.do_reload);