[IMP] Moved code for views in correct files; some improvements in mail.thread; work on threadview widget

bzr revid: tde@openerp.com-20120207170746-m3ptbzotrafa9wvq
This commit is contained in:
Thibault Delavallée 2012-02-07 18:07:46 +01:00
parent 7a4f8ea0a1
commit 74255533e1
7 changed files with 137 additions and 196 deletions

View File

@ -1,60 +1,7 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- mail.message tree: tweet-type view !-->
<record model="ir.ui.view" id="view_tweet_tree">
<field name="name">mail.message.tree_tweet</field>
<field name="model">mail.message</field>
<field name="type">tree</field>
<field name="sequence">15</field>
<field name="arch" type="xml">
<tree string="Tweets">
<field name="date"/>
<field name="subject"/>
<field name="user_id"/>
<field name="model" invisible="1"/>
<field name="res_id" invisible="1"/>
</tree>
</field>
</record>
<!-- mail.message form: tweet-type view !-->
<record model="ir.ui.view" id="view_tweet_form">
<field name="name">mail.message.form_tweet</field>
<field name="model">mail.message</field>
<field name="type">form</field>
<field name="sequence">15</field>
<field name="arch" type="xml">
<form string="Tweet">
<group colspan="4" col="6">
<field name="subject" colspan="4"/>
<field name="date"/>
<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"/>
<field name="res_id"/>
</form>
</field>
</record>
<!-- mail.message search: tweet-type view !-->
<record model="ir.ui.view" id="view_tweet_search">
<field name="name">mail.message.search_tweet</field>
<field name="model">mail.message</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Tweet Search">
<field name="user_id" string="User"/>
</search>
</field>
</record>
<!-- Group Kanban View !-->
<record model="ir.ui.view" id="view_group_kanban">
<field name="name">mail.group.kanban</field>
@ -72,7 +19,6 @@
<div class="oe_group_details">
<h4><a type="edit"><field name="name"/></a></h4>
<ul>
<li t-if="record.name.raw_value"><field name="name"/></li>
<li><a name="action_group_join" string="Join" type="object">Join</a></li>
<li>Joined</li>
</ul>
@ -102,11 +48,11 @@
<field name="public" nolabel="1" colspan="1"/>
<label string="This group is visible by non members" colspan="2"/>
</group>
<separator string="Test actions" colspan="4"/>
<button name="action_test" string="Test" type="object" icon="gtk-go-forward" colspan="2"/>
<button name="action_null" string="Test2" type="object" icon="gtk-go-forward" colspan="2"/>
<separator string="OpenChatter" colspan="4"/>
<button name="action_test" string="Test" type="object" icon="gtk-go-forward" />
<button name="action_null" string="Test2" type="object" icon="gtk-go-forward" />
<separator string="OpenChatter" colspan="4"/>
<!-- <field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/> -->
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</form>
</field>
</record>
@ -119,25 +65,6 @@
<field name="view_mode">kanban,tree,form</field>
</record>
<record id="action_view_tweets" 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="context">{'filter_search': True, 'tree_view_ref': 'mail.view_tweet_tree', 'form_view_ref': 'mail.view_tweet_form'}</field>
<field name="search_view_id" ref="view_tweet_search"/>
</record>
<record id="action_view_mytweets" 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="context">{'filter_search': True, 'tree_view_ref': 'mail.view_tweet_tree', 'form_view_ref': 'mail.view_tweet_form'}</field>
<field name="search_view_id" ref="view_tweet_search"/>
<field name="domain">[('user_id', '=', uid)]</field>
</record>
<!-- toplevel menu -->
<menuitem id="mail_group" name="Feeds" action="action_view_groups"/>

View File

