[IMP] website_mail: avoid marking old messages as published
There is semantically no reason to publish old messages, and doing so can be expensive for large databases. Defaulting new messages to published makes sense depending on the model on which they are attached, so it might be better to improve this as an opt-in handled in create() or message_post() or via default_* context keys. bzr revid: odo@openerp.com-20140217142006-ik18uqy9ewhhhb42
This commit is contained in:
parent
ae0e712cb9
commit
ea5d111166
|
@ -28,13 +28,21 @@ class MailMessage(osv.Model):
|
|||
|
||||
_columns = {
|
||||
'website_published': fields.boolean(
|
||||
'Publish', help="Publish on the website as a blog"
|
||||
'Published', help="Visible on the website as a comment"
|
||||
),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'website_published': True,
|
||||
}
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
defaults = super(MailMessage, self).default_get(cr, uid, fields_list, context=context)
|
||||
|
||||
# Note: explicitly implemented in default_get() instead of _defaults,
|
||||
# to avoid setting to True for all existing messages during upgrades.
|
||||
# TODO: this default should probably be dynamic according to the model
|
||||
# on which the messages are attached, thus moved to create().
|
||||
if 'website_published' in fields_list:
|
||||
defaults.setdefault('website_published', True)
|
||||
|
||||
return defaults
|
||||
|
||||
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False, access_rights_uid=None):
|
||||
|
|
Loading…
Reference in New Issue