openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #26849
[Bug 1188538] Re: mail_thread._message_get_auto_subscribe_fields needs a tracking_visibility to track a field
Hello,
Sorry but it's not something that we want to have currently. We don't want to autoscubscribe every user fields.
We consider autosubscribe fields are quite important (eg: responsible of a task) so it's good to track them (why was I added as follower ? can see in the chatter)
Regards
** Changed in: openobject-addons
Importance: Undecided => Wishlist
** Changed in: openobject-addons
Status: New => Won't Fix
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1188538
Title:
mail_thread._message_get_auto_subscribe_fields needs a
tracking_visibility to track a field
Status in OpenERP Addons (modules):
Won't Fix
Bug description:
Concerns the method
openerp.addons.mail.mail_thread.mail_thread._message_get_auto_subscribe_fields:
def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=['user_id'], context=None):
""" Returns the list of relational fields linking to res.users that should
trigger an auto subscribe. The default list checks for the fields
- called 'user_id'
- linking to res.users
- with track_visibility set
In OpenERP V7, this is sufficent for all major addon such as opportunity,
project, issue, recruitment, sale.
Override this method if a custom behavior is needed about fields
that automatically subscribe users.
"""
user_field_lst = []
for name, column_info in self._all_columns.items():
if name in auto_follow_fields and name in updated_fields and getattr(column_info.column, 'track_visibility', False) and column_info.column._obj == 'res.users':
user_field_lst.append(name)
return user_field_lst
(BTW, unrelated to my issue but the auto_follow_fields arg should
probably not be a mutable argument.)
Use case:
I create a model, I want to automatically subscribe a 'specialist_user_id' when defined so he will receive messages.
Note: the model does not automatically track and displays the changes.
class my_model(orm.Model):
_name = 'my.model'
_inherit = ['mail.thread']
_columns = {
'name': fields.char('Name'),
'user_id': fields.many2one('res.users', string='User'),
'specialist_user_id': fields.many2one('res.users', string='Specialist'),
}
def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=['user_id'], context=None):
follow_fields = ['specialist_user_id']
follow_fields += auto_follow_fields
return super(my_model, self)._message_get_auto_subscribe_fields(cr, uid, updated_fields, auto_follow_fields=follow_fields, context=context)
Result:
user_id and specialist_user_id are not subscribed when changed
Expected:
user_id and specialist_user_id are subscribed when changed
Note:
If I put the _columns:
_columns = {
'name': fields.char('Name'),
'user_id': fields.many2one('res.users', string='User', track_visibility='onchange'),
'specialist_user_id': fields.many2one('res.users', string='Specialist', track_visibility='onchange'),
}
It works, but I don't understand what is the relation between the track_visibility and the auto subscription.
I think that's 2 different things and that I shouldn't need to define a track_visibility to subscribe the users.
Workaround:
Define the columns with a dummy track_visibility as follows:
_columns = {
'name': fields.char('Name'),
'user_id': fields.many2one('res.users', string='User', track_visibility='never'),
'specialist_user_id': fields.many2one('res.users', string='Specialist', track_visibility='never'),
}
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1188538/+subscriptions