~therp-nl/openupgrade-server/6.0-lp1025797-dangling_references

« back to all changes in this revision

Viewing changes to bin/addons/base/res/res_log.py

  • Committer: Stefan Rijnhart
  • Date: 2012-05-09 12:52:49 UTC
  • mfrom: (3475.1.142 openobject-server)
  • Revision ID: stefan@therp.nl-20120509125249-llcqw330h6u9xls0
[MRG] Merged with main

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                       self._index_name)
51
51
 
52
52
    def create(self, cr, uid, vals, context=None):
 
53
 
 
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)
 
63
            return c
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
 
73
            # res.log item
 
74
            log_context = "{}"
 
75
        vals['context'] = log_context
58
76
        return super(res_log, self).create(cr, uid, vals, context=context)
59
77
 
60
78
    # TODO: do not return secondary log if same object than in the model (but unlink it)