[MERGE] forward port of branch saas-1 up to revid 3740 chs@openerp.com-20130702141958-zxkppo4c6zvpo0uf
bzr revid: chs@openerp.com-20130702145352-dym8zvfkwzb3qiqa
This commit is contained in:
commit
713b00d477
|
@ -2963,8 +2963,8 @@
|
|||
margin: 0 !important;
|
||||
padding: 0;
|
||||
}
|
||||
.openerp .oe_list .oe_form .oe_form_field_boolean {
|
||||
padding: 1px 6px 3px;
|
||||
.openerp .oe_list .oe_form .oe_form_field_boolean input {
|
||||
margin: 1px 0 0 10px !important;
|
||||
}
|
||||
.openerp .oe_list .oe_list_content .oe_group_header {
|
||||
background-color: #ededed;
|
||||
|
|
|
@ -2348,10 +2348,8 @@ $sheet-padding: 16px
|
|||
position: absolute
|
||||
margin: 0 !important // dammit
|
||||
padding: 0
|
||||
.oe_form_field_boolean
|
||||
// use padding similar to actual cell to correctly position the
|
||||
// checkbox
|
||||
padding: 1px 6px 3px
|
||||
.oe_form_field_boolean input
|
||||
margin: 1px 0 0 10px !important
|
||||
.oe_list_content .oe_group_header
|
||||
@include vertical-gradient(#fcfcfc, #dedede)
|
||||
|
||||
|
|
|
@ -283,6 +283,16 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
CHECK_INTERVAL = 1000, id = _.uniqueId('get_file_frame'),
|
||||
remove_form = false;
|
||||
|
||||
|
||||
// iOS devices doesn't allow iframe use the way we do it,
|
||||
// opening a new window seems the best way to workaround
|
||||
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
|
||||
var params = _.extend({}, options.data || {}, {token: token});
|
||||
var url = this.url(options.url, params);
|
||||
instance.web.unblockUI();
|
||||
return window.open(url);
|
||||
}
|
||||
|
||||
var $form, $form_data = $('<div>');
|
||||
|
||||
var complete = function () {
|
||||
|
|
|
@ -602,6 +602,86 @@ openerp.web.pyeval = function (instance) {
|
|||
}
|
||||
});
|
||||
|
||||
// recursively wraps JS objects passed into the context to attributedicts
|
||||
// which jsonify back to JS objects
|
||||
var wrap = function (value) {
|
||||
if (value === null) { return py.None; }
|
||||
|
||||
switch (typeof value) {
|
||||
case 'undefined': throw new Error("No conversion for undefined");
|
||||
case 'boolean': return py.bool.fromJSON(value);
|
||||
case 'number': return py.float.fromJSON(value);
|
||||
case 'string': return py.str.fromJSON(value);
|
||||
}
|
||||
|
||||
switch(value.constructor) {
|
||||
case Object: return wrapping_dict.fromJSON(value);
|
||||
case Array: return wrapping_list.fromJSON(value);
|
||||
}
|
||||
|
||||
throw new Error("ValueError: unable to wrap " + value);
|
||||
};
|
||||
var wrapping_dict = py.type('wrapping_dict', null, {
|
||||
__init__: function () {
|
||||
this._store = {};
|
||||
},
|
||||
__getitem__: function (key) {
|
||||
var k = key.toJSON();
|
||||
if (!(k in this._store)) {
|
||||
throw new Error("KeyError: '" + k + "'");
|
||||
}
|
||||
return wrap(this._store[k]);
|
||||
},
|
||||
__getattr__: function (key) {
|
||||
return this.__getitem__(py.str.fromJSON(key));
|
||||
},
|
||||
get: function () {
|
||||
var args = py.PY_parseArgs(arguments, ['k', ['d', py.None]]);
|
||||
|
||||
if (!(args.k.toJSON() in this._store)) { return args.d; }
|
||||
return this.__getitem__(args.k);
|
||||
},
|
||||
fromJSON: function (d) {
|
||||
var instance = py.PY_call(wrapping_dict);
|
||||
instance._store = d;
|
||||
return instance;
|
||||
},
|
||||
toJSON: function () {
|
||||
return this._store;
|
||||
},
|
||||
});
|
||||
var wrapping_list = py.type('wrapping_list', null, {
|
||||
__init__: function () {
|
||||
this._store = [];
|
||||
},
|
||||
__getitem__: function (index) {
|
||||
return wrap(this._store[index.toJSON()]);
|
||||
},
|
||||
fromJSON: function (ar) {
|
||||
var instance = py.PY_call(wrapping_list);
|
||||
instance._store = ar;
|
||||
return instance;
|
||||
},
|
||||
toJSON: function () {
|
||||
return this._store;
|
||||
},
|
||||
});
|
||||
var wrap_context = function (context) {
|
||||
for (var k in context) {
|
||||
if (!context.hasOwnProperty(k)) { continue; }
|
||||
var val = context[k];
|
||||
|
||||
if (val === null) { continue; }
|
||||
if (val.constructor === Array) {
|
||||
context[k] = wrapping_list.fromJSON(val);
|
||||
} else if (val.constructor === Object
|
||||
&& !py.PY_isInstance(val, py.object)) {
|
||||
context[k] = wrapping_dict.fromJSON(val);
|
||||
}
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
var eval_contexts = function (contexts, evaluation_context) {
|
||||
evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
|
||||
return _(contexts).reduce(function (result_context, ctx) {
|
||||
|
@ -615,8 +695,8 @@ openerp.web.pyeval = function (instance) {
|
|||
var evaluated = ctx;
|
||||
switch(ctx.__ref) {
|
||||
case 'context':
|
||||
evaluation_context.context = py.dict.fromJSON(evaluation_context);
|
||||
evaluated = py.eval(ctx.__debug, evaluation_context);
|
||||
evaluation_context.context = evaluation_context;
|
||||
evaluated = py.eval(ctx.__debug, wrap_context(evaluation_context));
|
||||
break;
|
||||
case 'compound_context':
|
||||
var eval_context = eval_contexts([ctx.__eval_context]);
|
||||
|
@ -640,9 +720,9 @@ openerp.web.pyeval = function (instance) {
|
|||
}
|
||||
switch(domain.__ref) {
|
||||
case 'domain':
|
||||
evaluation_context.context = py.dict.fromJSON(evaluation_context);
|
||||
evaluation_context.context = evaluation_context;
|
||||
result_domain.push.apply(
|
||||
result_domain, py.eval(domain.__debug, evaluation_context));
|
||||
result_domain, py.eval(domain.__debug, wrap_context(evaluation_context)));
|
||||
break;
|
||||
case 'compound_domain':
|
||||
var eval_context = eval_contexts([domain.__eval_context]);
|
||||
|
@ -669,8 +749,8 @@ openerp.web.pyeval = function (instance) {
|
|||
var evaluated = ctx;
|
||||
switch(ctx.__ref) {
|
||||
case 'context':
|
||||
evaluation_context.context = py.dict.fromJSON(evaluation_context);
|
||||
evaluated = py.eval(ctx.__debug, evaluation_context);
|
||||
evaluation_context.context = evaluation_context;
|
||||
evaluated = py.eval(ctx.__debug, wrap_context(evaluation_context));
|
||||
break;
|
||||
case 'compound_context':
|
||||
var eval_context = eval_contexts([ctx.__eval_context]);
|
||||
|
@ -712,7 +792,6 @@ openerp.web.pyeval = function (instance) {
|
|||
instance.web.pyeval.eval = function (type, object, context, options) {
|
||||
options = options || {};
|
||||
context = _.extend(instance.web.pyeval.context(), context || {});
|
||||
context['context'] = py.dict.fromJSON(context);
|
||||
|
||||
//noinspection FallthroughInSwitchStatementJS
|
||||
switch(type) {
|
||||
|
|
|
@ -1174,7 +1174,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in
|
|||
return $.when(_.map(facet_values, function (facet_value) {
|
||||
return {
|
||||
label: _.str.sprintf(self.completion_label.toString(),
|
||||
facet_value.label),
|
||||
_.escape(facet_value.label)),
|
||||
facet: self.make_facet([facet_value])
|
||||
}
|
||||
}));
|
||||
|
@ -1342,8 +1342,8 @@ instance.web.search.CharField = instance.web.search.Field.extend( /** @lends ins
|
|||
if (_.isEmpty(value)) { return $.when(null); }
|
||||
var label = _.str.sprintf(_.str.escapeHTML(
|
||||
_t("Search %(field)s for: %(value)s")), {
|
||||
field: '<em>' + this.attrs.string + '</em>',
|
||||
value: '<strong>' + _.str.escapeHTML(value) + '</strong>'});
|
||||
field: '<em>' + _.escape(this.attrs.string) + '</em>',
|
||||
value: '<strong>' + _.escape(value) + '</strong>'});
|
||||
return $.when([{
|
||||
label: label,
|
||||
facet: {
|
||||
|
@ -1360,8 +1360,8 @@ instance.web.search.NumberField = instance.web.search.Field.extend(/** @lends in
|
|||
if (isNaN(val)) { return $.when(); }
|
||||
var label = _.str.sprintf(
|
||||
_t("Search %(field)s for: %(value)s"), {
|
||||
field: '<em>' + this.attrs.string + '</em>',
|
||||
value: '<strong>' + _.str.escapeHTML(value) + '</strong>'});
|
||||
field: '<em>' + _.escape(this.attrs.string) + '</em>',
|
||||
value: '<strong>' + _.escape(value) + '</strong>'});
|
||||
return $.when([{
|
||||
label: label,
|
||||
facet: {
|
||||
|
@ -1449,13 +1449,13 @@ instance.web.search.SelectionField = instance.web.search.Field.extend(/** @lends
|
|||
})
|
||||
.map(function (sel) {
|
||||
return {
|
||||
label: sel[1],
|
||||
label: _.escape(sel[1]),
|
||||
facet: facet_from(self, sel)
|
||||
};
|
||||
}).value();
|
||||
if (_.isEmpty(results)) { return $.when(null); }
|
||||
return $.when.call(null, [{
|
||||
label: this.attrs.string
|
||||
label: _.escape(this.attrs.string)
|
||||
}].concat(results));
|
||||
},
|
||||
facet_for: function (value) {
|
||||
|
@ -1493,7 +1493,7 @@ instance.web.search.DateField = instance.web.search.Field.extend(/** @lends inst
|
|||
var date_string = instance.web.format_value(d, this.attrs);
|
||||
var label = _.str.sprintf(_.str.escapeHTML(
|
||||
_t("Search %(field)s at: %(value)s")), {
|
||||
field: '<em>' + this.attrs.string + '</em>',
|
||||
field: '<em>' + _.escape(this.attrs.string) + '</em>',
|
||||
value: '<strong>' + date_string + '</strong>'});
|
||||
return $.when([{
|
||||
label: label,
|
||||
|
@ -1540,10 +1540,10 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
|
|||
context: context
|
||||
}).then(function (results) {
|
||||
if (_.isEmpty(results)) { return null; }
|
||||
return [{label: self.attrs.string}].concat(
|
||||
return [{label: _.escape(self.attrs.string)}].concat(
|
||||
_(results).map(function (result) {
|
||||
return {
|
||||
label: result[1],
|
||||
label: _.escape(result[1]),
|
||||
facet: facet_from(self, result)
|
||||
};
|
||||
}));
|
||||
|
|
|
@ -471,6 +471,20 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
}).then(function(res) {
|
||||
action = _.clone(action);
|
||||
action.context = res.context;
|
||||
|
||||
// iOS devices doesn't allow iframe use the way we do it,
|
||||
// opening a new window seems the best way to workaround
|
||||
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
|
||||
var params = {
|
||||
action: JSON.stringify(action),
|
||||
token: new Date().getTime()
|
||||
}
|
||||
var url = self.session.url('/web/report', params)
|
||||
instance.web.unblockUI();
|
||||
$('<a href="'+url+'" target="_blank"></a>')[0].click();
|
||||
return;
|
||||
}
|
||||
|
||||
var c = instance.webclient.crashmanager;
|
||||
return $.Deferred(function (d) {
|
||||
self.session.get_file({
|
||||
|
|
|
@ -704,6 +704,73 @@ openerp.testing.section('eval.contexts', {
|
|||
}]);
|
||||
deepEqual(result, {type: 'out_invoice'});
|
||||
});
|
||||
test('return-input-value', function (instance) {
|
||||
var result = instance.web.pyeval.eval('contexts', [{
|
||||
__ref: 'compound_context',
|
||||
__contexts: ["{'line_id': line_id , 'journal_id': journal_id }"],
|
||||
__eval_context: {
|
||||
__ref: 'compound_context',
|
||||
__contexts: [{
|
||||
__ref: 'compound_context',
|
||||
__contexts: [
|
||||
{lang: 'en_US', tz: 'Europe/Paris', uid: 1},
|
||||
{lang: 'en_US', tz: 'Europe/Paris', uid: 1},
|
||||
{}
|
||||
],
|
||||
__eval_context: null,
|
||||
}, {
|
||||
active_id: false,
|
||||
active_ids: [],
|
||||
active_model: 'account.move',
|
||||
amount: 0,
|
||||
company_id: 1,
|
||||
date: '2013-06-21',
|
||||
id: false,
|
||||
journal_id: 14,
|
||||
line_id: [
|
||||
[0, false, {
|
||||
account_id: 55,
|
||||
amount_currency: 0,
|
||||
analytic_account_id: false,
|
||||
credit: 0,
|
||||
currency_id: false,
|
||||
date_maturity: false,
|
||||
debit: 0,
|
||||
name: "dscsd",
|
||||
partner_id: false,
|
||||
tax_amount: 0,
|
||||
tax_code_id: false,
|
||||
}]
|
||||
],
|
||||
name: '/',
|
||||
narration: false,
|
||||
parent: {},
|
||||
partner_id: false,
|
||||
period_id: 6,
|
||||
ref: false,
|
||||
state: 'draft',
|
||||
to_check: false,
|
||||
}],
|
||||
__eval_context: null,
|
||||
},
|
||||
}]);
|
||||
deepEqual(result, {
|
||||
journal_id: 14,
|
||||
line_id: [[0, false, {
|
||||
account_id: 55,
|
||||
amount_currency: 0,
|
||||
analytic_account_id: false,
|
||||
credit: 0,
|
||||
currency_id: false,
|
||||
date_maturity: false,
|
||||
debit: 0,
|
||||
name: "dscsd",
|
||||
partner_id: false,
|
||||
tax_amount: 0,
|
||||
tax_code_id: false,
|
||||
}]],
|
||||
});
|
||||
});
|
||||
});
|
||||
openerp.testing.section('eval.domains', {
|
||||
dependencies: ['web.coresetup', 'web.dates']
|
||||
|
|
|
@ -395,10 +395,16 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
|||
});
|
||||
},
|
||||
get_range_domain: function() {
|
||||
var format = instance.web.date_to_str,
|
||||
domain = this.last_search[0].slice(0);
|
||||
domain.unshift([this.date_start, '>=', format(this.range_start.clone().addDays(-6))]);
|
||||
domain.unshift([this.date_start, '<=', format(this.range_stop.clone().addDays(6))]);
|
||||
var format = instance.web.date_to_str;
|
||||
var A = format(this.range_start.clone().addDays(-6));
|
||||
var B = format(this.range_stop.clone().addDays(6));
|
||||
var domain = [
|
||||
'|', '|',
|
||||
'&', [this.date_start, '>=', A], [this.date_start, '<=', B],
|
||||
'&', [this.date_stop, '>=', A], [this.date_stop, '<=', B],
|
||||
'&', [this.date_start, '<', A], [this.date_stop, '>', B]
|
||||
];
|
||||
domain.concat(this.last_search[0].slice(0))
|
||||
return domain;
|
||||
},
|
||||
do_show: function () {
|
||||
|
|
Loading…
Reference in New Issue