[imp] corrected some problems with context and domains in relation + evalution of non literal context/domains
bzr revid: nicolas.vanhoren@openerp.com-20110630123113-tnzb6owv8kxtl3sw
This commit is contained in:
parent
fc03e1e818
commit
d80b269891
|
@ -649,15 +649,16 @@ class View(openerpweb.Controller):
|
|||
"""
|
||||
self.parse_domain(elem, 'domain', session)
|
||||
self.parse_domain(elem, 'filter_domain', session)
|
||||
context_string = elem.get('context', '').strip()
|
||||
if context_string:
|
||||
try:
|
||||
elem.set('context',
|
||||
openerpweb.ast.literal_eval(context_string))
|
||||
except ValueError:
|
||||
elem.set('context',
|
||||
openerpweb.nonliterals.Context(
|
||||
session, context_string))
|
||||
for el in ['context', 'default_get']:
|
||||
context_string = elem.get(el, '').strip()
|
||||
if context_string:
|
||||
try:
|
||||
elem.set(el,
|
||||
openerpweb.ast.literal_eval(context_string))
|
||||
except ValueError:
|
||||
elem.set(el,
|
||||
openerpweb.nonliterals.Context(
|
||||
session, context_string))
|
||||
|
||||
class FormView(View):
|
||||
_cp_path = "/base/formview"
|
||||
|
|
|
@ -1116,14 +1116,17 @@ var build_view_fields_values = function(view) {
|
|||
var build_relation_context = function(relation_field) {
|
||||
var a_context = relation_field.view.dataset.get_context() || {};
|
||||
var fields_values = build_view_fields_values(relation_field.view);
|
||||
var f_context = new openerp.base.CompoundContext(relation_field.field.context || {}).set_eval_context(fields_values);
|
||||
var ctx = new openerp.base.CompoundContext(a_context, f_context);
|
||||
var f_context = relation_field.field.context || {};
|
||||
var v_context = new openerp.base.CompoundContext(relation_field.node.attrs.default_get || {},
|
||||
relation_field.node.attrs.context || {}).set_eval_context(fields_values);
|
||||
var ctx = new openerp.base.CompoundContext(a_context, f_context, v_context);
|
||||
return ctx;
|
||||
}
|
||||
var build_relation_domain = function(relation_field) {
|
||||
var fields_values = build_view_fields_values(relation_field.view);
|
||||
var f_domain = new openerp.base.CompoundDomain(relation_field.field.domain || []).set_eval_context(fields_values);
|
||||
return f_domain;
|
||||
var f_domain = relation_field.field.domain || [];
|
||||
var v_domain = new openerp.base.CompoundDomain(relation_field.node.attrs.domain || []).set_eval_context(fields_values);
|
||||
return new openerp.base.CompoundDomain(f_domain, v_domain);
|
||||
}
|
||||
|
||||
openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
|
||||
|
|
|
@ -173,14 +173,14 @@ class Context(BaseContext):
|
|||
return eval(self.get_context_string(),
|
||||
SuperDict(ctx))
|
||||
|
||||
def SuperDict(dict):
|
||||
class SuperDict(dict):
|
||||
def __getattr__(self, name):
|
||||
try:
|
||||
return self[name]
|
||||
except KeyError:
|
||||
raise AttributeError(name)
|
||||
def __getitem__(self, key):
|
||||
tmp = super(dict, self)[key]
|
||||
tmp = super(type(self), self).__getitem__(key)
|
||||
if isinstance(tmp, dict):
|
||||
return SuperDict(tmp)
|
||||
return tmp
|
||||
|
|
Loading…
Reference in New Issue