[MERGE] Merged branch holding improvements and fixes about OpenChatter. Main modifications: css cleaning, feeds icon bug fix, message datetime management. Doc has also be updated even if it is not yet finished.

bzr revid: tde@openerp.com-20120419092435-stvju5o1d47wdqv6
This commit is contained in:
Thibault Delavallée 2012-04-19 11:24:35 +02:00
commit 40e6aee377
21 changed files with 376 additions and 138 deletions

View File

@ -22,6 +22,7 @@
from base_calendar import base_calendar
from crm import crm_base, crm_case
from osv import fields, osv
import tools
from tools.translate import _
import logging
@ -99,7 +100,11 @@ class crm_meeting(crm_base, osv.osv):
# update context: if come from phonecall, default state values can make the message_append_note crash
context.pop('default_state', False)
for meeting in self.browse(cr, uid, ids, context=context):
message = _("A meeting has been <b>scheduled</b> on <em>%s</em>.") % (meeting.date)
# convert datetime field to a datetime, using server format, then
# convert it to the user TZ and re-render it with %Z to add the timezone
meeting_datetime = fields.DT.datetime.strptime(meeting.date, tools.DEFAULT_SERVER_DATETIME_FORMAT)
meeting_date_str = fields.datetime.context_timestamp(cr, uid, meeting_datetime, context=context).strftime(tools.DATETIME_FORMATS_MAP['%+'] + " (%Z)")
message = _("A meeting has been <b>scheduled</b> on <em>%s</em>.") % (meeting_date_str)
if meeting.opportunity_id: # meeting can be create from phonecalls or opportunities, therefore checking for the parent
lead = meeting.opportunity_id
parent_message = _("Meeting linked to the opportunity <em>%s</em> has been <b>created</b> and <b>cscheduled</b> on <em>%s</em>.") % (lead.name, meeting.date)

View File

