[IMP] mail message

bzr revid: fp@tinyerp.com-20120817070218-rp1ssuhwnf8raitf
This commit is contained in:
Fabien Pinckaers 2012-08-17 09:02:18 +02:00
parent 960e4ba541
commit cb944d66ea
10 changed files with 36 additions and 101 deletions

View File

@ -334,7 +334,7 @@ class event_registration(osv.osv):
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
def confirm_registration(self, cr, uid, ids, context=None):
self.message_append(cr, uid, ids,_('State set to open'),body_text= _('Open'))
self.message_append_note(cr, uid, ids, body=_('State set to open'))
return self.write(cr, uid, ids, {'state': 'open'}, context=context)
def create(self, cr, uid, vals, context=None):
@ -364,13 +364,13 @@ class event_registration(osv.osv):
if today >= registration.event_id.date_begin:
values = {'state': 'done', 'date_closed': today}
self.write(cr, uid, ids, values)
self.message_append(cr, uid, ids, _('State set to Done'), body_text=_('Done'))
self.message_append_note(cr, uid, ids, body=_('State set to Done'))
else:
raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") )
return True
def button_reg_cancel(self, cr, uid, ids, context=None, *args):
self.message_append(cr, uid, ids,_('State set to Cancel'),body_text= _('Cancel'))
self.message_append_note(cr, uid, ids,body = _('State set to Cancel'))
return self.write(cr, uid, ids, {'state': 'cancel'})
def mail_user(self, cr, uid, ids, context=None):

View File

@ -12,7 +12,7 @@
<tree string="Followers">
<field name="res_model"/>
<field name="res_id"/>
<field name="user_id"/>
<field name="partner_id"/>
</tree>
</field>
</record>
@ -24,7 +24,7 @@
<field name="priority">10</field>
<field name="arch" type="xml">
<tree string="Notifications">
<field name="user_id"/>
<field name="partner_id"/>
<field name="message_id"/>
</tree>
</field>

View File

