summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2012-07-02 16:46:54 +0200
committerThibault Delavallée <tde@openerp.com>2012-07-02 16:46:54 +0200
commit8fea9baa91c118fe07a7be235134c0faec3e7cd2 (patch)
treedca48dcb4a48dd31da1b5ed5934045e67e0f3a9a
parentc8da73626e2340f7f4215b36c7e2b9ff11bb1948 (diff)
parent0c86af17ab90c580106aec65d195a91b8710e75e (diff)
[MERGE] Merged branch some fixes and clean for chatter/share.Mail
- subject is not required anymore, leading to a better-looking Wall/Chatter - defined a name_get because subject could be void Mail group - cleaned form view Mail compose message - cleaned the current form view Share - moved links to the More menu - cleaned various views of the wizard - fixed link send in the email for direct login Invite - cleaned style - better integration with Portal option Fetchmail - fixed a bug due to a wrongly named variable (logger) CRM - lead view: chatter in a footer Chatter - use expander plugin for read more/read less. bzr revid: tde@openerp.com-20120702144654-y9zt3vsh9dwje1rn
-rw-r--r--addons/crm/crm_lead_view.xml4
-rw-r--r--addons/fetchmail/fetchmail.py12
-rw-r--r--addons/mail/__openerp__.py1
-rw-r--r--addons/mail/mail_group_view.xml46
-rw-r--r--addons/mail/mail_message.py17
-rw-r--r--addons/mail/mail_thread.py9
-rw-r--r--addons/mail/static/src/css/mail.css4
-rw-r--r--addons/mail/static/src/css/mail_group.css43
-rw-r--r--addons/mail/static/src/js/jquery.expander.min.js24
-rw-r--r--addons/mail/static/src/js/mail.js31
-rw-r--r--addons/mail/static/src/xml/mail.xml5
-rw-r--r--addons/mail/wizard/mail_compose_message_view.xml18
-rw-r--r--addons/portal/wizard/share_wizard.py2
-rw-r--r--addons/portal/wizard/share_wizard_view.xml10
-rw-r--r--addons/share/static/src/css/share.css7
-rw-r--r--addons/share/static/src/js/share.js58
-rw-r--r--addons/share/static/src/xml/share.xml13
-rw-r--r--addons/share/wizard/share_wizard.py16
-rw-r--r--addons/share/wizard/share_wizard_view.xml32
19 files changed, 203 insertions, 149 deletions
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index a2f3c30c611..7476e709d6b 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -172,9 +172,9 @@
</page>
</notebook>
</sheet>
- <div class="oe_bottom">
+ <footer>
<field name="message_ids" widget="ThreadView"/>
- </div>
+ </footer>
</form>
</field>
</record>
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index cddcf642dc4..55923c3043a 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -151,7 +151,7 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS
connection = server.connect()
server.write({'state':'done'})
except Exception, e:
- logger.exception("Failed to connect to %s server %s", server.type, server.name)
+ _logger.exception("Failed to connect to %s server %s", server.type, server.name)
raise osv.except_osv(_("Connection test failed!"), _("Here is what we got instead:\n %s") % tools.ustr(e))
finally:
try:
@@ -177,7 +177,7 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS
mail_thread = self.pool.get('mail.thread')
action_pool = self.pool.get('ir.actions.server')
for server in self.browse(cr, uid, ids, context=context):
- logger.info('start checking for new emails on %s server %s', server.type, server.name)
+ _logger.info('start checking for new emails on %s server %s', server.type, server.name)
context.update({'fetchmail_server_id': server.id, 'server_type': server.type})
count = 0
imap_server = False
@@ -198,9 +198,9 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS
imap_server.store(num, '+FLAGS', '\\Seen')
cr.commit()
count += 1
- logger.info("fetched/processed %s email(s) on %s server %s", count, server.type, server.name)
+ _logger.info("fetched/processed %s email(s) on %s server %s", count, server.type, server.name)
except Exception, e:
- logger.exception("Failed to fetch mail from %s server %s", server.type, server.name)
+ _logger.exception("Failed to fetch mail from %s server %s", server.type, server.name)
finally:
if imap_server:
imap_server.close()
@@ -222,9 +222,9 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
pop_server.dele(num)
cr.commit()
- logger.info("fetched/processed %s email(s) on %s server %s", numMsgs, server.type, server.name)
+ _logger.info("fetched/processed %s email(s) on %s server %s", numMsgs, server.type, server.name)
except Exception, e:
- logger.exception("Failed to fetch mail from %s server %s", server.type, server.name)
+ _logger.exception("Failed to fetch mail from %s server %s", server.type, server.name)
finally:
if pop_server:
pop_server.quit()
diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py
index 95ce7d5619d..8ba3c02b0b3 100644
--- a/addons/mail/__openerp__.py
+++ b/addons/mail/__openerp__.py
@@ -86,6 +86,7 @@ The main features are:
'static/src/css/mail_group.css',
],
'js': [
+ 'static/src/js/jquery.expander.min.js',
'static/src/js/mail.js',
],
'qweb': [
diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml
index 921c3b528c4..4b9cfd09c3d 100644
--- a/addons/mail/mail_group_view.xml
+++ b/addons/mail/mail_group_view.xml
@@ -51,28 +51,30 @@
<field name="priority" eval="10"/>
<field name="arch" type="xml">
<form string="Group Form" version="7.0">
- <div style="padding: 8px">
- <div class="oe_right">
- <field name="photo" widget='image' on_change="onchange_photo(photo)"/>
- </div>
- <div class="oe_title">
- <div class="oe_edit_only">
- <label for="name"/>
- </div>
- <h1><field name="name"/></h1>
- <div class="oe_edit_only">
- <label for="responsible_id"/>
- </div>
- <field name="responsible_id" class="oe_inline"/>
- <div class="oe_edit_only">
- <label for="public"/>
- <field name="public" class="oe_inline"/>
- </div>
- <field name="description" colspan="4" nolabel="1"/>
- </div>
- </div>
- <footer>
- <field name="message_ids" colspan="4" widget="ThreadView" options='{"thread_level": 1}'/>
+ <sheet class="openerp_mail_group_sheet">
+ <group colspan="4" col="8">
+ <group colspan="1" col="2">
+ <field name="photo" widget='image' nolabel="1" on_change="onchange_photo(photo)"/>
+ </group>
+ <group colspan="7" col="6">
+ <div class="oe_edit_only">
+ <label for="name"/>
+ </div>
+ <h2><field name="name" colspan="4"/></h2>
+ <newline/>
+ <group colspan="4" col="4">
+ <field name="description" colspan="4" nolabel="1"/>
+ </group>
+ <group colspan="2" col="2" class="oe_edit_only">
+ <field name="responsible_id" colspan="2"/>
+ <field name="public" colspan="2"/>
+ </group>
+ </group>
+ </group>
+ </sheet>
+ <footer class="openerp_mail_group_footer">
+ <field name="message_ids" widget="ThreadView"
+ options='{"thread_level": 1}'/>
</footer>
</form>
</field>
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index 1c1e980e3ed..301657ba4c2 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -96,11 +96,24 @@ class mail_message_common(osv.osv_memory):
continue
result[message.id] = self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]
return result
-
+
+ def name_get(self, cr, uid, ids, context=None):
+ res = []
+ for message in self.browse(cr, uid, ids, context=context):
+ name = ''
+ if message.subject:
+ name = '%s: ' % (message.subject)
+ if message.body_text:
+ name = '%s%s ' % (name, message.body_text[0:20])
+ if message.date:
+ name = '%s(%s)' % (name, message.date)
+ res.append((message.id, name))
+ return res
+
_name = 'mail.message.common'
_rec_name = 'subject'
_columns = {
- 'subject': fields.char('Subject', size=512, required=True),
+ 'subject': fields.char('Subject', size=512),
'model': fields.char('Related Document Model', size=128, select=1),
'res_id': fields.integer('Related Document ID', select=1),
'record_name': fields.function(get_record_name, type='string', string='Message Record Name',
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index e0f2bfaf455..d0af1ed8841 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -746,13 +746,8 @@ class mail_thread(osv.osv):
self.message_append_note(cr, uid, [id], 'res.log', message, context=context)
def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, type='notification', subtype='html', context=None):
- if subject is None:
- if type == 'notification':
- subject = _('System notification')
- elif type == 'comment' and not parent_id:
- subject = _('Comment')
- elif type == 'comment' and parent_id:
- subject = _('Reply')
+ if type in ['notification', 'reply']:
+ subject = None
if subtype == 'html':
body_html = body
body_text = body
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 2421b28fbcb..0cf932f9a25 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -314,8 +314,8 @@
text-align: justify;
}
-.openerp .oe_mail_msg_tail {
- display: none;
+.openerp .oe_mail_msg_body span.oe_mail_msg_tail {
+ display: inline;
}
/* Read more/less link */
diff --git a/addons/mail/static/src/css/mail_group.css b/addons/mail/static/src/css/mail_group.css
index 90261499753..048b7a06415 100644
--- a/addons/mail/static/src/css/mail_group.css
+++ b/addons/mail/static/src/css/mail_group.css
@@ -1,3 +1,40 @@
+/* ------------------------------ */
+/* Group Form */
+/* ------------------------------ */
+
+/* Resize sheet width */
+.openerp .oe_form_sheetbg.openerp_mail_group_sheet {
+ min-height: 0px;
+ max-height: none;
+}
+
+.openerp .oe_form_sheetbg.openerp_mail_group_sheet .oe_form_sheet {
+ min-height: 0px;
+ max-height: none;
+ padding: 0px 18px;
+ max-width: 80%;
+}
+
+/* Resize footer width */
+.openerp .oe_form footer.openerp_mail_group_footer {
+ max-width: 80%;
+}
+
+/* Resize group logo */
+.openerp .oe_form_sheetbg.openerp_mail_group_sheet .oe_form_field_image > img {
+ max-width: 100px;
+ max-height: 100px;
+}
+
+/* Resize group description */
+.openerp .oe_form_sheetbg.openerp_mail_group_sheet .oe_form_field_text > textarea {
+ height: 40px;
+}
+
+/* ------------------------------ */
+/* Group Kanban */
+/* ------------------------------ */
+
.oe_group_vignette {
padding: 8px 0;
min-height: 100px;
@@ -71,9 +108,3 @@
.oe_group_details li {
margin: 2px 0;
}
-
-.oe_group_description {
-}
-
-.oe_kanban_record div.true {
-}
diff --git a/addons/mail/static/src/js/jquery.expander.min.js b/addons/mail/static/src/js/jquery.expander.min.js
new file mode 100644
index 00000000000..2c61251fcf0
--- /dev/null
+++ b/addons/mail/static/src/js/jquery.expander.min.js
@@ -0,0 +1,24 @@
+/*!
+ * jQuery Expander Plugin v1.4.2
+ *
+ * Date: Sat Mar 31 20:51:48 2012 EDT
+ * Requires: jQuery v1.3+
+ *
+ * Copyright 2011, Karl Swedberg
+ * Dual licensed under the MIT and GPL licenses (just like jQuery):
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ *
+ *
+ *
+*/
+(function(c){c.expander={version:"1.4.2",defaults:{slicePoint:100,preserveWords:true,widow:4,expandText:"read more",expandPrefix:"&hellip; ",expandAfterSummary:false,summaryClass:"summary",detailClass:"details",moreClass:"read-more",lessClass:"read-less",collapseTimer:0,expandEffect:"slideDown",expandSpeed:250,collapseEffect:"slideUp",collapseSpeed:200,userCollapse:true,userCollapseText:"read less",userCollapsePrefix:" ",onSlice:null,beforeExpand:null,afterExpand:null,onCollapse:null}};c.fn.expander=
+function(l){function J(a,d){var g="span",h=a.summary;if(d){g="div";if(x.test(h)&&!a.expandAfterSummary)h=h.replace(x,a.moreLabel+"$1");else h+=a.moreLabel;h='<div class="'+a.summaryClass+'">'+h+"</div>"}else h+=a.moreLabel;return[h,"<",g+' class="'+a.detailClass+'"',">",a.details,"</"+g+">"].join("")}function K(a){var d='<span class="'+a.moreClass+'">'+a.expandPrefix;d+='<a href="#">'+a.expandText+"</a></span>";return d}function y(a,d){if(a.lastIndexOf("<")>a.lastIndexOf(">"))a=a.slice(0,a.lastIndexOf("<"));
+if(d)a=a.replace(L,"");return c.trim(a)}function z(a,d){d.stop(true,true)[a.collapseEffect](a.collapseSpeed,function(){d.prev("span."+a.moreClass).show().length||d.parent().children("div."+a.summaryClass).show().find("span."+a.moreClass).show()})}function M(a,d,g){if(a.collapseTimer)A=setTimeout(function(){z(a,d);c.isFunction(a.onCollapse)&&a.onCollapse.call(g,false)},a.collapseTimer)}var v="init";if(typeof l=="string"){v=l;l={}}var o=c.extend({},c.expander.defaults,l),N=/^<(?:area|br|col|embed|hr|img|input|link|meta|param).*>$/i,
+L=o.wordEnd||/(&(?:[^;]+;)?|[a-zA-Z\u00C0-\u0100]+)$/,B=/<\/?(\w+)[^>]*>/g,C=/<(\w+)[^>]*>/g,D=/<\/(\w+)>/g,x=/(<\/[^>]+>)\s*$/,O=/^<[^>]+>.?/,A;l={init:function(){this.each(function(){var a,d,g,h,m,i,p,w,E=[],t=[],q={},r=this,f=c(this),F=c([]),b=c.meta?c.extend({},o,f.data()):o;i=!!f.find("."+b.detailClass).length;var s=!!f.find("*").filter(function(){return/^block|table|list/.test(c(this).css("display"))}).length,u=(s?"div":"span")+"."+b.detailClass,G="span."+b.moreClass,P=b.expandSpeed||0,n=c.trim(f.html());
+c.trim(f.text());var e=n.slice(0,b.slicePoint);if(!c.data(this,"expander")){c.data(this,"expander",true);c.each(["onSlice","beforeExpand","afterExpand","onCollapse"],function(j,k){q[k]=c.isFunction(b[k])});e=y(e);for(d=e.replace(B,"").length;d<b.slicePoint;){a=n.charAt(e.length);if(a=="<")a=n.slice(e.length).match(O)[0];e+=a;d++}e=y(e,b.preserveWords);h=e.match(C)||[];m=e.match(D)||[];g=[];c.each(h,function(j,k){N.test(k)||g.push(k)});h=g;d=m.length;for(a=0;a<d;a++)m[a]=m[a].replace(D,"$1");c.each(h,
+function(j,k){var H=k.replace(C,"$1"),I=c.inArray(H,m);if(I===-1){E.push(k);t.push("</"+H+">")}else m.splice(I,1)});t.reverse();if(i){i=f.find(u).remove().html();e=f.html();n=e+i;a=""}else{i=n.slice(e.length);a=c.trim(i.replace(B,""));if(a===""||a.split(/\s+/).length<b.widow)return;a=t.pop()||"";e+=t.join("");i=E.join("")+i}b.moreLabel=f.find(G).length?"":K(b);if(s)i=n;e+=a;b.summary=e;b.details=i;b.lastCloseTag=a;if(q.onSlice)b=(g=b.onSlice.call(r,b))&&g.details?g:b;s=J(b,s);f.html(s);p=f.find(u);
+w=f.find(G);p.hide();w.find("a").unbind("click.expander").bind("click.expander",function(j){j.preventDefault();w.hide();F.hide();q.beforeExpand&&b.beforeExpand.call(r);p.stop(false,true)[b.expandEffect](P,function(){p.css({zoom:""});q.afterExpand&&b.afterExpand.call(r);M(b,p,r)})});F=f.find("div."+b.summaryClass);b.userCollapse&&!f.find("span."+b.lessClass).length&&f.find(u).append('<span class="'+b.lessClass+'">'+b.userCollapsePrefix+'<a href="#">'+b.userCollapseText+"</a></span>");f.find("span."+
+b.lessClass+" a").unbind("click.expander").bind("click.expander",function(j){j.preventDefault();clearTimeout(A);j=c(this).closest(u);z(b,j);q.onCollapse&&b.onCollapse.call(r,true)})}})},destroy:function(){if(this.data("expander")){this.removeData("expander");this.each(function(){var a=c(this),d=c.meta?c.extend({},o,a.data()):o,g=a.find("."+d.detailClass).contents();a.find("."+d.moreClass).remove();a.find("."+d.summaryClass).remove();a.find("."+d.detailClass).after(g).remove();a.find("."+d.lessClass).remove()})}}};
+l[v]&&l[v].call(this);return this};c.fn.expander.defaults=c.expander.defaults})(jQuery);
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 5633a4bdae0..e724a8bcbd0 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -302,17 +302,20 @@ openerp.mail = function(session) {
record.body = this.do_clean_text(record.body);
record.body = this.do_replace_internal_links(record.body);
- // split for see more
- var split = this.do_truncate_string(record.body, this.params.msg_more_limit);
- record.body_head = split[0];
- record.body_tail = split[1];
-
// format date according to the user timezone
record.date = session.web.format_value(record.date, {type:"datetime"});
-
var rendered = session.web.qweb.render('mail.Thread.message', {'record': record, 'thread': this, 'params': this.params, 'display': this.display});
- $( rendered).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
+ $(rendered).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
+ // expand feature
+ this.$element.find('div.oe_mail_msg_body:last').expander({
+ slicePoint: this.params.msg_more_limit,
+ expandText: 'see more',
+ userCollapseText: 'see less',
+ detailClass: 'oe_mail_msg_tail',
+ moreClass: 'oe_mail_expand',
+ lesClass: 'oe_mail_reduce',
+ });
},
/**
@@ -447,20 +450,6 @@ openerp.mail = function(session) {
return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || '');
},
- /**
- * @param {String} string to truncate
- * @param {Number} max number of chars to display
- * @returns {String} truncated string
- */
- do_truncate_string: function(string, max_length) {
- // multiply by 1.2: prevent truncating an just too little long string
- if (string.length <= (max_length * 1.2)) {
- return [string, ""];
- } else {
- return [string.slice(0, max_length), string.slice(max_length)];
- }
- },
-
/** Removes html tags, except b, em, br */
do_clean_text: function (string) {
var html = $('<div/>').text(string.replace(/\s+/g, ' ')).html().replace(new RegExp('&lt;(/)?(b|em|br|br /)\\s*&gt;', 'gi'), '<$1$2>');
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 34445c48f8d..2eb3a390933 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -91,10 +91,7 @@
</div>
<div class="oe_mail_msg_body">
<a href="#" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}' class="oe_mail_internal_link"><t t-raw="record.user_id[1]"/></a>
- <t t-raw="record.body_head"/>
- <t t-if="record.body_tail"><a href="#" class="oe_mail_msg_more">... See more</a>
- <span class="oe_mail_msg_tail"><t t-raw="record.body_tail"/></span>
- </t>
+ <t t-raw="record.body"/>
</div>
<ul class="oe_mail_msg_footer">
<li><span t-att-title="record.date"><t t-raw="record.timerelative"/></span></li>
diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml
index 99eb7192738..3da63fb1adc 100644
--- a/addons/mail/wizard/mail_compose_message_view.xml
+++ b/addons/mail/wizard/mail_compose_message_view.xml
@@ -12,18 +12,18 @@
or
<button string="Cancel" class="oe_link" special="cancel" />
</header>
- <group col="6" colspan="4">
+ <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" colspan="4" required="1"/>
- <field name="email_to" colspan="4" required="1"/>
- <field name="email_cc" colspan="4"/>
- <field name="email_bcc" colspan="4"/>
- <field name="reply_to" colspan="4"/>
- <field name="subject" colspan="4" widget="char" size="512"/>
- <field name="references" invisible="1"/>
- <field name="message_id" invisible="1"/>
+ <field name="email_from" required="1"/>
+ <field name="email_to" required="1"/>
+ <field name="email_cc"/>
+ <field name="email_bcc"/>
+ <field name="reply_to"/>
+ <field name="subject" widget="char" size="512"/>
+ <field name="references"/>
+ <field name="message_id"/>
</group>
<notebook colspan="4">
<page string="Body">
diff --git a/addons/portal/wizard/share_wizard.py b/addons/portal/wizard/share_wizard.py
index d642be7b698..ca950a61b08 100644
--- a/addons/portal/wizard/share_wizard.py
+++ b/addons/portal/wizard/share_wizard.py
@@ -28,7 +28,7 @@ UID_ROOT = 1
SHARED_DOCS_MENU = "Documents"
SHARED_DOCS_CHILD_MENU = "Shared Documents"
-class share_wizard_portal(osv.osv_memory):
+class share_wizard_portal(osv.TransientModel):
"""Inherited share wizard to automatically create appropriate
menus in the selected portal upon sharing with a portal group."""
_inherit = "share.wizard"
diff --git a/addons/portal/wizard/share_wizard_view.xml b/addons/portal/wizard/share_wizard_view.xml
index 2f9d55c1f0d..cf294285f4f 100644
--- a/addons/portal/wizard/share_wizard_view.xml
+++ b/addons/portal/wizard/share_wizard_view.xml
@@ -8,7 +8,7 @@
<field name="type">form</field>
<field name="inherit_id" ref="share.share_step1_form"/>
<field name="arch" type="xml">
- <xpath expr="/form/field[@name='user_type']" position="attributes">
+ <xpath expr="//field[@name='user_type']" position="attributes">
<attribute name='invisible'>0</attribute>
<attribute name='colspan'>4</attribute>
</xpath>
@@ -40,11 +40,11 @@
<xpath expr="//field[@name='result_line_ids']//field[@name='login']" position="after">
<field name="share_url" groups="portal.group_portal_manager"/>
</xpath>
- <xpath expr="//field[@name='result_line_ids']//field[@name='login']" position="after">
- <field name="share_url" colspan="4" groups="portal.group_portal_manager"/>
- </xpath>
<xpath expr="//field[@name='result_line_ids']" position="after">
- <field colspan="4" name="share_root_url" groups="portal.group_portal_manager"/>
+ <newline/>
+ <group string="Details">
+ <field name="share_root_url" groups="portal.group_portal_manager"/>
+ </group>
</xpath>
</field>
</record>
diff --git a/addons/share/static/src/css/share.css b/addons/share/static/src/css/share.css
index 997c070fe54..dbbb8bea943 100644
--- a/addons/share/static/src/css/share.css
+++ b/addons/share/static/src/css/share.css
@@ -1,7 +1,4 @@
-button.oe_share_mail {
- display: none;
-}
-
-a.oe_share_link, a.oe_share {
+/* Added invite button, hidden by default */
+button.oe_share_invite {
display: none;
}
diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js
index e88616546a3..33aa3d1aab9 100644
--- a/addons/share/static/src/js/share.js
+++ b/addons/share/static/src/js/share.js
@@ -50,29 +50,46 @@ openerp.share = function(session) {
session.connection.share_flag.done(yes).fail(no);
}
+ /* Extend the Sidebar to add Share and Embed links in the 'More' menu */
session.web.Sidebar = session.web.Sidebar.extend({
- add_default_sections: function() {
- this._super();
+
+ start: function() {
var self = this;
+ this._super(this);
has_share(function() {
- self.add_items('other', [{
- label: 'Share',
- callback: self.on_sidebar_click_share,
- classname: 'oe_share',
- }]);
+ self.add_items('other', [
+ { label: 'Share',
+ callback: self.on_click_share,
+ classname: 'oe_share' },
+ { label: 'Embed',
+ callback: self.on_click_share_link,
+ classname: 'oe_share' },
+ ]);
});
},
- on_sidebar_click_share: function(item) {
+
+ on_click_share: function(item) {
+ var view = this.getParent()
+ launch_wizard(this, view, 'emails', false);
+ },
+
+ on_click_share_link: function(item) {
var view = this.getParent()
- launch_wizard(this, view);
+ launch_wizard(this, view, 'embedded', false);
},
});
+ /**
+ * Extends mail (Chatter widget)
+ * - show the 'invite' button' only we came on the form view through
+ * an action. We do this because 'invite' is based on the share
+ * mechanism, and it tries to share an action.
+ */
session.mail.RecordThread.include( {
start: function() {
start_res = this._super.apply(this, arguments);
if (has_action_id) {
- this.$element.find('button.oe_share_mail').show();
+ this.$element.find('button.oe_share_invite').show();
}
return start_res;
}
@@ -83,12 +100,7 @@ openerp.share = function(session) {
var self = this;
this.check_if_action_is_defined();
has_share(function() {
- self.$element.find('a.oe_share_link').click(self.on_click_share_link);
- self.$element.find('a.oe_share').click(self.on_click_share);
- self.$element.delegate('button.oe_share_mail', 'click', self.on_click_share_mail);
- }, function() {
- self.$element.find('a.oe_share_link').remove();
- self.$element.find('a.oe_share').remove();
+ self.$element.delegate('button.oe_share_invite', 'click', self.on_click_share_invite);
});
return this._super.apply(this, arguments);
},
@@ -96,23 +108,13 @@ openerp.share = function(session) {
check_if_action_is_defined: function() {
if (this.action && this.action.id) {
has_action_id = true;
- this.$element.find('a.oe_share_link').show();
- this.$element.find('a.oe_share').show();
}
else {
has_action_id = false;
}
},
-
- on_click_share_link: function(e) {
- e.preventDefault();
- launch_wizard(this, this.views[this.active_view].controller, 'embedded', false);
- },
- on_click_share: function(e) {
- e.preventDefault();
- launch_wizard(this, this.views[this.active_view].controller, 'emails', false);
- },
- on_click_share_mail: function(e) {
+
+ on_click_share_invite: function(e) {
e.preventDefault();
launch_wizard(this, this.views[this.active_view].controller, 'emails', true);
},
diff --git a/addons/share/static/src/xml/share.xml b/addons/share/static/src/xml/share.xml
index e51dc135c0b..1d9bc987afc 100644
--- a/addons/share/static/src/xml/share.xml
+++ b/addons/share/static/src/xml/share.xml
@@ -3,18 +3,11 @@
-->
<templates id="template" xml:space="preserve">
- <t t-extend="ViewManagerAction">
- <t t-jquery=".oe_shortcuts_toggle" t-operation="after">
- <a class="oe_share_link" href="#share_link" title="Link or embed..."><img t-att-src='_s + "/share/static/src/img/share.png"'/></a>
- <a class="oe_share" href="#share" title="Share with..."><img t-att-src='_s + "/share/static/src/img/share.png"'/></a>
- </t>
- </t>
-
- <t t-extend="RecordThread">
+ <!-- Extends Chatter widget in form view to add the invite button -->
+ <t t-extend="mail.RecordThread">
<t t-jquery="button.oe_mail_button_unfollow" t-operation="after">
- <button type="button" class="oe_share_mail oe_mail_button_mouseout">Invite</button>
+ <button type="button" class="oe_share_invite">Invite</button>
</t>
</t>
-
</templates>
diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py
index 55d43453775..41871480f45 100644
--- a/addons/share/wizard/share_wizard.py
+++ b/addons/share/wizard/share_wizard.py
@@ -48,7 +48,7 @@ RANDOM_PASS_CHARACTERS = 'aaaabcdeeeefghjkmnpqrstuvwxyzAAAABCDEEEEFGHJKLMNPQRSTU
def generate_random_pass():
return ''.join(random.sample(RANDOM_PASS_CHARACTERS,10))
-class share_wizard(osv.osv_memory):
+class share_wizard(osv.TransientModel):
_name = 'share.wizard'
_description = 'Share Wizard'
@@ -177,9 +177,10 @@ class share_wizard(osv.osv_memory):
'name': fields.char('Share Title', size=64, required=True, help="Title for the share (displayed to users as menu and shortcut name)"),
'record_name': fields.char('Record name', size=128, help="Name of the shared record, if sharing a precise record"),
'message': fields.text("Personal Message", help="An optional personal message, to be included in the email notification."),
-
- 'embed_code': fields.function(_embed_code, type='text'),
- 'embed_option_title': fields.boolean("Display title"),
+ 'embed_code': fields.function(_embed_code, type='text', string='Code',
+ help="Embed this code in your documents to provide a link to the "\
+ "shared document."),
+ 'embed_option_title': fields.boolean('Display title'),
'embed_option_search': fields.boolean('Display search view'),
'embed_url': fields.function(_embed_url, string='Share URL', type='char', size=512, readonly=True),
}
@@ -903,8 +904,11 @@ class share_result_line(osv.osv_memory):
def _share_url(self, cr, uid, ids, _fieldname, _args, context=None):
result = dict.fromkeys(ids, '')
for this in self.browse(cr, uid, ids, context=context):
- data = dict(dbname=cr.dbname, login=this.login, password='')
- result[this.id] = this.share_wizard_id.share_url_template() % data
+ data = dict(dbname=cr.dbname, login=this.login, password=this.password)
+ if this.share_wizard_id and this.share_wizard_id.action_id:
+ data['action_id'] = this.share_wizard_id.action_id.id
+ ctx = dict(context, share_url_template_hash_arguments=['action_id'])
+ result[this.id] = this.share_wizard_id.share_url_template(context=ctx) % data
return result
_columns = {
diff --git a/addons/share/wizard/share_wizard_view.xml b/addons/share/wizard/share_wizard_view.xml
index ee5d4dd23b9..58734caa25b 100644
--- a/addons/share/wizard/share_wizard_view.xml
+++ b/addons/share/wizard/share_wizard_view.xml
@@ -39,17 +39,20 @@
<group>
<field name="user_type" invisible="1"/>
<field name="invite" invisible="1"/>
- </group>
+ </group>
<group>
- <group name="emails_group" attrs="{'invisible':['|', ('user_type', '!=', 'emails'), ('invite', '=', True)]}" string="Share with these People (one email per line)">
- <field colspan="2" nolabel="1" name="new_users" attrs="{'required':[('user_type','=','emails'), ('invite', '!=', True)]}"/>
+ <group colspan="4" name="emails_group" attrs="{'invisible':['|', ('user_type', '!=', 'emails'), ('invite', '=', True)]}"
+ string="Share with these People (one email per line)">
+ <field nolabel="1" name="new_users" attrs="{'required':[('user_type','=','emails'), ('invite', '!=', True)]}"/>
</group>
- <group name="email_lines" attrs="{'invisible':[('invite', '!=', True)]}" string="Share with these People (one email per line)">
+ <group colspan="4" name="email_lines" attrs="{'invisible':['|', ('invite', '!=', True), ('user_type', '!=', 'emails')]}"
+ string="Share with these People (one email per line)">
<field name="email_1"/>
<field name="email_2"/>
<field name="email_3"/>
</group>
- <group attrs="{'invisible':[('user_type', '=', 'embedded')]}" string="Include an Optional Personal Message">
+ <group colspan="4" attrs="{'invisible':[('user_type', '=', 'embedded')]}"
+ string="Include an Optional Personal Message">
<field name="message" colspan="2" nolabel="1"/>
</group>
<group attrs="{'invisible':[('invite', '=', True)]}" string="Sharing Options">
@@ -71,8 +74,8 @@
<field name="user_type" invisible="1"/>
<field name="access_mode" invisible="1"/>
</header>
- <group attrs="{'invisible':[('user_type','=','embedded')]}">
- <separator string="An email notification with instructions has been sent to the following people:"/>
+ <group attrs="{'invisible':[('user_type','=','embedded')]}"
+ string="An email notification with instructions has been sent to the following people:">
<field name="result_line_ids" nolabel="1" mode="tree">
<tree string="Summary">
<field name="login"/>
@@ -85,14 +88,17 @@
</field>
</group>
<group colspan="4" col="1" attrs="{'invisible':[('user_type','!=','embedded')]}">
- <separator string="Use this Link"/>
- <field name="embed_url"/>
- <separator string="Or insert the following code where you want to embed your documents"/>
- <group string="Options">
- <field name="embed_option_title" on_change="onchange_embed_options(embed_option_title, embed_option_search)"/>
- <field name="embed_option_search" on_change="onchange_embed_options(embed_option_title, embed_option_search)" attrs="{'invisible':[('access_mode','=','readonly')]}"/>
+ <group string="Use this link">
+ <field name="embed_url"/>
+ </group>
+ <group string="Or insert the following code where you want to embed your documents">
<field name="embed_code"/>
</group>
+ <group string="Embedded code options">
+ <field name="embed_option_title" on_change="onchange_embed_options(embed_option_title, embed_option_search)"/>
+ <field name="embed_option_search" on_change="onchange_embed_options(embed_option_title, embed_option_search)"
+ attrs="{'invisible':[('access_mode','=','readonly')]}"/>
+ </group>
</group>
</form>