@ -24,6 +24,7 @@ from osv import fields, osv
from tools.translate import _
import crm
import time
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
from datetime import datetime
class crm_phonecall(crm_base, osv.osv):
@ -323,7 +324,11 @@ class crm_phonecall(crm_base, osv.osv):
phonecall.message_subscribe([phonecall.user_id.id], context=context)
if phonecall.opportunity_id:
lead = phonecall.opportunity_id
message = _("Phonecall linked to the opportunity <em>%s</em> has been <b>created</b> and <b>scheduled</b> on <em>%s</em>.") % (lead.name, phonecall.date)
# convert datetime field to a datetime, using server format, then
# convert it to the user TZ and re-render it with %Z to add the timezone
phonecall_datetime = fields.DT.datetime.strptime(phonecall.date, DEFAULT_SERVER_DATETIME_FORMAT)
phonecall_date_str = fields.datetime.context_timestamp(cr, uid, phonecall_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
message = _("Phonecall linked to the opportunity <em>%s</em> has been <b>created</b> and <b>scheduled</b> on <em>%s</em>.") % (lead.name, phonecall_date_str)
else:
message = _("Phonecall has been <b>created and opened</b>.")
phonecall.message_append_note(body=message)

View File

@ -1,6 +1,12 @@
:orphan:
Mail module documentation
=========================
The Mail module holds all models and logic related to messages management. At low-level, it handles messages and offers an API to message queues for email sending. At an higher level, it provides the OpenChatter feature that is a thread management system inside OpenERP. A model that inherits from the mail module adds OpenChatter to its document. Its gives them the following capabilities :
- messages management with a threaded design
- subscription mechanism tha allow users to follow/unfollow documents
- notifications mechanism; notifications are pushed to users to form a Wall page holding the latest pushed messages
The mail module also comes with an email composition wizard, along with discussion groups.
.. include:: index.rst.inc

View File

@ -1,8 +1,11 @@
Mail Module
'''''''''''
Mail Module documentation topics
'''''''''''''''''''''''''''''''''
.. toctree::
:maxdepth: 1
mail_message
mail_thread
mail_openchatter_howto
mail_needaction_howto

View File

@ -0,0 +1,24 @@
.. _mail_message:
mail.message
============
TODO
mail.group
++++++++++
A mail_group is a collection of users sharing messages in a discussion group. Group users are users that follow the mail group, using the subscription/follow mechanism of OpenSocial. A mail group has nothing in common wih res.users.group.
Additional information on fields:
- ``member_ids``: user member of the groups are calculated with ``message_get_subscribers`` method from mail.thread
- ``member_count``: calculated with member_ids
- ``is_subscriber``: calculated with member_ids
res.users
+++++++++
OpenChatter updates the res.users class:
- it adds a preference about sending emails when receiving a notification
- make a new user follow itself automatically
- create a welcome message when creating a new user, to make his arrival in OpenERP more friendly

View File

@ -0,0 +1,15 @@
How to use the need action mechanism in my addon
=================================================
Make your module inheriting from ir.needaction_mixin class
Feature integration
++++++++++++++++++++
::
class my_module(osv.osv):
_name = "my.module"
_description = "My Module"
_inherit = ['ir.needaction_mixin']

View File

@ -0,0 +1,155 @@
How to use OpenChatter in my addon
===================================
Running example
++++++++++++++++
A small my_task model will be used as example to explain how to use the OpenChatter feature. Being simple, it has only the following fields :
- a name
- a task responsible
- a related project
::
class my_task(osv.osv):
_name = "my.task"
_description = "My Task"
_columns = {
'name': fields.char('Name', required=True, size=64),
'user_id':fields.many2one('res.users', string='Responsible',
ondelete='cascade', required=True, select=1),
'project_id':fields.many2one('project.project', string='Related project',
ondelete='cascade', required=True, select=1),
}
Two-lines feature integration
++++++++++++++++++++++++++++++
Make your module inheriting from the ``mail.thread`` class.
::
class my_task(osv.osv):
_name = "my.task"
_description = "My Task"
# inherit from mail.thread allows the use of OpenChatter
_inherit = ['mail.thread']
Use the thread viewer widget inside your form view by using the ThreadView widget on the message_ids_social field inherited from mail.thread.
::
<record model="ir.ui.view" id="my_task_form_view">
<field name="name">My Task</field>
<field name="model">my.task</field>
<field name="type">form</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<form>
[...]
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</form>
</field>
</record>
Send notifications
+++++++++++++++++++
When sending a notification is required in your workflow or business logic, use the ``message_append_note`` method. This method is a shortcut to the ``message_append`` method that takes all ``mail.message`` fields as arguments. This latter method calls ``message_create`` that
- creates the message
- parses the body to find users you want to push the message to (finding and parsing ``@login`` in the message body)
- pushes a notification to users following the document and requested users of the latetr step
You should therefore not worry about subscriptions or anything else than sending the notification. Here is a small example of sending a notification when the ``do_something`` method is called :
::
def do_something(self, cr, uid, ids, context=None):
[...]
self.do_something_send_note(cr, uid, ids, context=context)
[...]
return res
def do_something_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, _('My subject'),
_("has received a <b>notification</b> and is happy for it."), context=context)
Notifications guidelines
+++++++++++++++++++++++++
Here are a few guidelines that you should keep in mind during the addition of system notifications :
- avoid unnecessary content; if a message has no interest, do not implement it
- use short sentences
- do not include the document name, as it is managed by the thread widget
- use a simple and clean style
- html tags are supported: use <b> or <em> mainly
- put main word(s) in bold
- avoid fancy styles that will break the OpenERP look and feel
- create a separate method for sending your notification
- use a method name like ``original_method_name_send_note``, that allow to easily spot notification methods in the code
Subscription management
++++++++++++++++++++++++
There are a few default subscription tricks that you should know before playing with subscription:
- users that click on 'follow' follow the document. An entry in ``mail.subscription`` is created.
- users that click on 'unfollow' are no longer followers to the document. The related entry in ``mail.subscription`` is created.
- users that create or update a document automatically follow it. An entry in ``mail.subscription`` is created.
If you want to override this default behavior, you should avoid doing it manualle. You should instead override the ``message_get_subscribers`` method from mail.thread. The default implementation looks in the ``mail.suscription`` table for entries matching ``user_id=uid, res_model=self._name, res_id=current_record_id``. You can add subscribers by overriding the ``message_get_subscribers`` and adding user ids to the returned list. This means that they will be considered as followers even if they do not have an entry in the mail.subscription table.
As an exemple, let us say that you want to automatically add the my_task responsible along with the project manager to the list of followers. The method could look like:
::
def message_get_subscribers(self, cr, uid, ids, context=None):
# get the followers from the mail.subscription table
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
# add the employee and its manager if specified to the subscribed users
for obj in self.browse(cr, uid, ids, context=context):
if obj.user_id:
sub_ids.append(obj.user_id)
if obj.project_id and obj.project_id.user_id:
sub_ids.append(obj.project_id.user_id)
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
This method has the advantage of being able to implement a particular behavior with as few code addition as possible. Moreover, when changing the task responsible of the project manager, the subscribers are always correct. This allows to avoid to implement complex corner cases that could obfuscate the code.
The drawback of this method is that it is no longer possible to those subscribers to unfollow a document. Indeed, as user ids are added directly in a list in ``message_get_subscribers``, it is not possible to unsubscribe to a document. However, this drawback is mitigated by
- only important users shoudl be added using this method. Important users should not unsubscribe from their documents.
- users can hide the notifications on their Wall
Messages display management
++++++++++++++++++++++++++++
By default, the ThreadView widget shows all messages related to the current document beside the document, in the History and comments section. However, you may want to display other messages in the widget. For example, the OpenChatter on res.users model shows
- messages related to the user, as usual (messages with ``model = res.users, res_id = current_document_id``)
- messages directly pushed to this user (containing @login)
The best way to direct the messages that will be displayed in the OpenChatter widget is to override the ``message_load`` method. For example, the following method fetches messages as usual, but also fetches messages linked to the task project that contain the task name. Please refer to the API for more details about the arguments.
::
def message_load(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None):
msg_obj = self.pool.get('mail.message')
for my_task in self.browse(cr, uid, ids, context=context):
# search as usual messages related to the current document
msg_ids += msg_obj.search(cr, uid, ['|', '&', ('res_id', '=', my_task.id), ('model', '=', self._name),
# add: search in the current task project messages
'&', '&', ('res_id', '=', my_task.project_id.id), ('model', '=', 'project.project'),
# ... containing the task name
'|', ('body_text', 'like', '%s' % (my_task.name)), ('body_html', 'like', '%s' % (my_task.name))
] + domain, limit=limit, offset=offset, context=context)
# if asked: add ancestor ids to have complete threads
if (ascent): msg_ids = self._message_add_ancestor_ids(cr, uid, ids, msg_ids, root_ids, context=context)
return msg_obj.read(cr, uid, msg_ids, context=context)

View File

@ -1,7 +1,7 @@
.. _mail_thread:
OpenChatter
===========
mail.thread and OpenChatter
===========================
TODO
@ -10,6 +10,7 @@ mail.group
A mail_group is a collection of users sharing messages in a discussion group. Group users are users that follow the mail group, using the subscription/follow mechanism of OpenSocial. A mail group has nothing in common wih res.users.group.
Additional information on fields:
- ``member_ids``: user member of the groups are calculated with ``message_get_subscribers`` method from mail.thread
- ``member_count``: calculated with member_ids
- ``is_subscriber``: calculated with member_ids

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data noupdate="1">
<record model="mail.group" id="group_all_company">
<field name="name">All Company</field>

View File

@ -3,11 +3,10 @@
<data>
<!-- toplevel menu -->
<menuitem id="mail_feeds_main" name="Feeds" sequence="0"
web_icon="static/src/img/feeds.png"
web_icon_hover="static/src/img/feeds-hover.png" />
<record id="mail_feeds_main" model="ir.ui.menu">
<field name="name">Feeds</field>
<field name="sequence">0</field>
<field name="web_icon" eval="static/src/img/feeds.png"/>
<field name="web_icon_hover" eval="static/src/img/feeds-hover.png"/>
<field name="action" ref="action_mail_all_feeds"/>
</record>

View File

@ -41,7 +41,7 @@ class res_users(osv.osv):
}
_defaults = {
'notification_email_pref': 'all',
'notification_email_pref': 'none',
}
def __init__(self, pool, cr):
@ -63,7 +63,8 @@ class res_users(osv.osv):
# create a welcome message to broadcast
company_name = user.company_id.name if user.company_id else 'the company'
message = _('%s has joined %s! You may leave him/her a message to celebrate a new arrival in the company ! You can help him/her doing its first steps on OpenERP.') % (user.name, company_name)
self.message_broadcast(cr, uid, [user.id], 'Welcome notification', message, context=context)
# TODO: clean the broadcast feature. As this is not cleany specified, temporarily remove the message broadcasting that is not buggy but not very nice.
#self.message_broadcast(cr, uid, [user.id], 'Welcome notification', message, context=context)
return user_id
def message_load_ids(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None):

View File

@ -2,125 +2,171 @@
/* Wall */
/* ------------------------------ */
div.oe_mail_wall {
.openerp div.oe_mail_wall {
overflow: auto;
padding: 0;
background: white;
}
/*div.oe_mail_wall_search {*/
/*width: 550px;*/
/*}*/
.oe_mail_wall_button_comment {
float: right;
.openerp div.oe_mail_wall_act:after {
content: "";
display: block;
clear: both;
}
/* 2 columns view */
div.oe_mail_wall_left {
.openerp div.oe_mail_wall_left {
float: left;
width: 560px;
margin: 8px;
}
div.oe_mail_wall_right {
float: right;
width: 34%;
.openerp div.oe_mail_wall_right {
margin-left: 565px;
margin: 8px;
}
.oe_mail_wall_threads {
.openerp div.oe_mail_wall_threads {
margin-top: 8px;
}
.oe_mail_wall_thread div.oe_mail_thread_act .oe_mail_action_textarea, div.oe_mail_thread_subthread .oe_mail_action_textarea {
.openerp textarea.oe_mail_wall_action_textarea {
width: 550px;
height: 60px;
padding: 5px;
}
.openerp div.oe_mail_wall_threads textarea {
height: 20px;
padding: 2px;
}
.oe_mail_thread_subthread div.oe_mail_thread_act .oe_mail_msg_image, .oe_mail_thread_subthread div.oe_mail_thread_display .oe_mail_msg_image {
.openerp div.oe_mail_thread_subthread img {
width: 30px;
height: 30px;
}
.oe_mail_thread_subthread .oe_mail_msg_content, .oe_mail_thread_subthread .oe_mail_msg_content {
.openerp div.oe_mail_thread_subthread div.oe_mail_msg_content {
margin-left: 40px;
}
div.oe_mail_wall_more {
.openerp div.oe_mail_wall_more {
text-align: center;
display: none;
}
/* ------------------------------ */
/* RecordThread */
/* ------------------------------ */
.oe_mail_recthread {
.openerp div.oe_mail_recthread {
overflow: auto;
}
/* Left-side CSS */
.oe_mail_recthread_actions {
.openerp div.oe_mail_recthread_actions {
margin-bottom: 8px;
}
.oe_mail_recthread_followers {
.openerp div.oe_mail_recthread_followers {
margin-bottom: 8px;
}
.oe_mail_followers_action, .oe_mail_followers_display {
}
/* RecordThread: 2 columns view */
.oe_mail_recthread_left {
.openerp div.oe_mail_recthread_left {
float: left;
width: 55%;
}
.oe_mail_recthread_right {
.openerp div.oe_mail_recthread_right {
float: right;
width: 240px;
width: 250px;
}
.oe_mail_button_follow, .oe_mail_button_unfollow {
/*width: 120px;*/
.openerp div.oe_mail_recthread_actions button {
width: 120px;
}
.oe_mail_button_followers {
display: inline-block;
width: 240px;
.openerp button.oe_mail_button_followers {
display: inline;
}
.openerp button.oe_mail_button_mouseout {
color: white;
background-color: #8a89ba;
background-image: -webkit-gradient(linear, left top, left bottom, from(#8a89ba), to(#807fb4));
background-image: -webkit-linear-gradient(top, #8a89ba, #807fb4);
background-image: -moz-linear-gradient(top, #8a89ba, #807fb4);
background-image: -ms-linear-gradient(top, #8a89ba, #807fb4);
background-image: -o-linear-gradient(top, #8a89ba, #807fb4);
background-image: linear-gradient(to bottom, #8a89ba, #807fb4);
}
.openerp button.oe_mail_button_mouseover {
display: none;
color: white;
background-color: #dc5f59;
background-image: -webkit-gradient(linear, left top, left bottom, from(#dc5f59), to(#b33630));
background-image: -webkit-linear-gradient(top, #dc5f59, #b33630);
background-image: -moz-linear-gradient(top, #dc5f59, #b33630);
background-image: -ms-linear-gradient(top, #dc5f59, #b33630);
background-image: -o-linear-gradient(top, #dc5f59, #b33630);
background-image: linear-gradient(to bottom, #dc5f59, #b33630);
}
.openerp textarea.oe_mail_action_textarea {
height: 60px;
padding: 5px;
}
/* ------------------------------ */
/* ThreadDisplay */
/* ------------------------------ */
div.oe_mail_thread_act {
.openerp div.oe_mail_thread_act {
white-space: normal;
margin-bottom: 5px;
padding: 4px;
}
div.oe_mail_thread_display {
white-space: normal;
/*margin-bottom: 5px;*/
.openerp div.oe_mail_thread_act:after {
content: "";
display: block;
clear: both;
}
div.oe_mail_thread_subthread {
.openerp div.oe_mail_thread_display {
white-space: normal;
}
.openerp div.oe_mail_thread_subthread {
margin-top: 8px;
padding-left: 5%;
}
div.oe_mail_thread_more {
.openerp div.oe_mail_thread_more {
display: none;
border-bottom: 1px solid #D2D9E7;
}
li.oe_mail_thread_msg {
.openerp li.oe_mail_thread_msg {
padding: 1px;
}
.notification, .comment {
.openerp li.oe_mail_thread_msg:after {
content: "";
display: block;
clear: both;
}
.openerp li.oe_mail_thread_msg > div:after {
content: "";
display: block;
clear: both;
}
.openerp .oe_mail_msg_notification, .openerp .oe_mail_msg_comment, .openerp .oe_mail_msg_email {
padding: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
@ -129,46 +175,35 @@ li.oe_mail_thread_msg {
border-radius: 4px;
}
.oe_mail_thread_msg > .comment {
.openerp li.oe_mail_thread_msg > .oe_mail_msg_comment {
background: #eee;
}
.oe_mail_thread_subthread .comment {
.openerp div.oe_mail_thread_subthread .oe_mail_msg_comment {
background: white;
}
.notification {
.openerp .oe_mail_msg_notification {
background: #eee;
}
.notification:after, .email:after, .comment:after {
.openerp .oe_mail_msg_notification:after, .openerp .oe_mail_msg_comment:after, .openerp .oe_mail_msg_email:after {
content: "";
display: block;
clear: both;
}
li.oe_mail_thread_msg:after, div.oe_mail_thread_act:after {
content: "";
display: block;
clear: both;
}
.oe_mail_msg_content {
.openerp .oe_mail_msg_content {
margin-left: 60px;
}
.oe_mail_msg_content:after {
.openerp .oe_mail_msg_content:after {
content: "";
display: block;
clear: both;
}
.oe_mail_action_textarea {
height: 50px;
padding: 5px;
}
.oe_mail_msg_image {
.openerp img.oe_mail_msg_image {
margin-right: 8px;
width: 45px;
height: 45px;
@ -186,11 +221,11 @@ li.oe_mail_thread_msg:after, div.oe_mail_thread_act:after {
clip: rect(5px, 40px, 45px, 0px);
}
p.oe_mail_msg_p_email_header {
.openerp p.oe_mail_msg_p_email_header {
border-bottom: 1px solid #D2D9E7;
}
.oe_mail_msg_body a.reduce, .oe_mail_msg_body_short a.expand {
.openerp span.oe_mail_msg_body a.reduce, .openerp span.oe_mail_msg_body_short a.expand {
color: #4E43E7;
}
@ -198,17 +233,17 @@ p.oe_mail_msg_p_email_header {
/* Styling (should be openerp) */
/* ------------------------------ */
ul.oe_mail {
.openerp ul.oe_mail {
padding: 0;
margin: 0;
}
li.oe_mail {
.openerp li.oe_mail {
list-style-type: none;
margin-bottom: 2px;
}
input.oe_mail, textarea.oe_mail {
.openerp input.oe_mail, textarea.oe_mail {
width: 100%;
padding: 4px;
font-size: 12px;
@ -226,15 +261,7 @@ input.oe_mail, textarea.oe_mail {
border-radius: 3px;
}
.oe_mail_wall .oe_mail_wall_act textarea {
width: 550px;
}
textarea.oe_mail {
height: 60px;
}
input.oe_mail:focus, textarea.oe_mail:focus {
.openerp input.oe_mail:focus, textarea.oe_mail:focus {
outline: 0;
border-color: rgba(82, 168, 236, 0.8);
-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);
@ -242,49 +269,30 @@ input.oe_mail:focus, textarea.oe_mail:focus {
-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);
}
p.oe_mail_msg {
.openerp p.oe_mail_msg {
padding: 0;
margin: 0;
}
.oe_mail_oe_right {
.openerp .oe_mail_oe_right {
float: right;
margin-right: 8px;
}
.oe_mail_oe_left {
.openerp .oe_mail_oe_left {
float: left;
margin-right: 8px;
}
.oe_mail_oe_fade {
color: #888888;
}
.oe_mail_oe_bold {
font-weight: bold;
}
.oe_mail_msg_reply, .oe_mail_msg_delete {
margin-right: 4px;
}
a.oe_mail_oe_intlink {
.openerp a.oe_mail_oe_intlink {
color: #8786b7;
}
.oe_mail_oe_warning, .oe_mail_oe_warning a {
color: #C03000;
.openerp .oe_mail_oe_bold {
font-weight: bold;
}
.oe_mail_oe_space {
.openerp .oe_mail_oe_space {
margin-left: 15px;
margin-right: 4px;
}
.oe_mail_recthread_actions button {
width: 120px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -275,6 +275,8 @@ openerp.mail = function(session) {
record.tr_body = this.do_truncate_string(record.body, this.params.msg_more_limit);
record.body = this.do_replace_internal_links(record.body);
if (record.tr_body) record.tr_body = this.do_replace_internal_links(record.tr_body);
// format date according to the user timezone
record.date = session.web.format_value(record.date, {type:"datetime"});
// render
$(session.web.qweb.render('ThreadMsg', {'record': record, 'thread': this, 'params': this.params, 'display': this.display})
).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
@ -388,6 +390,11 @@ openerp.mail = function(session) {
return this.fetch_comments(this.params.limit, this.params.offset, domain);
},
/**
*
* var regex_login = new RegExp(/(^|\s)@((\w|@|\.)*)/g);
* var regex_intlink = new RegExp(/(^|\s)#(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
*/
do_replace_internal_links: function (string) {
var self = this;
var icon_list = ['al', 'pinky']
@ -427,7 +434,6 @@ openerp.mail = function(session) {
/**
*
* var regex_login = new RegExp(/(^|\s)@(\w*[a-zA-Z_.]+\w*\s)/g);
* var regex_login = new RegExp(/(^|\s)@((\w|@|\.)*)/g);
* var regex_intlink = new RegExp(/(^|\s)#(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
*/
@ -485,11 +491,11 @@ openerp.mail = function(session) {
// bind buttons
this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }).hide();
this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
.mouseover(function () { $(this).html('Follow').addClass('following'); })
.mouseleave(function () { $(this).html('Not following').removeClass('following'); });
.mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
.mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
.mouseover(function () { $(this).html('Unfollow').removeClass('following').addClass('unfollow'); })
.mouseleave(function () { $(this).html('Following').removeClass('unfollow').addClass('following'); });
.mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
.mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
this.reinit();
},

View File

@ -10,7 +10,7 @@
<div class="oe_mail_wall_left">
<div class="oe_mail_wall_act">
<textarea class="oe_mail oe_mail_wall_action_textarea" placeholder="Add a personnal message here..."/>
<button class="oe_mail_wall_button_comment" type="button">Post comment</button>
<button class="oe_mail_oe_right oe_mail_wall_button_comment" type="button">Post comment</button>
</div>
<div class="oe_clear"></div>
<div class="oe_mail_wall_threads">
@ -31,8 +31,8 @@
</div>
<div class="oe_mail_recthread_right">
<div class="oe_mail_recthread_actions">
<button type="button" class="oe_mail_button_follow">Not following</button>
<button type="button" class="oe_mail_button_unfollow following">Following</button>
<button type="button" class="oe_mail_button_follow oe_mail_button_mouseout">Not following</button>
<button type="button" class="oe_mail_button_unfollow oe_mail_button_mouseout">Following</button>
<button type="button" class="oe_mail_button_followers">Display followers</button>
</div>
<div class="oe_mail_recthread_followers">
@ -43,11 +43,11 @@
</div>
</div>
<ul t-name="Thread" class="oe_mail_thread oe_mail">
<ul t-name="Thread" class="oe_mail oe_mail_thread">
<div class="oe_mail_thread_act">
<img class="oe_mail_msg_image oe_mail_oe_left" alt="User img"/>
<div class="oe_mail_msg_content">
<textarea class="oe_mail_action_textarea oe_mail" placeholder="Add your comment here..." onfocus="this.value = '';"/><br />
<textarea class="oe_mail oe_mail_action_textarea" placeholder="Add your comment here..." onfocus="this.value = '';"/><br />
</div>
</div>
<div class="oe_mail_thread_display"></div>
@ -56,8 +56,8 @@
</div>
</ul>
<li t-name="ThreadMsg" t-attf-class="oe_mail_thread_msg oe_mail">
<div t-attf-class="{record.type}">
<li t-name="ThreadMsg" t-attf-class="oe_mail oe_mail_thread_msg">
<div t-attf-class="oe_mail_msg_#{record.type}">
<img class="oe_mail_msg_image oe_mail_oe_left" t-att-src="record.mini_url"/>
<div class="oe_mail_msg_content">
<t t-if="record.type == 'email'"><t t-call="EmailDisplay" /></t>
@ -79,12 +79,12 @@
<a href="#" class="intlink oe_mail_oe_intlink" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}'><t t-raw="record.user_id[1]"/></a>
on <t t-raw="record.date"/>
</span>
<t t-if="display['show_reply']"><a href="#" class="oe_mail_msg_reply oe_mail_oe_intlink"> Reply</a> </t>
<t t-if="display['show_reply']"><a href="#" class="oe_mail_oe_space oe_mail_msg_reply oe_mail_oe_intlink"> Reply</a> </t>
<t t-if="display['show_delete']">
<t t-if="thread._is_author(record.user_id[0])"><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_delete oe_mail_oe_intlink"> Delete </a></t>
<t t-if="thread._is_author(record.user_id[0])"><a href="#" t-attf-data-id='{record.id}' class="oe_mail_oe_space oe_mail_msg_delete oe_mail_oe_intlink"> Delete </a></t>
</t>
<t t-if="display['show_hide']">
<t t-if="!(thread._is_author(record.user_id[0]))"><span class="oe_mail_oe_space"><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_hide oe_mail_oe_intlink">Hide</a></span></t>
<t t-if="!(thread._is_author(record.user_id[0]))"><a href="#" t-attf-data-id='{record.id}' class="oe_mail_oe_space oe_mail_msg_hide oe_mail_oe_intlink">Hide</a></t>
</t>
</p>
</t>

View File

@ -22,6 +22,7 @@
from datetime import datetime
from osv import osv, fields
import decimal_precision as dp
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
from tools.translate import _
import netsvc
import time
@ -1073,7 +1074,11 @@ class mrp_production(osv.osv):
def action_confirm_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = _("Manufacturing order has been <b>confirmed</b> and is <b>scheduled</b> for the <em>%s</em>.") % (obj.date_planned)
# convert datetime field to a datetime, using server format, then
# convert it to the user TZ and re-render it with %Z to add the timezone
obj_datetime = fields.DT.datetime.strptime(obj.date_planned, DEFAULT_SERVER_DATETIME_FORMAT)
obj_date_str = fields.datetime.context_timestamp(cr, uid, obj_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
message = _("Manufacturing order has been <b>confirmed</b> and is <b>scheduled</b> for the <em>%s</em>.") % (obj_date_str)
self.message_append_note(cr, uid, [obj.id], body=message, context=context)
return True

View File

@ -29,7 +29,7 @@ import pooler
from tools.translate import _
import decimal_precision as dp
from osv.orm import browse_record, browse_null
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
#
# Model definition
@ -672,8 +672,11 @@ class purchase_order(osv.osv):
def shipment_send_note(self, cr, uid, ids, picking_id, context=None):
for order in self.browse(cr, uid, ids, context=context):
for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
pck_date = datetime.strptime(picking.min_date, '%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y')
self.message_append_note(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, pck_date), context=context)
# convert datetime field to a datetime, using server format, then
# convert it to the user TZ and re-render it with %Z to add the timezone
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
self.message_append_note(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
for order in self.browse(cr, uid, ids, context=context):

View File

@ -25,7 +25,7 @@ import time
import pooler
from osv import fields, osv
from tools.translate import _
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, float_compare
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import decimal_precision as dp
import netsvc
@ -940,8 +940,11 @@ class sale_order(osv.osv):
def delivery_send_note(self, cr, uid, ids, picking_id, context=None):
for order in self.browse(cr, uid, ids, context=context):
for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
pck_date = datetime.strptime(picking.min_date, '%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y')
self.message_append_note(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, pck_date), context=context)
# convert datetime field to a datetime, using server format, then
# convert it to the user TZ and re-render it with %Z to add the timezone
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
self.message_append_note(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
def delivery_end_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Order <b>delivered</b>."), context=context)

View File

@ -1,5 +1,4 @@
button.oe-share-mail {
width: 120px;
display: none;
}

View File

@ -11,8 +11,8 @@
</t>
<t t-extend="RecordThread">
<t t-jquery=".oe_mail_button_follow" t-operation="before">
<button type="button" class="oe-share-mail">Invite</button>
<t t-jquery="button.oe_mail_button_unfollow" t-operation="after">
<button type="button" class="oe-share-mail oe_mail_button_mouseout">Invite</button>
</t>
</t>