@ -36,7 +36,7 @@ class mail_group(osv.Model):
"""
_description = 'Discussion group'
_name = 'mail.group'
_inherit = ['mail.thread','ir.needaction']
_inherit = ['mail.thread','ir.needaction_mixin']
_inherits = {'mail.alias': 'alias_id', 'ir.ui.menu': 'menu_id'}
def _get_image(self, cr, uid, ids, name, args, context=None):
@ -84,7 +84,7 @@ class mail_group(osv.Model):
help="Small-sized photo of the group. It is automatically "\
"resized as a 50x50px image, with aspect ratio preserved. "\
"Use this field anywhere a small image is required."),
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade",
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
help="The email address associated with this group. New emails received will automatically "
"create new topics."),
}

View File

@ -10,7 +10,7 @@
<tree string="Messages">
<field name="date"/>
<field name="subject"/>
<field name="user_id"/>
<field name="author_id"/>
<field name="model"/>
<field name="res_id"/>
</tree>
@ -28,10 +28,9 @@
<group>
<group>
<field name="subject"/>
<field name="user_id"/>
<field name="author_id"/>
<field name="date"/>
<field name="type"/>
<field name="content_subtype"/>
</group>
<group>
<field name="model"/>
@ -40,14 +39,7 @@
<field name="partner_ids" widget="many2many_tags"/>
</group>
</group>
<notebook>
<page string="Body (Rich)">
<field name="body_html"/>
</page>
<page string="Body (Plain)">
<field name="body_text" widget="text"/>
</page>
</notebook>
<field name="body"/>
</sheet>
</form>
</field>
@ -60,9 +52,8 @@
<field name="priority">20</field>
<field name="arch" type="xml">
<search string="Messages Search">
<field name="model" string="Message"/>
<field name="date"/>
<field name="user_id"/>
<field name="body" string="Message"/>
<field name="author_id"/>
</search>
</field>
</record>
@ -76,9 +67,6 @@
<search string="Messages Search">
<field name="subject" string="Content" filter_domain="['|', ('subject', 'ilike', self), ('body', 'ilike', self)]" />
<field name="type"/>
<filter icon="terp-personal+" string="My Feeds"
name="my_feeds" help="My Feeds"
domain="[('user_id','=',uid)]"/>
<filter icon="terp-personal+" string="Comments"
name="comments" help="Comments"
domain="[('type', '=', 'comment')]"/>
@ -88,31 +76,21 @@
<filter icon="terp-personal+" string="Emails"
name="emails" help="Emails"
domain="[('type', '=', 'email')]"/>
<filter icon="terp-go-today" string="Today"
name="today" help="Today"
domain="[ ('date', '&lt;=', datetime.date.today().strftime('%%Y-%%m-%%d 23:59:59')),
('date', '&gt;=', datetime.date.today().strftime('%%Y-%%m-%%d 00:00:00'))
]"/>
<filter icon="terp-go-week" string="This week"
name="7_days" help="This week"
domain="[ ('date', '&lt;=', datetime.date.today().strftime('%%Y-%%m-%%d 23:59:59')),
('date', '&gt;=', (datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d 00:00:00'))
]"/>
<field name="user_id"/>
<field name="author_id"/>
</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>
<field name="name">mail.mail.form</field>
<field name="model">mail.mail</field>
<field name="arch" type="xml">
<form string="Email message" version="7.0">
<sheet>
<label for="subject" class="oe_edit_only"/>
<h2><field name="subject"/></h2>
<div>
by <field name="user_id" class="oe_inline" string="User"/> on <field name="date" class="oe_inline"/>
by <field name="author_id" class="oe_inline" string="User"/> on <field name="date" class="oe_inline"/>
<button name="%(action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
context="{'mail.compose.message.mode':'reply', 'message_id':active_id}" states='received,sent,exception,cancel'/>
</div>
@ -126,17 +104,16 @@
<field name="reply_to"/>
</group>
<group>
<field name="partner_id" readonly="1"/>
<field name="partner_ids" widget="many2many_tags"/>
</group>
</group>
<notebook>
<page string="Body">
<field name="body" widget="text"/>
</page>
<page string="Body (Rich)">
<field name="body_html"/>
</page>
<page string="Body (Plain)">
<field name="body_text" widget="text"/>
</page>
</notebook>
</page>
<page string="Advanced" groups="base.group_no_one">
@ -153,7 +130,6 @@
<group>
<field name="message_id"/>
<field name="references"/>
<field name="headers"/>
</group>
</group>
</page>
@ -173,13 +149,11 @@
<tree string="Emails" colors="grey:state in ('sent', 'cancel');blue:state=='outgoing';red:state=='exception';black:state=='received'">
<field name="date"/>
<field name="subject"/>
<field name="email_from"/>
<field name="user_id" string="User"/>
<field name="author_id" string="User"/>
<field name="message_id" invisible="1"/>
<field name="partner_id" invisible="1"/>
<field name="partner_ids" invisible="1"/>
<field name="model" invisible="1"/>
<field name="res_id" invisible="1"/>
<field name="state"/>
<button name="send" string="Send Now" type="object" icon="gtk-media-play" states='outgoing'/>
<button name="mark_outgoing" string="Retry" type="object" icon="gtk-redo" states='exception,cancel'/>
<button name="cancel" string="Cancel" type="object" icon="terp-gtk-stop" states='outgoing'/>
@ -188,8 +162,8 @@
</record>
<record model="ir.ui.view" id="view_email_message_search">
<field name="name">mail.message.search</field>
<field name="model">mail.message</field>
<field name="name">mail.mail.search</field>
<field name="model">mail.mail</field>
<field name="arch" type="xml">
<search string="Email Search">
<field name="email_from" filter_domain="['|' '|',('email_from','ilike',self), ('email_to','ilike',self), ('subject','ilike',self)]" string="Email"/>
@ -203,8 +177,8 @@
<filter icon="terp-camera_test" name="type_comment" string="Comment" domain="[('type','=','comment')]"/>
<filter icon="terp-camera_test" name="type_notification" string="Notification" domain="[('type','=','notification')]"/>
<group expand="0" string="Extended Filters...">
<field name="user_id" string="User"/>
<field name="partner_id" string="Partner Name"/>
<field name="author_id"/>
<field name="partner_ids"/>
<field name="model"/>
<field name="res_id"/>
</group>

View File

@ -835,9 +835,9 @@ class mail_thread(osv.Model):
msg_original = message.as_string() if isinstance(message, Message) \
else message
attachments.append((0, 0, {
'name':'email.msg',
'name':'email.eml',
'datas': base64.b64encode(msg_original),
'datas_fname': 'email.msg',
'datas_fname': 'email.eml',
'res_model': 'mail.message',
'description': _('original email'),
}))

View File

@ -45,5 +45,8 @@ class res_partner_mail(osv.Model):
help="Choose in which case you want to receive an email when you "\
"receive new feeds."),
}
_defaults = {
'notification_email_pref': lambda *args: 'comment'
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -45,7 +45,6 @@ class res_users(osv.Model):
}
_defaults = {
'notification_email_pref': 'to_me',
'alias_domain': False, # always hide alias during creation
}
@ -128,43 +127,6 @@ class res_users(osv.Model):
alias_pool.unlink(cr, uid, alias_ids, context=context)
return res
# --------------------------------------------------
# Wrappers on partner methods for Chatter
# #FIXME: another branch holds a refactoring of mail.thread
# that should help cleaning those wrappers
# --------------------------------------------------
#def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None,
# type='email', email_date=None, parent_id=False,
# content_subtype='plain', state=None,
# partner_ids=None, email_from=False, email_to=False,
# email_cc=None, email_bcc=None, reply_to=None,
# headers=None, message_id=False, references=None,
# attachments=None, original=None, context=None):
# for user in self.browse(cr, uid, threads, context=context):
# user.partner_id.message_append(subject, body_text, body_html, type, email_date, parent_id,
# content_subtype, state, partner_ids, email_from, email_to, email_cc, email_bcc, reply_to,
# headers, message_id, references, attachments, original)
#def message_read(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None,
# limit=100, offset=0, domain=None, context=None):
# for user in self.browse(cr, uid, ids, context=context):
# return user.partner_id.message_read(fetch_ancestors, ancestor_ids, limit, offset, domain)
#def message_search(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None,
# limit=100, offset=0, domain=None, count=False, context=None):
# for user in self.browse(cr, uid, ids, context=context):
# return user.partner_id.message_search(fetch_ancestors, ancestor_ids, limit, offset, domain, count)
#def message_subscribe(self, cr, uid, ids, user_ids = None, context=None):
# for user in self.browse(cr, uid, ids, context=context):
# return user.partner_id.message_subscribe(user_ids)
#def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None):
# for user in self.browse(cr, uid, ids, context=context):
# return user.partner_id.message_unsubscribe(user_ids)
class res_users_mail_group(osv.Model):
""" Update of res.groups class
- if adding/removing users from a group, check mail.groups linked to

