Updated group model and views (inherit from mail thread). Updated message model (updated type field). First work on thread API
bzr revid: tde@openerp.com-20120202094845-rb2b93ifmj8xyny8
This commit is contained in:
parent
d64f3c9783
commit
77e4e05b94
|
@ -32,8 +32,9 @@ class mail_group(osv.osv):
|
|||
"""
|
||||
|
||||
_name = 'mail.group'
|
||||
_inherits = {'res.groups': 'group_id'}
|
||||
|
||||
#_inherits = {'res.groups': 'group_id'}
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
def action_group_join(self, cr, uid, ids, context={}):
|
||||
sub_obj = self.pool.get('mail.subscription')
|
||||
menu_values = {'res_model': 'mail.group', 'user_id': uid}
|
||||
|
@ -49,10 +50,9 @@ class mail_group(osv.osv):
|
|||
return True
|
||||
|
||||
_columns = {
|
||||
'group_id': fields.many2one('res.groups', required=True, ondelete='cascade',
|
||||
string='Group',
|
||||
help='The group extended by this portal'),
|
||||
#'name': fields.char('Name', size=64, required=True),
|
||||
#'group_id': fields.many2one('res.groups', required=True, ondelete='cascade',
|
||||
#string='Group', help='The group extended by this portal'),
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'description': fields.text('Description'),
|
||||
'responsible_id': fields.many2one('res.users', string='Responsible',
|
||||
ondelete='set null', required=True),
|
||||
|
@ -93,14 +93,14 @@ class mail_group(osv.osv):
|
|||
'name': _('%s') % group.name,
|
||||
'parent_id': menu_root,
|
||||
'action': 'ir.actions.act_window,%s' % (act_id),
|
||||
'groups_id': [(6, 0, [group.group_id.id])],
|
||||
#'groups_id': [(6, 0, [group.group_id.id])],
|
||||
}
|
||||
menu_id = menu_obj.create(cr, uid, menu_values, context)
|
||||
# create data
|
||||
data_values = {
|
||||
'name': _('%s') % group.name,
|
||||
'name': '%s' % group.name,
|
||||
'model': 'ir.ui.menu',
|
||||
'module': 'portal',
|
||||
'module': 'mail',
|
||||
'res_id': menu_id,
|
||||
'noupdate': 'True'}
|
||||
data_id = ir_data.create(cr, uid, data_values, context)
|
||||
|
@ -108,13 +108,13 @@ class mail_group(osv.osv):
|
|||
|
||||
def _assign_menu(self, cr, uid, ids, context=None):
|
||||
""" assign groups (ids) menu to the users joigning the groups"""
|
||||
user_obj = self.pool.get('res.users')
|
||||
for p in self.browse(cr, uid, ids, context):
|
||||
# user menu action = portal menu action if set in portal
|
||||
if p.menu_action_id:
|
||||
user_ids = [u.id for u in p.users if u.id != 1]
|
||||
user_values = {'menu_id': p.menu_action_id.id}
|
||||
user_obj.write(cr, uid, user_ids, user_values, context)
|
||||
#user_obj = self.pool.get('res.users')
|
||||
#for p in self.browse(cr, uid, ids, context):
|
||||
## user menu action = portal menu action if set in portal
|
||||
#if p.menu_action_id:
|
||||
#user_ids = [u.id for u in p.users if u.id != 1]
|
||||
#user_values = {'menu_id': p.menu_action_id.id}
|
||||
#user_obj.write(cr, uid, user_ids, user_values, context)
|
||||
|
||||
def _get_res_xml_id(self, cr, uid, module, xml_id):
|
||||
""" return the resource id associated to the given xml_id """
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
<field name="user_id" string="User" readonly="0"/>
|
||||
<field name="partner_id" readonly="1" attrs="{'invisible':[('partner_id', '=', False)]}"/>
|
||||
</group>
|
||||
<field name="body_text"/>
|
||||
<field name="body_html"/>
|
||||
<field name="type"/>
|
||||
<field name="need_action"/>
|
||||
<field name="model"/>
|
||||
|
@ -142,32 +144,24 @@
|
|||
<field name="domain">[('user_id', '=', uid)]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_subscriptions" model="ir.actions.act_window">
|
||||
<field name="name">Subscriptions</field>
|
||||
<field name="res_model">mail.subscription</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<!-- toplevel menu -->
|
||||
<menuitem id="mail_group" name="Feeds" action="action_view_groups"/>
|
||||
|
||||
<!-- left-side menu: Feeds !-->
|
||||
<menuitem id="mg_feeds" name="Feeds" parent="mail_group" action="action_view_groups"/>
|
||||
<!-- left-side Tmp: temporary Messages link to create a message !-->
|
||||
<menuitem id="mg_feeds" name="Feeds" parent="mail_group" action="action_view_mytweets"/>
|
||||
<menuitem id="mg_feeds_my" name="My feeds" parent="mg_feeds" action="action_view_mytweets"/>
|
||||
<!-- left-side Tmp: temporary Messages link to create a message !-->
|
||||
<menuitem id="mg_feeds_all" name="All feeds" parent="mg_feeds" action="action_view_tweets"/>
|
||||
|
||||
<!-- left-side menu: Groups !-->
|
||||
<menuitem id="mg_groups" name="Groups" parent="mail_group" action="action_view_groups"/>
|
||||
<menuitem id="mg_groups_all" name="All groups" parent="mg_groups" action="action_view_groups"/>
|
||||
|
||||
<!-- left-side menu: Tmp !-->
|
||||
<menuitem id="mg_tmp" name="Tmp" parent="mail_group" action="action_view_mail_message"/>
|
||||
<menuitem id="mg_tmp" name="Tmp" parent="mail_group" action="action_view_all_message"/>
|
||||
<!-- left-side Tmp: temporary Messages link to create a message !-->
|
||||
<menuitem id="mg_msg" name="Messages" parent="mg_tmp" action="action_view_mail_message"/>
|
||||
<!-- left-side Tmp: temporary Subscriptions link to see subscriptions !-->
|
||||
<menuitem id="mg_sub" name="Subscriptions" parent="mg_tmp" action="action_view_subscriptions"/>
|
||||
<menuitem id="mg_msg" name="Messages" parent="mg_tmp" action="action_view_all_message"/>
|
||||
<!-- left-side Tmp: temporary Groups link to see groups !-->
|
||||
<menuitem id="mg_groups_tmp" name="groups" parent="mg_tmp" action="action_view_groups"/>
|
||||
<menuitem id="mg_groups_tmp" name="Groups" parent="mg_tmp" action="action_view_groups"/>
|
||||
|
||||
<!-- <act_window
|
||||
context="{'search_default__id': [active_id], 'default_project_id': active_id}"
|
||||
|
|
|
@ -107,7 +107,7 @@ class mail_message(osv.osv):
|
|||
|
||||
_name = 'mail.message'
|
||||
_inherit = 'mail.message.common'
|
||||
_description = 'Email Message'
|
||||
_description = 'Generic Message (Email, Comment, Notification)'
|
||||
_order = 'date desc'
|
||||
|
||||
# XXX to review - how to determine action to use?
|
||||
|
@ -163,7 +163,7 @@ class mail_message(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'partner_id': fields.many2one('res.partner', 'Related partner'),
|
||||
#'user_id': fields.many2one('res.users', 'Related user', readonly=1),
|
||||
'user_id': fields.many2one('res.users', 'Related user', readonly=1),
|
||||
'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'),
|
||||
'display_text': fields.function(_get_display_text, method=True, type='text', size="512", string='Display Text'),
|
||||
'mail_server_id': fields.many2one('ir.mail_server', 'Outgoing mail server', readonly=1),
|
||||
|
@ -176,22 +176,25 @@ class mail_message(osv.osv):
|
|||
], 'State', readonly=True),
|
||||
'auto_delete': fields.boolean('Auto Delete', help="Permanently delete this email after sending it, to save space"),
|
||||
'original': fields.binary('Original', help="Original version of the message, as it was sent on the network", readonly=1),
|
||||
# tde add/modif
|
||||
'user_id': fields.many2one('res.users', 'Related user', readonly=1),
|
||||
# note feature: add type (email, comment, notification) and need_action
|
||||
'type': fields.selection([
|
||||
('tweet', 'Tweet'),
|
||||
('status', 'Status'),
|
||||
], 'Type'),
|
||||
'need_action': fields.boolean('Need action'),
|
||||
('email', 'e-mail'),
|
||||
('comment', 'Comment'),
|
||||
('notification', 'Notification'),
|
||||
], 'Type', help="Message type: e-mail for e-mail message, notification for system message, comment for other messages such as user replies"),
|
||||
'need_action': fields.boolean('Need action', help="Asks the user to perform an action"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': 'received',
|
||||
'type': 'notification',
|
||||
}
|
||||
|
||||
# thib add
|
||||
#------------------------------------------------------
|
||||
# Note specific api
|
||||
#------------------------------------------------------
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
print vals
|
||||
return super(mail_message, self).create(cr, uid, vals, context)
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
|
@ -255,7 +258,9 @@ class mail_message(osv.osv):
|
|||
print args
|
||||
return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit,order=order, context=context, count=count)
|
||||
|
||||
# end thib add
|
||||
#------------------------------------------------------
|
||||
# E-Mail api
|
||||
#------------------------------------------------------
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""SELECT indexname FROM pg_indexes WHERE indexname = 'mail_message_model_res_id_idx'""")
|
||||
|
|
|
@ -125,6 +125,14 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_all_message" model="ir.actions.act_window">
|
||||
<field name="name">Messages</field>
|
||||
<field name="res_model">mail.message</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_email_message_search"/>
|
||||
</record>
|
||||
|
||||
<record id="action_view_mail_message" model="ir.actions.act_window">
|
||||
<field name="name">Messages</field>
|
||||
<field name="res_model">mail.message</field>
|
||||
|
|
|
@ -55,9 +55,9 @@ class mail_notification(osv.osv):
|
|||
_name = 'mail.notification'
|
||||
_rec_name = 'id'
|
||||
_columns = {
|
||||
'user_id': fields.many2one('res.users', string='User'
|
||||
'user_id': fields.many2one('res.users', string='User',
|
||||
ondelete='cascade', required=True),
|
||||
'message_id': fields.many2one('mail.message', string='Message'
|
||||
'message_id': fields.many2one('mail.message', string='Message',
|
||||
ondelete='cascade', required=True),
|
||||
'read': fields.boolean('Read'),
|
||||
}
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="action_view_subscriptions" model="ir.actions.act_window">
|
||||
<field name="name">Subscriptions</field>
|
||||
<field name="res_model">mail.subscription</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_notifications" model="ir.actions.act_window">
|
||||
<field name="name">Pushed notif</field>
|
||||
<field name="res_model">mail.notification</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<!-- left-side Tmp: temporary Subscriptions link to see subscriptions !-->
|
||||
<menuitem id="mg_sub" name="Subscriptions" parent="mg_tmp" action="action_view_subscriptions"/>
|
||||
<!-- left-side Tmp: temporary Notifications link to see notifications !-->
|
||||
<menuitem id="mg_notif" name="Pushed notif" parent="mg_tmp" action="action_view_notifications"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -82,7 +82,7 @@ class mail_thread(osv.osv):
|
|||
})
|
||||
return super(mail_thread, self).copy(cr, uid, id, default, context=context)
|
||||
|
||||
def message_append(self, cr, uid, threads, subject, body_text=None, email_to=False,
|
||||
def message_append(self, cr, uid, threads, subject, body_text=None, type='email', email_to=False,
|
||||
email_from=False, email_cc=None, email_bcc=None, reply_to=None,
|
||||
email_date=None, message_id=False, references=None,
|
||||
attachments=None, body_html=None, subtype=None, headers=None,
|
||||
|
@ -166,7 +166,8 @@ class mail_thread(osv.osv):
|
|||
'message_id': message_id,
|
||||
'body_text': body_text or (hasattr(thread, 'description') and thread.description or False),
|
||||
'attachment_ids': [(6, 0, to_attach)],
|
||||
'state' : 'received',
|
||||
'state': 'received',
|
||||
'type': type,
|
||||
}
|
||||
|
||||
if email_from:
|
||||
|
@ -215,9 +216,12 @@ class mail_thread(osv.osv):
|
|||
to determine the model of the thread to
|
||||
update (instead of the current model).
|
||||
"""
|
||||
# 6.2 Social feature: add default email type for old API
|
||||
if not 'type' in msg_dict: msg_dict['type'] = 'email'
|
||||
return self.message_append(cr, uid, ids,
|
||||
subject = msg_dict.get('subject'),
|
||||
body_text = msg_dict.get('body_text'),
|
||||
type = msg_dict.get('type'),
|
||||
email_to = msg_dict.get('to'),
|
||||
email_from = msg_dict.get('from'),
|
||||
email_cc = msg_dict.get('cc'),
|
||||
|
@ -235,8 +239,15 @@ class mail_thread(osv.osv):
|
|||
context = context)
|
||||
|
||||
# Message loading
|
||||
def message_load(self):
|
||||
pass
|
||||
def message_load(self, cr, uid, ids, context=None):
|
||||
""" Social feature added this method
|
||||
loading message: search in mail.messages where res_id = ids, (res_)model = current model """
|
||||
msg_obj = self.pool.get('mail.message')
|
||||
msg_ids = []
|
||||
for id in ids:
|
||||
msg_ids += msg_obj.search(cr, uid, ['&', ('res_id', '=', id), ('model', '=', self._name)], context=context)
|
||||
msgs = msg_obj.browse(cr, uid, ids)
|
||||
return msgs
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email specific
|
||||
|
@ -484,8 +495,8 @@ class mail_thread(osv.osv):
|
|||
#------------------------------------------------------
|
||||
# Note specific
|
||||
#------------------------------------------------------
|
||||
def message_append_note(self, context, type='notification'):
|
||||
pass
|
||||
def message_append_note(self, cr, uid, ids, subject, body, type='notification', context=None):
|
||||
return self.message_append(cr, uid, ids, subject, body_text=body, type=type, context=context)
|
||||
|
||||
#------------------------------------------------------
|
||||
# Subscription mechanism
|
||||
|
|
Loading…
Reference in New Issue