From 6ff627d27548a97a65860e796af3a8b62d1d2ffd Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 23 Nov 2010 17:05:06 +0100 Subject: [PATCH] [IMP] ir.model.data,res.log: allow marking res.log entries as read upon creation via context + do it during module install to avoid useless log spam bzr revid: odo@openerp.com-20101123160506-qsxa7gm5j8scphdz --- bin/addons/base/ir/ir_model.py | 4 ++++ bin/addons/base/res/res_log.py | 8 ++++++++ bin/osv/orm.py | 1 - 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 86bb6cc4dc5..ff4fc9f0feb 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -429,6 +429,10 @@ class ir_model_data(osv.osv): model_obj = self.pool.get(model) if not context: context = {} + + # records created during module install should result in res.log entries that are already read! + context = dict(context, res_log_read=True) + if xml_id and ('.' in xml_id): assert len(xml_id.split('.'))==2, _("'%s' contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id") % (xml_id) module, xml_id = xml_id.split('.') diff --git a/bin/addons/base/res/res_log.py b/bin/addons/base/res/res_log.py index 8ac53acae6b..0862a686aa8 100644 --- a/bin/addons/base/res/res_log.py +++ b/bin/addons/base/res/res_log.py @@ -50,6 +50,14 @@ class res_log(osv.osv): cr.execute('CREATE INDEX %s ON res_log (user_id, read)' % self._index_name) + def create(self, cr, uid, vals, context=None): + create_context = context and dict(context) or {} + if 'res_log_read' in create_context: + vals['read'] = create_context.pop('res_log_read') + if create_context and not vals.get('context'): + vals['context'] = create_context + return super(res_log, self).create(cr, uid, vals, context=context) + # TODO: do not return secondary log if same object than in the model (but unlink it) def get(self, cr, uid, context=None): unread_log_ids = self.search(cr, uid, diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 496d569a29c..fb9381ed0b1 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -394,7 +394,6 @@ class orm_template(object): 'res_model': self._name, 'secondary': secondary, 'res_id': id, - 'context': context, }, context=context )