@ -162,7 +162,7 @@ class mail_message(osv.osv):
msg_txt += message.subject
result[message.id] = msg_txt
return result
_columns = {
'partner_id': fields.many2one('res.partner', 'Related partner'),
'user_id': fields.many2one('res.users', 'Related user', readonly=1),
@ -182,15 +182,14 @@ class mail_message(osv.osv):
'type': fields.selection([
('email', 'e-mail'),
('comment', 'Comment'),
('notification', 'Notification'),
('notification', 'System 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"),
'need_action_user_id': fields.many2one('res.users', 'Action user', help="User requested to perform an action"),
'need_action_user_id': fields.many2one('res.users', 'Action by user', help="User requested to perform an action"),
}
_defaults = {
'state': 'received',
'type': 'notification',
'type': 'comment',
}
#------------------------------------------------------
@ -221,72 +220,6 @@ class mail_message(osv.osv):
return notifications
#------------------------------------------------------
# Note specific api
#------------------------------------------------------
#def tmp_backup(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
#if not context or not context.has_key('filter_search'):
#return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
## get subscriptions
#sub_obj = self.pool.get('mail.subscription')
#sub_ids = sub_obj.search(cr, uid, [('user_id', '=', uid)])
#subs = sub_obj.browse(cr, uid, sub_ids)
## stock tweets to find
#res_model_ids_dict = {}
#res_model_all_list = []
## check all subscriptions
#for sub in subs:
#if sub.res_model and sub.res_id == 0 and sub.res_domain == False:
#print "s-1"
#if sub.res_model not in res_model_all_list:
#res_model_all_list.append(sub.res_model)
#elif sub.res_model and sub.res_id:
#print "s-2"
#if res_model_ids_dict.has_key(sub.res_model):
#res_model_ids_dict[sub.res_model].append(sub.res_id)
#else:
#res_model_ids_dict[sub.res_model] = [sub.res_id]
#elif sub.res_model and sub.res_domain:
#print "s-3"
#res_obj = self.pool.get(sub.res_model)
#print sub.res_domain
##res_ids = res_obj.search(cr, uid, [('id', 'in', [1,2])])
#res_ids = res_obj.search(cr, uid, eval(sub.res_domain))
#if res_model_ids_dict.has_key(sub.res_model):
#res_model_ids_dict[sub.res_model] += res_ids
#else:
#res_model_ids_dict[sub.res_model] = res_ids
#print 'cacaprout'
#else:
#print 'erreur !!!'
#print sub
## add fully-followed domains
#args.append('|')
#args.append(['model', 'in', res_model_all_list])
## add partially-followed domains
#for x in range(0, len(res_model_ids_dict.keys())-1):
#args.append('|')
#for res_model in res_model_ids_dict.keys():
#if res_model not in res_model_all_list:
#args.append('&')
#args.append(['model', '=', res_model])
#args.append(['res_id', 'in', res_model_ids_dict[res_model]])
#if context and context.has_key('filter_search'):
#pass
#else:
#args = []
#print args
#return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit,order=order, context=context, count=count)
#------------------------------------------------------
# E-Mail api
#------------------------------------------------------

View File

@ -1,6 +1,60 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- mail.message tree: tweet-type view !-->
<record model="ir.ui.view" id="view_tweet_tree">
<field name="name">mail.message.tree_tweet</field>
<field name="model">mail.message</field>
<field name="type">tree</field>
<field name="sequence">15</field>
<field name="arch" type="xml">
<tree string="Tweets">
<field name="date"/>
<field name="subject"/>
<field name="user_id"/>
<field name="model"/>
<field name="res_id" invisible="1"/>
</tree>
</field>
</record>
<!-- mail.message form: tweet-type view !-->
<record model="ir.ui.view" id="view_tweet_form">
<field name="name">mail.message.form_tweet</field>
<field name="model">mail.message</field>
<field name="type">form</field>
<field name="sequence">15</field>
<field name="arch" type="xml">
<form string="Tweet">
<group colspan="2" col="2">
<field name="subject"/>
<field name="date"/>
<field name="type"/>
<field name="body_text"/>
<field name="need_action_user_id"/>
</group>
<group colspan="2" col="2">
<field name="user_id" string="User" readonly="0"/>
<field name="model"/>
<field name="res_id"/>
</group>
</form>
</field>
</record>
<!-- mail.message search: tweet-type view !-->
<record model="ir.ui.view" id="view_tweet_search">
<field name="name">mail.message.search_tweet</field>
<field name="model">mail.message</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Tweet Search">
<field name="user_id"/>
<field name="model"/>
</search>
</field>
</record>
<record model="ir.ui.view" id="view_email_message_form">
<field name="name">mail.message.form</field>
<field name="model">mail.message</field>
@ -142,6 +196,25 @@
<field name="search_view_id" ref="view_email_message_search"/>
</record>
<record id="action_view_tweets" 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="context">{'filter_search': True, 'tree_view_ref': 'mail.view_tweet_tree', 'form_view_ref': 'mail.view_tweet_form'}</field>
<field name="search_view_id" ref="view_tweet_search"/>
</record>
<record id="action_view_mytweets" 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="context">{'filter_search': True, 'tree_view_ref': 'mail.view_tweet_tree', 'form_view_ref': 'mail.view_tweet_form'}</field>
<field name="search_view_id" ref="view_tweet_search"/>
<field name="domain">[('user_id', '=', uid)]</field>
</record>
<act_window domain="[('partner_id', '=', active_id), ('email_from', '!=', False)]"
context="{'default_partner_id': active_id}"
id="act_res_partner_emails" name="Emails"

View File

@ -61,9 +61,8 @@ class mail_thread(osv.osv):
res[thread.id] = [obj['id'] for obj in records]
return res
# TODO remove this and copy method, this will be replaced by message_load
# OpenSocial: removed message_ids and copy method, this will be replaced by message_load
_columns = {
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', readonly=True),
'message_ids_social': fields.function(_get_message_ids, method=True,
type='one2many', obj='mail.message', string='Temp messages',
),
@ -81,23 +80,12 @@ class mail_thread(osv.osv):
ret_dict[model_name] = model._description
return ret_dict
def copy(self, cr, uid, id, default=None, context=None):
"""Overrides default copy method to empty the thread of
messages attached to this record, as the copied object
will have its own thread and does not have to share it.
"""
if default is None:
default = {}
default.update({
'message_ids': [],
})
return super(mail_thread, self).copy(cr, uid, id, default, context=context)
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,
original=None, context=None):
def message_append(self, cr, uid, threads, subject, body_text=None,
type='email', need_action_user_id=False,
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,
original=None, context=None):
"""Creates a new mail.message attached to the current mail.thread,
containing all the details passed as parameters. All attachments
will be attached to the thread record as well as to the actual
@ -130,7 +118,7 @@ class mail_thread(osv.osv):
to determine the model of the thread to
update (instead of the current model).
"""
if context is None:
if context is None:
context = {}
if attachments is None:
attachments = {}
@ -179,6 +167,7 @@ class mail_thread(osv.osv):
'attachment_ids': [(6, 0, to_attach)],
'state': 'received',
'type': type,
'need_action_user_id': need_action_user_id,
}
if email_from:
@ -227,12 +216,13 @@ 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
# 6.2 OpenSocial 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'),
need_action_user_id = msg_dict.get('need_action_user_id'),
email_to = msg_dict.get('to'),
email_from = msg_dict.get('from'),
email_cc = msg_dict.get('cc'),
@ -250,14 +240,22 @@ class mail_thread(osv.osv):
context = context)
# Message loading
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 """
def message_load_ids(self, cr, uid, ids, context=None):
""" OpenSocial feature added this method
get ids of thread messages
"""
msg_obj = self.pool.get('mail.message')
msg_ids = [msg_obj.search(cr, uid, ['&', ('res_id', '=', id), ('model', '=', self._name)], context=context) for id in ids]
return msg_ids[0]
def message_load(self, cr, uid, ids, context=None):
""" OpenSocial feature added this method
loading message: search in mail.messages where res_id = ids, (res_)model = current model
"""
msg_ids = []
msg_obj = self.pool.get('mail.message')
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, msg_ids)
msgs = msg_obj.read(cr, uid, msg_ids, context=context)
return msgs
@ -507,12 +505,30 @@ class mail_thread(osv.osv):
#------------------------------------------------------
# Note specific
#------------------------------------------------------
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)
def message_append_note(self, cr, uid, ids, subject, body, type='notification', need_action=False,
need_action_user_id=False, context=None):
return self.message_append(cr, uid, ids, subject, body_text=body, type=type, need_action=need_action,
need_action_user_id=need_action_user_id, context=context)
# old log overrided method: now calls message_append_note
def log(self, cr, uid, id, message, secondary=False, context=None):
""" OpenSocial add: new res_log implementation
A res.log is now a mail.message, as all messages in OpenERP
It has a notification type.
It can have a need_action flag attached if an user
has to perform a given action.
See mail.message, mail.subscription and mail.notification for more details.
"""
if context and context.get('disable_log'):
#return True # old behavior
print 'Log diabled, but we do not care currently about that. We want you to have our logs !'
return self.message_append_note(cr, uid, [id], 'System notification', message, context=context)
#------------------------------------------------------
# Subscription mechanism
#------------------------------------------------------
def message_get_subscribers(self, cr, uid, ids, context=None):
subscription_obj = self.pool.get('mail.subscription')
for id in ids:

View File

@ -39,4 +39,6 @@
.oe_mail_msg_p {
padding: 0;
margin: 0;
width: 25%;
word-wrap: break-word;
}

View File

@ -70,9 +70,6 @@ openerp.mail = function(session) {
'record': record,
});
$('<div>').html(render_res).appendTo(self.$element);
// $('<div>').text(record.user_id[1]).appendTo(self.$element);
// $('<div>').text(record.date).appendTo(self.$element);
// $('<div>').text(record.body_text).appendTo(self.$element);
});
// this.timeout = setTimeout(this.proxy('fetch_messages'), 5000);
},

View File

@ -10,28 +10,21 @@
<textarea rows="3" cols="15">Type your comment</textarea><br />
<button type="button" class="oe_mail_action_comment">Post comment</button>
</div>
<div>
<p>
<t t-if="follow_state == 0">00000000</t>
<t t-if="follow_state == 1">11111111</t>
<t t-if="follow_state == '0'">00000000</t>
<t t-if="follow_state == '1'">11111111</t>
<t t-if="this.follow_state == 0">00000000</t>
<t t-if="this.follow_state == 1">11111111</t>
<t t-if="this.follow_state == '0'">00000000</t>
<t t-if="this.follow_state == '1'">11111111</t>
</p>
</div>
</div>
<div t-name="ThreadMsgView">
<div class="oe_mail_msg">
<!-- <p style="border: 3px solid #332299;"> -->
zmeofizepofinzepfoiznepfoizpfozeinfpzoeinfpoznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz ef
<!-- </p> -->
<div class="oe_mail_msg_image">Image</div>
<div class="oe_mail_msg_content">
<p class="oe_mail_msg_p">
<span class="oe_mail_msg_body"><t t-esc="record.body_text"/></span><br />
<span class="oe_mail_msg_author"><t t-esc="record.user_id[1]"/></span><br />
<span class="oe_mail_msg_date"><t t-esc="record.date"/></span>
zmeofizepofinzepfoiznepfoizpfozeinfpzoeinfpoznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz ef
<!-- <t t-raw="record.body_text"/> -->
<!-- <span class="oe_mail_msg_body"><t t-raw="record.body_text"/></span><br /> -->
<!-- <span class="oe_mail_msg_author"><t t-raw="record.user_id[1]"/></span><br /> -->
<!-- <span class="oe_mail_msg_date"><t t-raw="record.date"/></span> -->
</p>
</div>
</div>