[IMP] no auto_follow, we will use auto-compose instead on some actions

bzr revid: fp@tinyerp.com-20120816090243-nzu6ounygswiceqi
This commit is contained in:
Fabien Pinckaers 2012-08-16 11:02:43 +02:00
parent 1b58af40cc
commit a2b7f82a81
13 changed files with 12 additions and 136 deletions

View File

@ -859,11 +859,6 @@ class crm_lead(base_stage, osv.osv):
# OpenChatter methods and notifications
# ----------------------------------------
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'user_id' to the monitored fields """
res = super(crm_lead, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['user_id']
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1]

View File

@ -364,12 +364,6 @@ class hr_holidays(osv.osv):
dom = ['|'] + dom + [ ('state','=','validate1') ]
return dom
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'user_id' and 'manager' to the monitored fields """
res = super(hr_holidays, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
# TODO: add manager
return res + ['user_id']
def create_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, ids, _('System notification'),

View File

@ -461,11 +461,6 @@ class hr_applicant(base_stage, osv.Model):
# OpenChatter methods and notifications
# -------------------------------------------------------
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'user_id' to the monitored fields """
res = super(hr_applicant, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['user_id']
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
if not stage_id: return True

View File

@ -25,7 +25,6 @@ import mail_mail
import mail_followers
import mail_thread
import mail_group
import ir_needaction
import res_partner
import res_users
import report

View File

@ -24,7 +24,7 @@ from osv import fields
class mail_followers(osv.Model):
""" mail_followers holds the data related to the follow mechanism inside
OpenERP. Users can choose to follow documents (records) of any kind that
OpenERP. Partners can choose to follow documents (records) of any kind that
inherits from mail.thread. Following documents allow to receive
notifications for new messages.
A subscription is characterized by:
@ -32,28 +32,26 @@ class mail_followers(osv.Model):
:param: res_id: ID of resource (may be 0 for every objects)
"""
_name = 'mail.followers'
_rec_name = 'id'
_rec_name = 'partner_id'
_log_access = False
_order = 'res_model asc'
_description = 'Mail Document Followers'
_description = 'Document Followers'
_columns = {
'res_model': fields.char('Related Document Model', size=128,
required=True, select=1,
help='Model of the followed resource'),
'res_id': fields.integer('Related Document ID', select=1,
help='Id of the followed resource'),
'partner_id': fields.many2one('res.partner', string='Related User',
'partner_id': fields.many2one('res.partner', string='Related Partner',
ondelete='cascade', required=True, select=1),
}
class mail_notification(osv.Model):
""" mail_notification is a relational table modeling messages pushed to users.
""" mail_notification is a relational table modeling messages pushed to partners.
"""
_name = 'mail.notification'
_rec_name = 'id'
_rec_name = 'partner_id'
_log_access = False
_order = 'message_id desc'
_description = 'Mail notification'
_description = 'Notifications'
_columns = {
'partner_id': fields.many2one('res.partner', string='Contact',
ondelete='cascade', required=True, select=1),
@ -103,9 +101,9 @@ class mail_notification(osv.Model):
if email_to not in towrite['email_to']:
towrite['email_to'] = towrite['email_to'] + ', ' + email_to
if towrite.get('state', False):
if towrite.get('subject', False):
towrite['subject'] = msg.name_get(cr, uid, [msg.id], context=context)[0][1]
if towrite.get('state', False):
towrite['message_id'] = msg.id
self.pool.get('mail.mail').create(cr, uid, towrite, context=context)
return True

View File

@ -67,7 +67,7 @@ class mail_group(osv.Model):
'image': fields.binary("Photo",
help="This field holds the image used as photo for the "\
"user. The image is base64 encoded, and PIL-supported. "\
"It is limited to a 12024x1024 px image."),
"It is limited to a 1024x1024 px image."),
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
string="Medium-sized photo", type="binary", multi="_get_image",
store = {
@ -165,17 +165,3 @@ class mail_group(osv.Model):
self._subscribe_user_with_group_m2m_command(cr, uid, ids, vals.get('group_ids'), context=context)
return super(mail_group, self).write(cr, uid, ids, vals, context=context)
def action_group_join(self, cr, uid, ids, context=None):
return self.message_subscribe(cr, uid, ids, context=context)
def action_group_leave(self, cr, uid, ids, context=None):
return self.message_unsubscribe(cr, uid, ids, context=context)
# ----------------------------------------
# OpenChatter methods and notifications
# ----------------------------------------
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'responsible_id' to the monitored fields """
res = super(mail_group, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['responsible_id']

View File

@ -31,8 +31,8 @@
<h4><a type="edit"><field name="name"/></a></h4>
<ul>
<li><t t-raw="record.message_summary.raw_value"/></li>
<li t-if="! record.message_is_follower.raw_value"><a name="action_group_join" string="Join" type="object" class="oe_group_join">Not following</a></li>
<li t-if="record.message_is_follower.raw_value"><a name="action_group_leave" string="Join" type="object" class="oe_group_leave">Following</a></li>
<li t-if="! record.message_is_follower.raw_value"><a name="message_subscribe" string="Join" type="object" class="oe_group_join">Not following</a></li>
<li t-if="record.message_is_follower.raw_value"><a name="message_unsubscribe" string="Join" type="object" class="oe_group_leave">Following</a></li>
</ul>
</div>
</div>

View File

@ -22,6 +22,7 @@ class mail_mail(osv.Model):
_columns = {
'message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade'),
'mail_server_id': fields.many2one('ir.mail_server', 'Outgoing mail server', readonly=1),
'subject': fields.char('Subject', size=128),
'state': fields.selection([
('outgoing', 'Outgoing'),
('sent', 'Sent'),

View File

@ -194,27 +194,6 @@ class mail_thread(osv.Model):
self.message_subscribe(cr, uid, [thread_id], [uid], context=context)
return thread_id
# FP Note: not sure we need this?
#def write(self, cr, uid, ids, vals, context=None):
# """ Override of write to subscribe :
# - the writer
# - followers given by the monitored fields
# """
# if isinstance(ids, (int, long)):
# ids = [ids]
# for id in ids:
# # copy original vals because we are going to modify it
# specific_vals = dict(vals)
# # we modify followers: do not subscribe the uid
# if specific_vals.get('message_follower_ids'):
# followers_command = self.message_get_automatic_followers(cr, uid, id, specific_vals, add_uid=False, context=context)
# specific_vals['message_follower_ids'] += followers_command
# else:
# followers_command = self.message_get_automatic_followers(cr, uid, id, specific_vals, context=context)
# specific_vals['message_follower_ids'] = followers_command
# write_res = super(mail_thread, self).write(cr, uid, ids, specific_vals, context=context)
# return True
def unlink(self, cr, uid, ids, context=None):
"""Override unlink, to automatically delete messages
that are linked with res_model and res_id, not through
@ -227,51 +206,6 @@ class mail_thread(osv.Model):
msg_obj.unlink(cr, uid, msg_to_del_ids, context=context)
return super(mail_thread, self).unlink(cr, uid, ids, context=context)
def message_get_automatic_followers(self, cr, uid, id, record_vals, add_uid=True, fetch_missing=False, context=None):
""" Return the command for the many2many follower_ids field to manage
followers. Behavior :
- get the monitored fields (ex: ['user_id', 'responsible_id']); those
fields should be relationships to res.users (#TODO: res.partner)
- if this field is in the record_vals: it means it has been modified
thus add its value to the followers
- if this fields is not in record_vals, but fetch_missing paramter
is set to True: fetch the value in the record (use: at creation
for default values, not present in record_vals)
- if add_uid: add the current user (for example: writer is follower)
- generate the command and return it
This method has to be used on 1 id, because otherwise it would imply
to track which user.id is used for which record.id.
:param record_vals: values given to the create method of the new
record, or values updated in a write.
:param monitored_fields: a list of fields that are monitored. Those
fields must be many2one fields to the res.users model.
:param fetch_missing: is set to True, the method will read the
record to find values that are not present in record_vals.
#TODO : UPDATE WHEN MERGING TO PARTNERS
"""
# get monitored fields
monitored_fields = self.message_get_monitored_follower_fields(cr, uid, [id], context=context)
modified_fields = [field for field in monitored_fields if field in record_vals.iterkeys()]
other_fields = [field for field in monitored_fields if field not in record_vals.iterkeys()] if fetch_missing else []
# for each monitored field: if in record_vals, it has been modified/added
follower_ids = []
for field in modified_fields:
# do not add 'False'
if record_vals.get(fields):
follower_ids.append(record_vals.get(field))
# for other fields: read in record if fetch_missing (otherwise list is void)
for field in other_fields:
record = self.browse(cr, uid, id, context=context)
value = getattr(record, field)
if value:
follower_ids.append(value)
# add uid if asked and not already present
if add_uid and uid not in follower_ids:
follower_ids.append(uid)
return self.message_subscribe_get_command(cr, uid, follower_ids, context=context)
#------------------------------------------------------
# mail.message wrappers and tools
#------------------------------------------------------
@ -987,12 +921,6 @@ class mail_thread(osv.Model):
return True
return False
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Returns a list of fields containing a res.user.id. Those fields
will be checked to automatically subscribe those users.
"""
return []
def message_subscribe(self, cr, uid, ids, partner_ids=None, context=None):
"""
:param user_ids: a list of user_ids; if not set, subscribe

View File

@ -1046,11 +1046,6 @@ class mrp_production(osv.osv):
# OpenChatter methods and notifications
# ---------------------------------------------------
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'user_id' to the monitored fields """
res = super(mrp_production, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['user_id']
def create_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Manufacturing order has been <b>created</b>."), context=context)
return True

View File

@ -514,11 +514,6 @@ def Project():
# OpenChatter methods and notifications
# ------------------------------------------------
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'user_id' to the monitored fields """
res = super(project, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['user_id']
def create(self, cr, uid, vals, context=None):
if context is None: context = {}
# Prevent double project creation when 'use_tasks' is checked!

View File

@ -499,11 +499,6 @@ class project_issue(base_stage, osv.osv):
# OpenChatter methods and notifications
# -------------------------------------------------------
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'user_id' to the monitored fields """
res = super(project_issue, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['user_id']
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1]

View File

@ -734,11 +734,6 @@ class purchase_order(osv.osv):
def needaction_domain_get(self, cr, uid, ids, context=None):
return [('state','=','draft')]
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
""" Add 'validator' to the monitored fields """
res = super(purchase_order, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['validator']
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Request for quotation <b>created</b>."), context=context)