[IMP] mark as (un)read implemented as a server action.
bzr revid: tde@openerp.com-20120625161312-9m60ryduj77l46j9
This commit is contained in:
@@ -2,34 +2,42 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Read/Unread actions -->
|
||||
<record id="actions_server_crm_unread" model="ir.actions.server">
|
||||
<field name="name">Mark unread</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="model_crm_lead"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">object.message_mark_as_unread()</field>
|
||||
<field name="code">self.message_check_and_set_unread(cr, uid, context.get('active_ids'), context=context)</field>
|
||||
</record>
|
||||
|
||||
<record id="act_multi_crm_lead_mark_unread" model="ir.values">
|
||||
<field name="name">actions_server_crm_unread</field>
|
||||
<record id="action_crm_lead_mark_unread" model="ir.values">
|
||||
<field name="name">action_crm_lead_mark_unread</field>
|
||||
<field name="action_id" ref="actions_server_crm_unread"/>
|
||||
<field name="value" eval="'ir.actions.server,' + str(ref('actions_server_crm_unread'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model_id" ref="model_crm_lead" />
|
||||
<field name="model">crm.lead</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<record id="act_multi_hr_holidays_mark_unread" model="ir.values">
|
||||
<field name="name">Hr holidays Mark unread</field>
|
||||
<field name="value" eval="'ir.actions.server,' + str(ref('mail.actions_server_mail_thread_unread'))" />
|
||||
<record id="actions_server_crm_read" model="ir.actions.server">
|
||||
<field name="name">Mark read</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="model_crm_lead"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">self.message_check_and_set_read(cr, uid, context.get('active_ids'), context=context)</field>
|
||||
</record>
|
||||
<record id="action_crm_lead_mark_read" model="ir.values">
|
||||
<field name="name">action_crm_lead_mark_read</field>
|
||||
<field name="action_id" ref="actions_server_crm_read"/>
|
||||
<field name="value" eval="'ir.actions.server,' + str(ref('actions_server_crm_read'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_holidays" />
|
||||
<field name="model">hr_holidays</field>
|
||||
<field name="model_id" ref="model_crm_lead" />
|
||||
<field name="model">crm.lead</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!--
|
||||
CRM CASE STAGE
|
||||
|
||||
@@ -181,7 +181,7 @@ class mail_thread(osv.Model):
|
||||
msg_id = message_obj.create(cr, uid, vals, context=context)
|
||||
|
||||
# Set as unread if writer is not the document responsible
|
||||
self.message_create_check_state(cr, uid, [thread_id], context=context)
|
||||
self.message_create_and_set_unread(cr, uid, [thread_id], context=context)
|
||||
|
||||
# special: if install mode, do not push demo data
|
||||
if context.get('install_mode', False):
|
||||
@@ -438,6 +438,9 @@ class mail_thread(osv.Model):
|
||||
msg_ids = self.message_load_ids(cr, uid, ids, limit, offset, domain, ascent, root_ids, context=context)
|
||||
msgs = self.pool.get('mail.message').read(cr, uid, msg_ids, [], context=context)
|
||||
|
||||
# Set as read
|
||||
self.message_check_and_set_read(cr, uid, ids, context=context)
|
||||
|
||||
""" Retrieve all attachments names """
|
||||
map_id_to_name = {}
|
||||
|
||||
@@ -461,7 +464,6 @@ class mail_thread(osv.Model):
|
||||
|
||||
""" Sort and return messages """
|
||||
msgs = sorted(msgs, key=lambda d: (-d['id']))
|
||||
print 'tatayoyo'
|
||||
return msgs
|
||||
|
||||
def get_pushed_messages(self, cr, uid, ids, limit=100, offset=0, msg_search_domain=[], ascent=False, root_ids=[], context=None):
|
||||
@@ -873,17 +875,26 @@ class mail_thread(osv.Model):
|
||||
# Thread_state
|
||||
#------------------------------------------------------
|
||||
|
||||
def message_create_check_state(self, cr, uid, ids, context=None):
|
||||
def message_create_and_set_unread(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if hasattr(obj, 'user_id') and (not obj.user_id or (obj.user_id and obj.user_id.id != uid)):
|
||||
print 'poinpoinponi'
|
||||
if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id != uid):
|
||||
self.message_mark_as_unread(cr, uid, [obj.id], context=context)
|
||||
|
||||
def message_check_and_set_unread(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id == uid):
|
||||
self.message_mark_as_unread(cr, uid, [obj.id], context=context)
|
||||
|
||||
def message_mark_as_read(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'message_state': True}, context=context)
|
||||
|
||||
def message_mark_as_unread(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'message_state': False}, context=context)
|
||||
|
||||
def message_check_and_set_read(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if not obj.message_state and hasattr(obj, 'user_id') and obj.user_id and obj.user_id.id == uid:
|
||||
self.message_mark_as_read(cr, uid, [obj.id], context=context)
|
||||
|
||||
def message_mark_as_read(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'message_state': True}, context=context)
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -2,30 +2,6 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Server action: mark as unread -->
|
||||
<!--
|
||||
<record id="actions_server_mail_thread_unread" model="ir.actions.server">
|
||||
<field name="name">Mark unread</field>
|
||||
<field name="condition" eval="True"/>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="crm.model_crm_lead"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code" eval=""""self.message_mark_as_unread(cr, uid, [object.id], context=context)""""/>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- Server action: mark as read -->
|
||||
<!--
|
||||
<record id="actions_server_mail_thread_read" model="ir.actions.server">
|
||||
<field name="name">Mark read</field>
|
||||
<field name="condition" eval="True"/>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="mail.model_mail_thread"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code" eval=""""self.message_mark_as_read(cr, uid, [object.id], context=context)""""/>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- toplevel menu -->
|
||||
<menuitem id="mail_feeds_main" name="Feeds" sequence="0"
|
||||
web_icon="static/src/img/feeds.png"
|
||||
|
||||
Reference in New Issue
Block a user