Pankita Shah(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-compose-message-shp
into lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.
Requested reviews:
Atul Patel(OpenERP) (atp-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-compose-message-shp/+merge/118557
Hello,
i set image as per comment and add many2many field in mail_extra.
thanks
shp
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-compose-message-shp/+merge/118557
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.
=== removed file '.bzrignore'
--- .bzrignore 2012-07-21 19:34:59 +0000
+++ .bzrignore 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-.*
=== modified file 'mail/static/src/js/mail.js'
--- mail/static/src/js/mail.js 2012-08-06 06:10:04 +0000
+++ mail/static/src/js/mail.js 2012-08-07 13:34:08 +0000
@@ -293,6 +293,7 @@
* reply mode
*/
init: function(parent, params) {
+ console.log("====init method is calles =====")
var self = this;
this._super(parent);
// options
@@ -337,6 +338,7 @@
* Widget start function
* - builds and initializes the form view */
start: function() {
+ console.log("=====start method called =====")
var self = this;
this._super.apply(this, arguments);
// customize display: add avatar, clean previous content
@@ -610,6 +612,8 @@
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply', 'click', function (event) {
var act_dom = $(this).parents('div.oe_mail_thread_display').find('div.oe_mail_thread_action:first');
+ console.log("============")
+ console.log(act_dom)
act_dom.toggle();
event.preventDefault();
});
@@ -1164,7 +1168,7 @@
var records = self.comments_structure.tree_struct[root_id]['for_thread_msgs'];
var model_name = self.comments_structure.msgs[root_id]['model'];
var res_id = self.comments_structure.msgs[root_id]['res_id'];
- var render_res = session.web.qweb.render('mail.wall_thread_container', {});
+ var render_res = session.web.qweb.render('mail.Wall_thread_container', {});
$('<li class="oe_mail_wall_thread">').html(render_res).appendTo(self.$element.find('ul.oe_mail_wall_threads'));
var thread = new mail.Thread(self, {
'res_model': model_name, 'res_id': res_id, 'uid': self.session.uid, 'records': records,
=== modified file 'mail/static/src/xml/mail.xml'
--- mail/static/src/xml/mail.xml 2012-08-06 05:59:42 +0000
+++ mail/static/src/xml/mail.xml 2012-08-07 13:34:08 +0000
@@ -45,7 +45,7 @@
wall_thread_container template for the wall
Each discussion thread is contained inside this template
-->
- <t t-name="mail.wall_thread_container">
+ <t t-name="mail.Wall_thread_container">
</t>
<!--
=== modified file 'mail/wizard/mail_compose_message.py'
--- mail/wizard/mail_compose_message.py 2012-08-06 05:36:51 +0000
+++ mail/wizard/mail_compose_message.py 2012-08-07 13:34:08 +0000
@@ -236,6 +236,7 @@
return result
def send_mail(self, cr, uid, ids, context=None):
+ print "======send method calles ======="
'''Process the wizard contents and proceed with sending the corresponding
email(s), rendering any template patterns on the fly if needed.
If the wizard is in mass-mail mode (context['mail.compose.message.mode'] is
=== modified file 'mail/wizard/mail_compose_message_view.xml'
--- mail/wizard/mail_compose_message_view.xml 2012-07-20 12:56:23 +0000
+++ mail/wizard/mail_compose_message_view.xml 2012-08-07 13:34:08 +0000
@@ -44,7 +44,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Compose Email" version="7.0" >
- <group>
+ <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 ?"
@@ -54,11 +54,12 @@
<field name="dest_partner_ids" colspan="2" nolabel="1" widget="many2many_tags"
placeholder="Add contacts to notify..."
class="oe_mail_compose_message_partner_ids oe_mail_compose_message_invisible"/>
- <div>
+ <div class='oe_mail_compose_message_post'>
<button name="send_mail" string="Post" type="object"
class="oe_mail_compose_message_button_send"/>
or <a href="#" class="oe_mail_compose_message_email">Send an Email</a>
</div>
+ <newline/>
<div class='oe_mail_compose_message_icons'>
<!-- <button icon="../../../../../mail/static/src/img/checklist"
type="object" name="checklist" string=""
=== modified file 'mail_extra/__openerp__.py'
--- mail_extra/__openerp__.py 2012-07-12 05:25:52 +0000
+++ mail_extra/__openerp__.py 2012-08-07 13:34:08 +0000
@@ -42,6 +42,7 @@
],
'data': [
'security/ir.model.access.csv',
+ 'mail_checklist_view.xml'
],
'css': [
"static/src/css/mail_extra.css",
=== modified file 'mail_extra/mail_checklist.py'
--- mail_extra/mail_checklist.py 2012-08-06 06:30:44 +0000
+++ mail_extra/mail_checklist.py 2012-08-07 13:34:08 +0000
@@ -33,9 +33,9 @@
done : True If Item checked otherwise False.
'''
_columns = {
- 'msg_id': fields.many2one('mail.message', 'Message'),
+ 'msg_id': fields.many2one('mail.message', 'Message',readonly="1"),
'name': fields.char('Item Name', size=128, required=True, help='Checklist Item Name.'),
- 'done': fields.boolean('Done', help="When Item is done then check it."),
+ 'done': fields.boolean('Done', help="When Item is done then check it.",readonly="1"),
'user_id': fields.many2one('res.users', 'Related user', readonly=1),
}
@@ -67,6 +67,7 @@
'checklist_item_ids': fields.one2many('mail.checklist.item', 'msg_id', 'CheckItems'),
}
mail_message()
+
class mail_compose_message(osv.TransientModel):
_inherit = 'mail.compose.message'
def add_checklist_item(self, cr, uid, msg_id, item_names, context=None):
@@ -97,6 +98,49 @@
img_checklist = "<img height='12px' width='16px' src='/mail_extra/static/src/img/checklist.png'/>"
res[key]['message_summary'] += " . <span> %s %d/%d</span>"% (img_checklist,total_done_items,total_items)
return res
+ def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None,
+ type=type, 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, checklist=None, original=None, context=None):
+ res = super(mail_thread, self).message_append(cr, uid, threads, subject, body_text=None, body_html=None,
+ type=type, email_date=email_date, parent_id=parent_id,
+ content_subtype=content_subtype, state=state,
+ partner_ids=partner_ids, email_from=email_from, email_to=email_to,
+ email_cc=email_cc, email_bcc=email_bcc, reply_to=reply_to,
+ headers=None, message_id=message_id, references=references,
+ attachments=attachments, original=original, context=context)
+ if context is None:
+ context = {}
+ if checklist is None:
+ checklist = {}
+
+ ir_attachment = self.pool.get('ir.attachment')
+ data ={}
+ mail_message = self.pool.get('mail.message')
+ if all(isinstance(thread_id, (int, long)) for thread_id in threads):
+ model = context.get('thread_model') or self._name
+ model_pool = self.pool.get(model)
+ threads = model_pool.browse(cr, uid, threads, context=context)
+
+ for thread in threads:
+ checklist_pool = self.pool.get('mail.checklist.item')
+ mail_message_pool = self.pool.get('mail.message')
+ for thread in threads:
+ to_checklist = []
+ if checklist:
+ for item in checklist:
+ data_items = {
+ 'name': item,
+ 'user_id': uid,
+ 'msg_id': res[0],
+ }
+ to_checklist.append(checklist_pool.create(cr, uid, data_items, context=context))
+ data.update({'checklist_item_ids': [(6, 0, to_checklist)]})
+ mail_message_pool.write(cr, uid, res,data)
+ return res
_columns = {
'message_summary': fields.function(_get_message_ids, method=True,
@@ -107,3 +151,114 @@
}
mail_thread()
+
+
+class mail_compose_message(osv.Model):
+
+ def add_compose_checklist_item(self, cr, uid, ids, checklist_items, context=None):
+ to_checklist = []
+ mail_item = self.pool.get('mail.checklist.item')
+ for item in checklist_items:
+ new_checklist_id = mail_item.create(cr, uid, {'user_id':uid, 'name' : item}, context=context)
+ to_checklist.append(new_checklist_id)
+ return to_checklist
+
+ def send_mail(self, cr, uid, ids, context=None):
+ res = super(mail_compose_message,self).send_mail(cr, uid, ids, context=context)
+ self.write(cr, uid, ids, {'checklist_ids': [(6,0, context.get('checklist_items'))]})
+ # composition wizard options
+ msg_list_ids = []
+ email_mode = context.get('email_mode')
+ formatting = context.get('formatting')
+ mass_mail_mode = context.get('mail.compose.message.mode') == 'mass_mail'
+ mail_message_obj = self.pool.get('mail.message')
+ for mail_wiz in self.browse(cr, uid, ids, context=context):
+ # Checklist Itemsss
+ checklist = {}
+ for items in mail_wiz.checklist_ids:
+ checklist[items.name] = items.name
+ # checklist[uid] = uid
+ # attachments
+ attachment = {}
+ for attach in mail_wiz.attachment_ids:
+ attachment[attach.datas_fname] = attach.datas and attach.datas.decode('base64')
+ # default values, according to the wizard options
+ subject = mail_wiz.subject if formatting else False
+ content_subtype = 'html' if formatting else 'plain'
+ type = 'email' if email_mode else 'comment'
+ state = 'outgoing' if email_mode else False
+ partner_ids = [partner.id for partner in mail_wiz.dest_partner_ids]
+ references = None
+ headers = {}
+ body = mail_wiz.body_html if content_subtype == 'html' else mail_wiz.body_text
+
+ # get model, active_ids, and check if model is openchatter-enabled
+ if mass_mail_mode and context.get('active_ids') and context.get('active_model'):
+ active_ids = context['active_ids']
+ active_model = context['active_model']
+ elif mass_mail_mode:
+ active_model = mail_wiz.model
+ active_model_pool = self.pool.get(active_model)
+ active_ids = active_model_pool.search(cr, uid, ast.literal_eval(mail_wiz.filter_id.domain), context=ast.literal_eval(mail_wiz.filter_id.context))
+ else:
+ active_model = mail_wiz.model
+ active_ids = [mail_wiz.res_id]
+ active_model_pool = self.pool.get(active_model)
+ mail_thread_enabled = hasattr(active_model_pool, 'message_append')
+
+ if context.get('mail.compose.message.mode') == 'mass_mail':
+
+ # Mass mailing: must render the template patterns
+ for active_id in active_ids:
+ rendered_subject = self.render_template(cr, uid, subject, active_model, active_id)
+ rendered_body_html = self.render_template(cr, uid, mail_wiz.body_html, active_model, active_id)
+ rendered_body_text = self.render_template(cr, uid, mail_wiz.body_text, active_model, active_id)
+ email_from = self.render_template(cr, uid, mail_wiz.email_from, active_model, active_id)
+ email_to = self.render_template(cr, uid, mail_wiz.email_to, active_model, active_id)
+ email_cc = self.render_template(cr, uid, mail_wiz.email_cc, active_model, active_id)
+ email_bcc = self.render_template(cr, uid, mail_wiz.email_bcc, active_model, active_id)
+ reply_to = self.render_template(cr, uid, mail_wiz.reply_to, active_model, active_id)
+
+ # in mass-mailing mode we only schedule the mail for sending, it will be
+ # processed as soon as the mail scheduler runs.
+ if mail_thread_enabled:
+ active_model_pool.message_append(cr, uid, [active_id], rendered_subject, rendered_body_text, rendered_body_html,
+ type=type, content_subtype=content_subtype, state=state, partner_ids=partner_ids,
+ email_from=email_from, email_to=email_to, email_cc=email_cc, email_bcc=email_bcc,
+ reply_to=reply_to, references=references, attachments=attachment, checklist=checklist, headers=headers, context=context)
+ else:
+ mail_message_obj.schedule_with_attach(cr, uid, email_from, to_email(email_to), subject, rendered_body_text,
+ model=mail_wiz.model, email_cc=to_email(email_cc), email_bcc=to_email(email_bcc), reply_to=reply_to,
+ attachments=attachment, checklist=checklist, references=references, res_id=active_id, partner_ids=partner_ids,
+ content_subtype=mail_wiz.content_subtype, headers=headers, context=context)
+ else:
+ # normal mode - no mass-mailing
+ if mail_thread_enabled:
+ msg_ids = active_model_pool.message_append(cr, uid, active_ids, subject, mail_wiz.body_text, mail_wiz.body_html,
+ type=type, content_subtype=content_subtype, state=state, partner_ids=partner_ids,
+ email_from=mail_wiz.email_from, email_to=mail_wiz.email_to, email_cc=mail_wiz.email_cc, email_bcc=mail_wiz.email_bcc,
+ reply_to=mail_wiz.reply_to, references=references, attachments=attachment, checklist=checklist, headers=headers, context=context)
+ else:
+ msg_ids = [mail_message_obj.schedule_with_attach(cr, uid, mail_wiz.email_from, to_email(mail_wiz.email_to), subject, mail_wiz.body_text,
+ type=type, model=mail_wiz.model, email_cc=to_email(mail_wiz.email_cc), email_bcc=to_email(mail_wiz.email_bcc), reply_to=mail_wiz.reply_to,
+ attachments=attachment, checklist=checklist, references=references, res_id=int(mail_wiz.res_id), partner_ids=partner_ids,
+ content_subtype=mail_wiz.content_subtype, headers=headers, context=context)]
+ # in normal mode, we send the email immediately, as the user expects us to (delay should be sufficiently small)
+ msg_list_ids += msg_ids
+ if type == 'comment':
+ return {'type': 'ir.actions.act_window_close', 'msg_ids': msg_list_ids}
+
+ return res
+
+ _inherit = 'mail.compose.message'
+ _columns= {
+ 'checklist_ids': fields.many2many('mail.checklist.item','mail_checklist_rel', 'compose_ids', 'checklist_id','checklist'),
+ }
+
+mail_compose_message()
+
+class res_users(osv.Model):
+ _name = 'res.users'
+ _inherit = ['res.users', 'mail.thread']
+
+
=== added file 'mail_extra/mail_checklist_view.xml'
--- mail_extra/mail_checklist_view.xml 1970-01-01 00:00:00 +0000
+++ mail_extra/mail_checklist_view.xml 2012-08-07 13:34:08 +0000
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record model="ir.ui.view" id="mail_compose_view_inherit">
+ <field name="name">mail.compose.message.inherit</field>
+ <field name="model">mail.compose.message</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="mail.email_compose_message_wizard_form_chatter"/>
+ <field name="arch" type="xml">
+ <xpath expr="//div[@class='oe_mail_compose_message_post']" position="before">
+ <field name="checklist_ids" colspan="4" nolabel="1" widget="many2many_tags" class="oe_edit_only"/>
+ </xpath>
+ </field>
+ </record>
+ </data>
+</openerp>
=== modified file 'mail_extra/static/src/js/mail_extra.js'
--- mail_extra/static/src/js/mail_extra.js 2012-07-20 11:41:56 +0000
+++ mail_extra/static/src/js/mail_extra.js 2012-08-07 13:34:08 +0000
@@ -6,6 +6,24 @@
bind_events: function() {
var self = this;
this._super(this)
+ this.$element.find('button.oe_form_button').click(function (event) {
+ check_items = []
+ var text_items = $('input[type=text]');
+ _(text_items).each(function(item){
+ item_value = $(item).val();
+ if (item_value != "" && item_value != 'http://'){
+ check_items.push(item_value);
+ }
+
+ $(item).val('');
+ });
+ mail_compose_message = new session.web.DataSet(this, 'mail.compose.message', self.ds_compose.context);
+ var call_done = mail_compose_message.call('add_compose_checklist_item', [[],check_items]).then(function (result) {
+ self.ds_compose.context.checklist_items = result;
+
+ });
+ });
+
this.render_default_checklist_item(self);
var lastElement = this.$element.find('input[type=text]:last');
$('a.oe_add_more_item').click(function (event) {
@@ -41,9 +59,10 @@
check_items.push(item_value);
}
$(item).val('');
- });
+ });
return check_items
},
+
calculate_checklist_progress: function(items){
if (items.length == 0) return 0;
total_checklist_items = items.length;
@@ -70,6 +89,7 @@
},
});
+
session.mail.Thread.include({
display_comments: function(records){
=== modified file 'mail_extra/static/src/xml/mail_extra.xml'
--- mail_extra/static/src/xml/mail_extra.xml 2012-07-20 10:40:15 +0000
+++ mail_extra/static/src/xml/mail_extra.xml 2012-08-07 13:34:08 +0000
@@ -1,7 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
+
+
+ <!-- FOR ADD CHECKLIST ITEMS IN FEEDS(WALL) -->
+ <t t-extend="mail.compose_message">
+ <div t-jquery="oe_mail_msg_content" t-operation="append">
+ <t t-jquery="textarea.oe_mail_wall_action_textarea" t-operation="after">
+ <t t-name = "AddChecklist_wall">
+ <div class="oe_wall_checklist_item">
+ <a class="oe_checklist_item" title="Add one more item.">Add More Items</a>
+ </div>
+ </t>
+ </t>
+ </div>
+ <t t-jquery="a.oe_attach" t-operation="append">
+ <a class="oe_checklist_wall oe_right">
+ <img t-att-src='_s + "/mail_extra/static/src/img/checklist.png"' class="oe_checklist_icon"/>
+ <span title="Hide and show checklist Items">Checklist</span>
+ </a>
+ </t>
+ </t>
+
+ <!-- FOR ADD CHECKLIST ITEMS IN DOCUMENTS(THREAD) -->
+
+ <t t-extend="mail.Thread">
+ <t t-jquery=".oe_mail_action_textarea" t-operation="after">
+ <t t-name = "AddChecklist_thread">
+ <div class="oe_thread_checklist_item">
+ <a class="oe_checklist_item" title="Add one more item.">Add More Items</a>
+ </div>
+ </t>
+ </t>
+ <t t-jquery="a.oe_attach" t-operation="append">
+ <a class="oe_checklist_thread oe_right">
+ <img t-att-src='_s + "/mail_extra/static/src/img/checklist.png"' class="oe_checklist_icon"/>
+ <span title="Hide and show checklist Items">Checklist</span>
+ </a>
+ </t>
+ </t>
+
+
<t t-extend="mail.thread.message">
+
<t t-jquery=".oe_mail_msg_body" t-operation="append">
<div t-att-data-id="record.id" class="oe_mail_msg_checklist">
</div>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp