[MERGE] forward port of branch saas-2 up to revid 3887 chs@openerp.com-20131122172422-tsd8wzqkbqknrw1w

bzr revid: chs@openerp.com-20131125160506-30uia4pdwzpp54gj
This commit is contained in:
Christophe Simonis
2013-11-25 17:05:06 +01:00
16 changed files with 997 additions and 559 deletions
+6 -10
View File
@@ -90,16 +90,12 @@ db_list = http.db_list
db_monodb = http.db_monodb
def redirect_with_hash(url, code=303):
redirect_code = "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
if request.httprequest.user_agent.browser == 'msie':
try:
version = float(request.httprequest.user_agent.version)
if version < 10:
return redirect_code
except Exception:
pass
elif request.httprequest.user_agent.browser == 'safari':
return redirect_code
if request.httprequest.user_agent.browser in ('msie', 'safari'):
# Most IE and Safari versions decided not to preserve location.hash upon
# redirect. And even if IE10 pretends to support it, it still fails
# inexplicably in case of multiple redirects (and we do have some).
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
return werkzeug.utils.redirect(url, code)
def module_topological_sort(modules):
@@ -1,12 +1,11 @@
// Underscore.string
// (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
// Underscore.strings is freely distributable under the terms of the MIT license.
// Documentation: https://github.com/epeli/underscore.string
// Some code is borrowed from MooTools and Alexandru Marasteanu.
// Underscore.string
// (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
// Underscore.string is freely distributable under the terms of the MIT license.
// Documentation: https://github.com/epeli/underscore.string
// Some code is borrowed from MooTools and Alexandru Marasteanu.
// Version '2.3.2'
// Version 2.2.0rc
(function(root){
!function(root, String){
'use strict';
// Defining helper functions.
@@ -16,36 +15,51 @@
var nativeTrimLeft = String.prototype.trimLeft;
var parseNumber = function(source) { return source * 1 || 0; };
var strRepeat = function(str, qty, separator){
// ~~var — is the fastest available way to convert anything to Integer in javascript.
// We'll use it extensively in this lib.
str += ''; qty = ~~qty;
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
return repeat.join(separator == null ? '' : separator);
};
var slice = function(a){
return Array.prototype.slice.call(a);
};
var defaultToWhiteSpace = function(characters){
if (characters != null) {
return '[' + _s.escapeRegExp(''+characters) + ']';
var strRepeat = function(str, qty){
if (qty < 1) return '';
var result = '';
while (qty > 0) {
if (qty & 1) result += str;
qty >>= 1, str += str;
}
return '\\s';
return result;
};
var slice = [].slice;
var defaultToWhiteSpace = function(characters) {
if (characters == null)
return '\\s';
else if (characters.source)
return characters.source;
else
return '[' + _s.escapeRegExp(characters) + ']';
};
// Helper for toBoolean
function boolMatch(s, matchers) {
var i, matcher, down = s.toLowerCase();
matchers = [].concat(matchers);
for (i = 0; i < matchers.length; i += 1) {
matcher = matchers[i];
if (!matcher) continue;
if (matcher.test && matcher.test(s)) return true;
if (matcher.toLowerCase() === down) return true;
}
}
var escapeChars = {
lt: '<',
gt: '>',
quot: '"',
apos: "'",
amp: '&'
amp: '&',
apos: "'"
};
var reversedEscapeChars = {};
for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
for(var key in escapeChars) reversedEscapeChars[escapeChars[key]] = key;
reversedEscapeChars["'"] = '#39';
// sprintf() for JavaScript 0.7-beta1
// http://www.diveintojavascript.com/projects/javascript-sprintf
@@ -175,28 +189,28 @@
var _s = {
VERSION: '2.2.0rc',
VERSION: '2.3.0',
isBlank: function(str){
if (str == null) str = '';
return (/^\s*$/).test(str);
},
stripTags: function(str){
return (''+str).replace(/<\/?[^>]+>/g, '');
if (str == null) return '';
return String(str).replace(/<\/?[^>]+>/g, '');
},
capitalize : function(str) {
str += '';
return str.charAt(0).toUpperCase() + str.substring(1);
capitalize : function(str){
str = str == null ? '' : String(str);
return str.charAt(0).toUpperCase() + str.slice(1);
},
chop: function(str, step){
str = str+'';
step = ~~step || str.length;
var arr = [];
for (var i = 0; i < str.length; i += step)
arr.push(str.slice(i,i + step));
return arr;
if (str == null) return [];
str = String(str);
step = ~~step;
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
},
clean: function(str){
@@ -204,22 +218,47 @@
},
count: function(str, substr){
str += ''; substr += '';
return str.split(substr).length - 1;
if (str == null || substr == null) return 0;
str = String(str);
substr = String(substr);
var count = 0,
pos = 0,
length = substr.length;
while (true) {
pos = str.indexOf(substr, pos);
if (pos === -1) break;
count++;
pos += length;
}
return count;
},
chars: function(str) {
return (''+str).split('');
if (str == null) return [];
return String(str).split('');
},
swapCase: function(str) {
if (str == null) return '';
return String(str).replace(/\S/g, function(c){
return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase();
});
},
escapeHTML: function(str) {
return (''+str).replace(/[&<>"']/g, function(match){ return '&' + reversedEscapeChars[match] + ';'; });
if (str == null) return '';
return String(str).replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; });
},
unescapeHTML: function(str) {
return (''+str).replace(/\&([^;]+);/g, function(entity, entityCode){
if (str == null) return '';
return String(str).replace(/\&([^;]+);/g, function(entity, entityCode){
var match;
if (entityCode in escapeChars) {
return escapeChars[entityCode];
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
@@ -233,31 +272,8 @@
},
escapeRegExp: function(str){
// From MooTools core 1.2.4
return str.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
insert: function(str, i, substr){
var arr = _s.chars(str);
arr.splice(~~i, 0, ''+substr);
return arr.join('');
},
include: function(str, needle){
return !!~(''+str).indexOf(needle);
},
join: function() {
var args = slice(arguments);
return args.join(args.shift());
},
lines: function(str) {
return (''+str).split("\n");
},
reverse: function(str){
return _s.chars(str).reverse().join('');
if (str == null) return '';
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
},
splice: function(str, i, howmany, substr){
@@ -266,31 +282,62 @@
return arr.join('');
},
insert: function(str, i, substr){
return _s.splice(str, i, 0, substr);
},
include: function(str, needle){
if (needle === '') return true;
if (str == null) return false;
return String(str).indexOf(needle) !== -1;
},
join: function() {
var args = slice.call(arguments),
separator = args.shift();
if (separator == null) separator = '';
return args.join(separator);
},
lines: function(str) {
if (str == null) return [];
return String(str).split("\n");
},
reverse: function(str){
return _s.chars(str).reverse().join('');
},
startsWith: function(str, starts){
str += ''; starts += '';
return str.length >= starts.length && str.substring(0, starts.length) === starts;
if (starts === '') return true;
if (str == null || starts == null) return false;
str = String(str); starts = String(starts);
return str.length >= starts.length && str.slice(0, starts.length) === starts;
},
endsWith: function(str, ends){
str += ''; ends += '';
return str.length >= ends.length && str.substring(str.length - ends.length) === ends;
if (ends === '') return true;
if (str == null || ends == null) return false;
str = String(str); ends = String(ends);
return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
},
succ: function(str){
str += '';
var arr = _s.chars(str);
arr.splice(str.length-1, 1, String.fromCharCode(str.charCodeAt(str.length-1) + 1));
return arr.join('');
if (str == null) return '';
str = String(str);
return str.slice(0, -1) + String.fromCharCode(str.charCodeAt(str.length-1) + 1);
},
titleize: function(str){
return (''+str).replace(/\b./g, function(ch){ return ch.toUpperCase(); });
if (str == null) return '';
str = String(str).toLowerCase();
return str.replace(/(?:^|\s|-)\S/g, function(c){ return c.toUpperCase(); });
},
camelize: function(str){
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, chr){
return chr && chr.toUpperCase();
});
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, c){ return c ? c.toUpperCase() : ""; });
},
underscored: function(str){
@@ -298,45 +345,41 @@
},
dasherize: function(str){
return _s.trim(str).replace(/[_\s]+/g, '-').replace(/([A-Z])/g, '-$1').replace(/-+/g, '-').toLowerCase();
return _s.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
},
classify: function(str){
str += '';
return _s.titleize(str.replace(/_/g, ' ')).replace(/\s/g, '')
return _s.titleize(String(str).replace(/[\W_]/g, ' ')).replace(/\s/g, '');
},
humanize: function(str){
return _s.capitalize(this.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
return _s.capitalize(_s.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
},
trim: function(str, characters){
str += '';
if (!characters && nativeTrim) { return nativeTrim.call(str); }
if (str == null) return '';
if (!characters && nativeTrim) return nativeTrim.call(str);
characters = defaultToWhiteSpace(characters);
return str.replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
return String(str).replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
},
ltrim: function(str, characters){
str+='';
if (!characters && nativeTrimLeft) {
return nativeTrimLeft.call(str);
}
if (str == null) return '';
if (!characters && nativeTrimLeft) return nativeTrimLeft.call(str);
characters = defaultToWhiteSpace(characters);
return str.replace(new RegExp('^' + characters + '+'), '');
return String(str).replace(new RegExp('^' + characters + '+'), '');
},
rtrim: function(str, characters){
str+='';
if (!characters && nativeTrimRight) {
return nativeTrimRight.call(str);
}
if (str == null) return '';
if (!characters && nativeTrimRight) return nativeTrimRight.call(str);
characters = defaultToWhiteSpace(characters);
return str.replace(new RegExp(characters + '+$'), '');
return String(str).replace(new RegExp(characters + '+$'), '');
},
truncate: function(str, length, truncateStr){
str += ''; truncateStr = truncateStr || '...';
if (str == null) return '';
str = String(str); truncateStr = truncateStr || '...';
length = ~~length;
return str.length > length ? str.slice(0, length) + truncateStr : str;
},
@@ -344,57 +387,53 @@
/**
* _s.prune: a more elegant version of truncate
* prune extra chars, never leaving a half-chopped word.
* @author github.com/sergiokas
* @author github.com/rwz
*/
prune: function(str, length, pruneStr){
str += ''; length = ~~length;
pruneStr = pruneStr != null ? ''+pruneStr : '...';
var pruned, borderChar, template = str.replace(/\W/g, function(ch){
return (ch.toUpperCase() !== ch.toLowerCase()) ? 'A' : ' ';
});
borderChar = template.charAt(length);
pruned = template.slice(0, length);
// Check if we're in the middle of a word
if (borderChar && borderChar.match(/\S/))
pruned = pruned.replace(/\s\S+$/, '');
pruned = _s.rtrim(pruned);
return (pruned+pruneStr).length > str.length ? str : str.substring(0, pruned.length)+pruneStr;
if (str == null) return '';
str = String(str); length = ~~length;
pruneStr = pruneStr != null ? String(pruneStr) : '...';
if (str.length <= length) return str;
var tmpl = function(c){ return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; },
template = str.slice(0, length+1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
if (template.slice(template.length-2).match(/\w\w/))
template = template.replace(/\s*\S+$/, '');
else
template = _s.rtrim(template.slice(0, template.length-1));
return (template+pruneStr).length > str.length ? str : str.slice(0, template.length)+pruneStr;
},
words: function(str, delimiter) {
if (_s.isBlank(str)) return [];
return _s.trim(str, delimiter).split(delimiter || /\s+/);
},
pad: function(str, length, padStr, type) {
str += '';
str = str == null ? '' : String(str);
length = ~~length;
var padlen = 0;
length = ~~length;
if (!padStr) {
if (!padStr)
padStr = ' ';
} else if (padStr.length > 1) {
else if (padStr.length > 1)
padStr = padStr.charAt(0);
}
switch(type) {
case 'right':
padlen = (length - str.length);
padlen = length - str.length;
return str + strRepeat(padStr, padlen);
case 'both':
padlen = (length - str.length);
return strRepeat(padStr, Math.ceil(padlen/2)) +
str +
strRepeat(padStr, Math.floor(padlen/2));
padlen = length - str.length;
return strRepeat(padStr, Math.ceil(padlen/2)) + str
+ strRepeat(padStr, Math.floor(padlen/2));
default: // 'left'
padlen = (length - str.length);
padlen = length - str.length;
return strRepeat(padStr, padlen) + str;
}
},
@@ -419,76 +458,185 @@
},
toNumber: function(str, decimals) {
str += '';
var num = parseNumber(parseNumber(str).toFixed(~~decimals));
return num === 0 && !str.match(/^0+$/) ? Number.NaN : num;
if (!str) return 0;
str = _s.trim(str);
if (!str.match(/^-?\d+(?:\.\d+)?$/)) return NaN;
return parseNumber(parseNumber(str).toFixed(~~decimals));
},
numberFormat : function(number, dec, dsep, tsep) {
if (isNaN(number) || number == null) return '';
number = number.toFixed(~~dec);
tsep = typeof tsep == 'string' ? tsep : ',';
var parts = number.split('.'), fnums = parts[0],
decimals = parts[1] ? (dsep || '.') + parts[1] : '';
return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals;
},
strRight: function(str, sep){
str += ''; sep = sep != null ? ''+sep : sep;
if (str == null) return '';
str = String(str); sep = sep != null ? String(sep) : sep;
var pos = !sep ? -1 : str.indexOf(sep);
return ~pos ? str.slice(pos+sep.length, str.length) : str;
},
strRightBack: function(str, sep){
str += ''; sep = sep != null ? ''+sep : sep;
if (str == null) return '';
str = String(str); sep = sep != null ? String(sep) : sep;
var pos = !sep ? -1 : str.lastIndexOf(sep);
return ~pos ? str.slice(pos+sep.length, str.length) : str;
},
strLeft: function(str, sep){
str += ''; sep = sep != null ? ''+sep : sep;
if (str == null) return '';
str = String(str); sep = sep != null ? String(sep) : sep;
var pos = !sep ? -1 : str.indexOf(sep);
return ~pos ? str.slice(0, pos) : str;
},
strLeftBack: function(str, sep){
if (str == null) return '';
str += ''; sep = sep != null ? ''+sep : sep;
var pos = str.lastIndexOf(sep);
return ~pos ? str.slice(0, pos) : str;
},
toSentence: function(array, separator, lastSeparator) {
separator || (separator = ', ');
lastSeparator || (lastSeparator = ' and ');
var length = array.length, str = '';
toSentence: function(array, separator, lastSeparator, serial) {
separator = separator || ', ';
lastSeparator = lastSeparator || ' and ';
var a = array.slice(), lastMember = a.pop();
for (var i = 0; i < length; i++) {
str += array[i];
if (i === (length - 2)) { str += lastSeparator; }
else if (i < (length - 1)) { str += separator; }
}
if (array.length > 2 && serial) lastSeparator = _s.rtrim(separator) + lastSeparator;
return str;
return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember;
},
toSentenceSerial: function() {
var args = slice.call(arguments);
args[3] = true;
return _s.toSentence.apply(_s, args);
},
slugify: function(str) {
var from = "ąàáäâãćęèéëêìíïîłńòóöôõùúüûñçżź",
to = "aaaaaaceeeeeiiiilnooooouuuunczz",
if (str == null) return '';
var from = "ąàáäâãåæăćęèéëêìíïîłńòóöôõøśșțùúüûñçżź",
to = "aaaaaaaaaceeeeeiiiilnoooooosstuuuunczz",
regex = new RegExp(defaultToWhiteSpace(from), 'g');
str = (''+str).toLowerCase();
str = str.replace(regex, function(ch){
var index = from.indexOf(ch);
str = String(str).toLowerCase().replace(regex, function(c){
var index = from.indexOf(c);
return to.charAt(index) || '-';
});
return _s.trim(str.replace(/[^\w\s-]/g, '').replace(/[-\s]+/g, '-'), '-');
return _s.dasherize(str.replace(/[^\w\s-]/g, ''));
},
surround: function(str, wrapper) {
return [wrapper, str, wrapper].join('');
},
quote: function(str, quoteChar) {
return _s.surround(str, quoteChar || '"');
},
unquote: function(str, quoteChar) {
quoteChar = quoteChar || '"';
if (str[0] === quoteChar && str[str.length-1] === quoteChar)
return str.slice(1,str.length-1);
else return str;
},
exports: function() {
var result = {};
for (var prop in this) {
if (!this.hasOwnProperty(prop) || ~_s.words('include contains reverse').indexOf(prop)) continue;
if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse)$/)) continue;
result[prop] = this[prop];
}
return result;
},
repeat: strRepeat
repeat: function(str, qty, separator){
if (str == null) return '';
qty = ~~qty;
// using faster implementation if separator is not needed;
if (separator == null) return strRepeat(String(str), qty);
// this one is about 300x slower in Google Chrome
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
return repeat.join(separator);
},
naturalCmp: function(str1, str2){
if (str1 == str2) return 0;
if (!str1) return -1;
if (!str2) return 1;
var cmpRegex = /(\.\d+)|(\d+)|(\D+)/g,
tokens1 = String(str1).toLowerCase().match(cmpRegex),
tokens2 = String(str2).toLowerCase().match(cmpRegex),
count = Math.min(tokens1.length, tokens2.length);
for(var i = 0; i < count; i++) {
var a = tokens1[i], b = tokens2[i];
if (a !== b){
var num1 = parseInt(a, 10);
if (!isNaN(num1)){
var num2 = parseInt(b, 10);
if (!isNaN(num2) && num1 - num2)
return num1 - num2;
}
return a < b ? -1 : 1;
}
}
if (tokens1.length === tokens2.length)
return tokens1.length - tokens2.length;
return str1 < str2 ? -1 : 1;
},
levenshtein: function(str1, str2) {
if (str1 == null && str2 == null) return 0;
if (str1 == null) return String(str2).length;
if (str2 == null) return String(str1).length;
str1 = String(str1); str2 = String(str2);
var current = [], prev, value;
for (var i = 0; i <= str2.length; i++)
for (var j = 0; j <= str1.length; j++) {
if (i && j)
if (str1.charAt(j - 1) === str2.charAt(i - 1))
value = prev;
else
value = Math.min(current[j], current[j - 1], prev) + 1;
else
value = i + j;
prev = current[j];
current[j] = value;
}
return current.pop();
},
toBoolean: function(str, trueValues, falseValues) {
if (typeof str === "number") str = "" + str;
if (typeof str !== "string") return !!str;
str = _s.trim(str);
if (boolMatch(str, trueValues || ["true", "1"])) return true;
if (boolMatch(str, falseValues || ["false", "0"])) return false;
}
};
// Aliases
@@ -500,26 +648,26 @@
_s.rjust = _s.lpad;
_s.ljust = _s.rpad;
_s.contains = _s.include;
_s.q = _s.quote;
_s.toBool = _s.toBoolean;
// Exporting
// CommonJS module is defined
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
// Export module
if (typeof module !== 'undefined' && module.exports)
module.exports = _s;
}
exports._s = _s;
} else if (typeof define === 'function' && define.amd) {
// Register as a named module with AMD.
define('underscore.string', function() {
return _s;
});
} else {
// Integrate with Underscore.js if defined
// or create our own underscore object.
root._ = root._ || {};
root._.string = root._.str = _s;
exports._s = _s;
}
}(this || window));
// Register as a named module with AMD.
if (typeof define === 'function' && define.amd)
define('underscore.string', [], function(){ return _s; });
// Integrate with Underscore.js if defined
// or create our own underscore object.
root._ = root._ || {};
root._.string = root._.str = _s;
}(this, String);
File diff suppressed because it is too large Load Diff
+1 -4
View File
@@ -739,9 +739,6 @@
display: block;
color: #4c4c4c;
text-decoration: none;
width: 200px;
text-overflow: ellipsis;
overflow: hidden;
}
.openerp .oe_dropdown_menu > li > a:hover {
text-decoration: none;
@@ -3402,7 +3399,7 @@ div.ui-widget-overlay {
background: transparent;
}
.openerp_ie ul.oe_form_status li > .arrow span, .openerp_ie ul.oe_form_status_clickable li > .arrow span {
background-color: #fefefe !important;
background-color: #eeeeee !important;
}
.openerp_ie ul.oe_form_status li.oe_active > .label, .openerp_ie ul.oe_form_status_clickable li.oe_active > .label {
border-bottom: 1px solid #729fcf;
+1 -4
View File
@@ -630,9 +630,6 @@ $sheet-padding: 16px
display: block
color: #4c4c4c
text-decoration: none
width: 200px
text-overflow: ellipsis
overflow: hidden
&:hover
text-decoration: none
.oe_dropdown_arrow:after
@@ -2684,7 +2681,7 @@ div.ui-widget-overlay
background: transparent
> .arrow
span
background-color: #fefefe !important
background-color: #eeeeee !important
li.oe_active
> .label
border-bottom: 1px solid #729fcf
+4
View File
@@ -561,6 +561,10 @@ instance.web.TranslationDataBase.include({
});
/** Custom jQuery plugins */
if(navigator.appVersion.indexOf("MSIE") !== -1) {
$.browser = $.browser || {};
$.browser.msie = 1;
}
$.fn.getAttributes = function() {
var o = {};
if (this.length) {
+19 -8
View File
@@ -743,7 +743,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({
});
},
get_domain: function (other_domain) {
this._model.domain(other_domain);
return this._model.domain(other_domain);
},
alter_ids: function (ids) {
this._super(ids);
@@ -780,6 +780,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
this._super.apply(this, arguments);
this.reset_ids([]);
this.last_default_get = {};
this.running_reads = [];
},
default_get: function(fields, options) {
var self = this;
@@ -846,6 +847,9 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
this.to_write = [];
this.cache = [];
this.delete_all = false;
_.each(_.clone(this.running_reads), function(el) {
el.reject();
});
},
read_ids: function (ids, fields, options) {
var self = this;
@@ -861,7 +865,6 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
to_get.push(id);
}
});
var completion = $.Deferred();
var return_records = function() {
var records = _.map(ids, function(id) {
return _.extend({}, _.detect(self.cache, function(c) {return c.id === id;}).values, {"id": id});
@@ -896,10 +899,20 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
}, 0);
});
}
completion.resolve(records);
return $.when(records);
};
if(to_get.length > 0) {
var rpc_promise = this._super(to_get, fields, options).done(function(records) {
var def = $.Deferred();
self.running_reads.push(def);
def.always(function() {
self.running_reads = _.without(self.running_reads, def);
});
this._super(to_get, fields, options).then(function() {
def.resolve.apply(def, arguments);
}, function() {
def.reject.apply(def, arguments);
});
return def.then(function(records) {
_.each(records, function(record, index) {
var id = to_get[index];
var cached = _.detect(self.cache, function(x) {return x.id === id;});
@@ -910,13 +923,11 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
cached.values = _.defaults(_.clone(cached.values), record);
}
});
return_records();
return return_records();
});
$.when(rpc_promise).fail(function() {completion.reject();});
} else {
return_records();
return return_records();
}
return completion.promise();
},
/**
* Invalidates caching of a record in the dataset to ensure the next read
+15 -12
View File
@@ -1155,7 +1155,8 @@ openerp.Model = openerp.Class.extend({
kwargs = args;
args = [];
}
return this.session().rpc('/web/dataset/call_kw', {
var call_kw = _.str.sprintf('/web/dataset/call_kw/%s/%s', this.name, method);
return this.session().rpc(call_kw, {
model: this.name,
method: method,
args: args,
@@ -1236,15 +1237,14 @@ openerp.TranslationDataBase = openerp.Class.extend(/** @lends instance.Translati
openerp._t = new openerp.TranslationDataBase().build_translation_function();
openerp.get_cookie = function(c_name) {
if (document.cookie.length > 0) {
var c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
var c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) {
c_end = document.cookie.length;
}
return unescape(document.cookie.substring(c_start, c_end));
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = parts.shift();
var cookie = parts.join('=');
if (c_name && c_name === name) {
return cookie;
}
}
return "";
@@ -1292,7 +1292,10 @@ openerp.str_to_datetime = function(str) {
if ( !res ) {
throw new Error("'" + str + "' is not a valid datetime");
}
var tmp = new Date(0);
var tmp = new Date(2000,0,1);
tmp.setUTCMonth(1970);
tmp.setUTCMonth(0);
tmp.setUTCDate(1);
tmp.setUTCFullYear(parseFloat(res[1]));
tmp.setUTCMonth(parseFloat(res[2]) - 1);
tmp.setUTCDate(parseFloat(res[3]));
@@ -1324,7 +1327,7 @@ openerp.str_to_date = function(str) {
if ( !res ) {
throw new Error("'" + str + "' is not a valid date");
}
var tmp = new Date(0);
var tmp = new Date(2000,0,1);
tmp.setFullYear(parseFloat(res[1]));
tmp.setMonth(parseFloat(res[2]) - 1);
tmp.setDate(parseFloat(res[3]));
+1 -2
View File
@@ -58,8 +58,7 @@ openerp.testing = {};
}
var fn, params;
var needle = rparams.model + ':' + rparams.method;
if (url.url === '/web/dataset/call_kw'
&& needle in this.responses) {
if (url.url.substr(0, 20) === '/web/dataset/call_kw' && needle in this.responses) {
fn = this.responses[needle];
params = [
rparams.args || [],
+28 -29
View File
@@ -731,12 +731,13 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var self = this;
return this.save().done(function(result) {
self.trigger("save", result);
self.to_view_mode();
}).then(function(result) {
var parent = self.ViewManager.ActionManager.getParent();
if(parent){
parent.menu.do_reload_needaction();
}
self.reload().then(function() {
self.to_view_mode();
var parent = self.ViewManager.ActionManager.getParent();
if(parent){
parent.menu.do_reload_needaction();
}
});
});
},
on_button_cancel: function(event) {
@@ -900,17 +901,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
* @param {Object} r result of the write function.
*/
record_saved: function(r) {
var self = this;
this.trigger('record_saved', r);
if (!r) {
// should not happen in the server, but may happen for internal purpose
this.trigger('record_saved', r);
return $.Deferred().reject();
} else {
return $.when(this.reload()).then(function () {
self.trigger('record_saved', r);
return r;
});
}
return r;
},
/**
* Updates the form' dataset to contain the new record:
@@ -3080,7 +3076,7 @@ instance.web.form.CompletionFieldMixin = {
values.push({
label: _t("Search More..."),
action: function() {
dataset.name_search(search_val, self.build_domain(), 'ilike', false).done(function(data) {
dataset.name_search(search_val, self.build_domain(), 'ilike', 160).done(function(data) {
self._search_create_popup("search", data);
});
},
@@ -5559,23 +5555,23 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
var calculation = _.bind(function() {
if (this.field.type == "many2one") {
return self.get_distant_fields().then(function(fields) {
return new instance.web.DataSetSearch(self, self.field.relation, self.build_context(), self.get("evaluated_selection_domain"))
.read_slice(fields.fold ? ['fold'] : ['id'], {}).then(function (records) {
var ids = _.map(records, function (val) {return val.id;});
return self.dataset.name_get(ids).then(function (records_name) {
_.each(records, function (record) {
var name = _.find(records_name, function (val) {return val[0] == record.id;})[1];
if (record.fold && record.id != self.get('value')) {
selection_folded.push([record.id, name]);
} else {
selection_unfolded.push([record.id, name]);
}
});
/* :deprecated: fold feature will probably be removed */
// return self.get_distant_fields().then(function(fields) {
self.distant_fields = {};
return new instance.web.DataSetSearch(self, self.field.relation, self.build_context(), self.get("evaluated_selection_domain"))
.read_slice(_.union(_.keys(self.distant_fields), ['id']), {}).then(function (records) {
var ids = _.pluck(records, 'id');
return self.dataset.name_get(ids).then(function (records_name) {
_.each(records, function (record) {
var name = _.find(records_name, function (val) {return val[0] == record.id;})[1];
if (record.fold && record.id != self.get('value')) {
selection_folded.push([record.id, name]);
} else {
selection_unfolded.push([record.id, name]);
}
});
});
});
});
} else {
// For field type selection filter values according to
// statusbar_visible attribute of the field. For example:
@@ -5597,6 +5593,9 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
}
});
},
/*
* :deprecated: this feature will probably be removed with OpenERP v8
*/
get_distant_fields: function() {
var self = this;
if (this.distant_fields) {
+5 -7
View File
@@ -508,7 +508,6 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
var reloaded = $.Deferred();
this.$el.find('.oe_list_content').append(
this.groups.render(function () {
// Keep '=='. This is not a mistake, this is a wanted behaviour to match null & undefined
if (self.dataset.index == null) {
if (self.records.length) {
self.dataset.index = 0;
@@ -1474,14 +1473,13 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
var view = this.view,
limit = view.limit(),
d = new $.Deferred(),
page = this.datagroup.openable ? this.page : view.page;
var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field";}), 'name');
var options = { offset: page * limit, limit: limit, context: {bin_size: true} };
//TODO xmo: investigate why we need to put the setTimeout
$.async_when().done(function() {
dataset.read_slice(fields, options).done(function (records) {
return $.async_when().then(function() {
return dataset.read_slice(fields, options).then(function (records) {
// FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently
if (self.records.length) {
self.records.reset(null, {silent: true});
@@ -1513,13 +1511,12 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
self.records.add(records, {silent: true});
list.render();
d.resolve(list);
if (_.isEmpty(records)) {
view.no_result();
}
return list;
});
});
return d.promise();
},
setup_resequence_rows: function (list, dataset) {
// drag and drop enabled if list is not sorted and there is a
@@ -1600,11 +1597,12 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
self.render_groups(groups));
if (post_render) { post_render(); }
}, function (dataset) {
self.render_dataset(dataset).done(function (list) {
self.render_dataset(dataset).then(function (list) {
self.children[null] = list;
self.elements =
[list.$current.replaceAll($el)[0]];
self.setup_resequence_rows(list, dataset);
}).always(function() {
if (post_render) { post_render(); }
});
});
+14 -3
View File
@@ -1209,11 +1209,12 @@ instance.web.Sidebar = instance.web.Widget.extend({
var self = this;
self.getParent().sidebar_eval_context().done(function (sidebar_eval_context) {
var ids = self.getParent().get_selected_ids();
var domain;
if (self.getParent().get_active_domain) {
var domain = self.getParent().get_active_domain();
domain = self.getParent().get_active_domain();
}
else {
var domain = $.Deferred().resolve(undefined);
domain = $.Deferred().resolve(undefined);
}
if (ids.length === 0) {
instance.web.dialog($("<div />").text(_t("You must choose at least one record.")), { title: _t("Warning"), modal: true });
@@ -1385,7 +1386,17 @@ instance.web.View = instance.web.Widget.extend({
return self.getParent().on_action_executed.apply(null, arguments);
}
};
var context = new instance.web.CompoundContext(dataset.get_context(), action_data.context || {});
var context = dataset.get_context();
if (action_data.model !== dataset.model) {
// filter out context keys that are specific to the action model.
// Wrong default_ and search_default values will no give the expected views
// Wrong group_by values will simply fail and forbid rendering of the destination view
context = _.object(_.reject(_.pairs(context.eval()), function(pair) {
return pair[0].match('^(?:(?:default_|search_default_).+|group_by|group_by_no_leaf)$') !== null;
}));
}
context = new instance.web.CompoundContext(context, action_data.context || {});
var handler = function (action) {
if (action && action.constructor == Object) {
var ncontext = new instance.web.CompoundContext(context);
@@ -690,7 +690,6 @@
.openerp_ie .oe_kanban_view .oe_kanban_group_title_vertical {
-ms-writing-mode: lr-tb !important;
background: #f0eeee;
top: -5px !important;
}
.openerp_ie .oe_kanban_view.oe_kanban_grouped .oe_kanban_group_header {
height: 1%;
@@ -572,7 +572,6 @@
.oe_kanban_group_title_vertical
-ms-writing-mode: lr-tb !important
background: rgb(240, 238, 238)
top: -5px !important
&.oe_kanban_grouped
.oe_kanban_group_header
height: 1%
@@ -859,7 +859,7 @@ function getColor(val, pct, col, noGradient, custSec) {
/** Fix Raphael display:none tspan dy attribute bug */
function setDy(elem, fontSize, txtYpos) {
if (!ie || ie > 9) {
if ((!ie || ie > 9) && elem.node.firstChild.attributes.dy) {
elem.node.firstChild.attributes.dy.value = 0;
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
from openerp.osv import orm, fields
class TestObject(orm.Model):
class TestObject(orm.TransientModel):
_name = 'web_tests_demo.model'
_columns = {