Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Here is what I have done in my code to be able to bypass tracked messages when needed (say a wizard already generates a more specific summary message for changes)
- Monkey patching is not the best tool, I think OpenERP shall provide this out of the box (or a similar way to do this).
- """
- import logging
- from openerp.addons.project import project
- _logger = logging.getLogger(__name__)
- NO_TRACK_KEY = '_message_no_tracking'
- def patch_message_track(cls):
- """Modification of message tracking mecanism, to be able to inihbate it.
- Some time we generate our own message, bundling different updates.
- In those very case we don't want automatic messages to be issued.
- The new method will look at the context for a _message_no_tracking entry
- which has to exists and be set to true to inhibate auto tracking.
- """
- original = cls.message_track
- def message_track(
- self, cr, uid, ids, tracked_fields, initial_values, context=None):
- if context is not None and context.get(NO_TRACK_KEY, False):
- # no tracking, pass
- _logger.debug(
- "Bypassing tracking for %s,%s as requested by context" %
- (cls._name, ids))
- pass
- else:
- original(
- self, cr, uid, ids, tracked_fields, initial_values, context)
- cls.message_track = original
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement