[REF] mail: mail has now a mesage_subscriber_ids field, many2many modified field, to avoid doing asynchronous queries to have them. Added temp debug field on mail_group.
bzr revid: tde@openerp.com-20120809144345-y03iqvhxv8jxo59v
This commit is contained in:
parent
a59933de2c
commit
c510b34778
|
@ -21,9 +21,9 @@
|
|||
|
||||
import mail_alias
|
||||
import mail_message
|
||||
import mail_subscription
|
||||
import mail_thread
|
||||
import mail_group
|
||||
import mail_subscription
|
||||
import ir_needaction
|
||||
import res_users
|
||||
import res_partner
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<field name="message_subscriber_ids"/>
|
||||
</sheet>
|
||||
<div class="oe_chatter oe_mail_group_footer">
|
||||
<field name="message_ids" widget="mail_thread"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
from osv import osv
|
||||
from osv import fields
|
||||
|
||||
class mail_subscription(osv.osv):
|
||||
class mail_subscription(osv.Model):
|
||||
"""
|
||||
mail_subscription holds the data related to the follow mechanism inside OpenERP.
|
||||
A subscription is characterized by:
|
||||
|
@ -32,6 +32,7 @@ class mail_subscription(osv.osv):
|
|||
"""
|
||||
_name = 'mail.subscription'
|
||||
_rec_name = 'id'
|
||||
_log_access = False
|
||||
_order = 'res_model asc'
|
||||
_description = 'Mail subscription'
|
||||
_columns = {
|
||||
|
@ -44,7 +45,7 @@ class mail_subscription(osv.osv):
|
|||
ondelete='cascade', required=True, select=1),
|
||||
}
|
||||
|
||||
class mail_notification(osv.osv):
|
||||
class mail_notification(osv.Model):
|
||||
"""
|
||||
mail_notification is a relational table modeling messages pushed to users.
|
||||
:param: read: not used currently
|
||||
|
|
|
@ -34,6 +34,25 @@ import xmlrpclib
|
|||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class many2many_model_in_where(fields.many2many):
|
||||
|
||||
def _get_query_and_where_params(self, cr, model, ids, values, where_params):
|
||||
""" Add in where:
|
||||
- mail_subscription.res_model = 'crm.lead'
|
||||
"""
|
||||
query = 'SELECT %(rel)s.%(id2)s, %(rel)s.%(id1)s \
|
||||
FROM %(rel)s, %(from_c)s \
|
||||
WHERE %(rel)s.%(id1)s IN %%s \
|
||||
AND %(rel)s.%(id2)s = %(tbl)s.id \
|
||||
AND %(rel)s.res_model = %%s \
|
||||
%(where_c)s \
|
||||
%(order_by)s \
|
||||
%(limit)s \
|
||||
OFFSET %(offset)d' \
|
||||
% values
|
||||
where_params = [model._name] + where_params
|
||||
return query, where_params
|
||||
|
||||
class mail_thread(osv.Model):
|
||||
'''Mixin model, meant to be inherited by any model that needs to
|
||||
act as a discussion topic on which messages can be attached.
|
||||
|
@ -84,6 +103,10 @@ class mail_thread(osv.Model):
|
|||
type='one2many', obj='mail.message', _fields_id = 'res_id',
|
||||
string='Temp messages', multi="_get_message_ids",
|
||||
help="Functional field holding messages related to the current document."),
|
||||
'message_subscriber_ids': many2many_model_in_where('res.users',
|
||||
rel='mail_subscription', id1='res_id', id2='user_id', string="Followers",
|
||||
help="Followers of the document. The followers have full access to " \
|
||||
"the document details, as well as the conversation."),
|
||||
'message_state': fields.boolean('Read',
|
||||
help="When checked, new messages require your attention."),
|
||||
'message_summary': fields.function(_get_message_ids, method=True,
|
||||
|
|
Loading…
Reference in New Issue