52
52
def create(self, cr, uid, vals, context=None):
54
def filter_context_value(c):
55
"""filter unrequired value from context"""
56
# We remove user context and web client related value as those
57
# values will be re-set when accessing res.log item, depending
58
# on user or client settings
59
if isinstance(c, dict):
60
FILTER_OUT_KEYS = ['tz', 'lang', 'client', 'bin_size', '_terp_view_name']
61
for context_key in FILTER_OUT_KEYS:
62
c.pop(context_key, None)
53
64
create_context = context and dict(context) or {}
54
65
if 'res_log_read' in create_context:
55
66
vals['read'] = create_context.pop('res_log_read')
56
67
if create_context and not vals.get('context'):
57
68
vals['context'] = create_context
69
log_context = filter_context_value(vals.get('context',{}))
70
if len(str(log_context)) > 250:
71
# if context is still bigger that field size, better lose the
72
# context completly instead of breaking later when user access
75
vals['context'] = log_context
58
76
return super(res_log, self).create(cr, uid, vals, context=context)
60
78
# TODO: do not return secondary log if same object than in the model (but unlink it)