View File

@ -116,6 +116,7 @@ class mail_compose_message(osv.TransientModel):
'attachment_ids': fields.many2many('ir.attachment','email_message_send_attachment_rel', 'wizard_id', 'attachment_id', 'Attachments'),
'auto_delete': fields.boolean('Auto Delete', help="Permanently delete emails after sending"),
'filter_id': fields.many2one('ir.filters', 'Filters'),
'body_html': fields.html('HTML Editor Body'),
}
def get_value(self, cr, uid, model, res_id, context=None):

View File

@ -9,18 +9,14 @@
<group>
<field name="model" invisible="1"/>
<field name="res_id" invisible="1"/>
<field name='filter_id' invisible="context.get('active_model',False)"/>
<field name="email_from" required="1"/>
<field name="email_to" required="1"/>
<field name="email_cc"/>
<field name="reply_to"/>
<field name="author_id"/>
<field name="partner_ids"/>
<field name="subject" widget="char" size="512"/>
<field name="references"/>
<field name="message_id"/>
</group>
<notebook colspan="4">
<page string="Body">
<field name="body_text" colspan="4" nolabel="1" height="300" width="300"/>
<field name="body" colspan="4" nolabel="1" height="300" width="300"/>
</page>
<page string="Attachments">
<field name="attachment_ids" colspan="4" nolabel="1"/>
@ -44,7 +40,7 @@
<group>
<field name="subject" colspan="2" nolabel="1" placeholder="Subject..."
class="oe_mail_compose_message_subject oe_mail_compose_message_invisible"/>
<field name="body_text" colspan="2" nolabel="1" placeholder="What are you working on ?"
<field name="body" colspan="2" nolabel="1" placeholder="What are you working on ?"
class="oe_mail_compose_message_body_text"/>
<field name="body_html" colspan="2" nolabel="1" placeholder="What are you working on HTML ?"
class="oe_mail_compose_message_body_html oe_mail_compose_message_invisible"/>

View File

@ -108,8 +108,7 @@ class plugin_handler(osv.osv_memory):
else:
if model == 'res.partner':
model_obj = self.pool.get('mail.thread')
res = self.pool.get(model).browse(cr, uid, [res_id])
model_obj.message_append_dict(cr, uid, res, msg)
model_obj.message_append_note(cr, uid, [res_id], body=msg)
notify = "Mail succefully pushed"
url = self._make_url(cr, uid, res_id, model)