Mi comincio a rispondere da solo ( ho fatto un po' di reverse engineering).
In generale la questione delle notifiche è un gran casino. Nel caso specifico (cambio agente sul nominativo, ma vale anche per altri modelli) il codice è "inghisato" nella classe mail_thread e più precisamente qui:
def _message_auto_subscribe_followers(self, updated_values, default_subtype_ids):
""" Optional method to override in addons inheriting from mail.thread.
Return a list tuples containing (
partner ID,
subtype IDs (or False if model-based default subtypes),
QWeb template XML ID for notification (or False is no specific
notification is required),
), aka partners and their subtype and possible notification to send
using the auto subscription mechanism linked to updated values.
Default value of this method is to return the new responsible of
documents. This is done using relational fields linking to res.users
with track_visibility set. Since OpenERP v7 it is considered as being
responsible for the document and therefore standard behavior is to
subscribe the user and send him a notification.
Override this method to change that behavior and/or to add people to
notify, using possible custom notification.
:param updated_values: see ``_message_auto_subscribe``
:param default_subtype_ids: coming from ``_get_auto_subscription_subtypes``
"""
fnames = []
field = self._fields.get('user_id')
user_id = updated_values.get('user_id')
if field and user_id and field.comodel_name == 'res.users' and (getattr(field, 'track_visibility', False) or getattr(field, 'tracking', False)):
user = self.env['res.users'].sudo().browse(user_id)
try: # avoid to make an exists, lets be optimistic and try to read it.
if user.active:
return [(user.partner_id.id, default_subtype_ids, 'mail.message_user_assigned' if user != self.env.user else False)]
except:
pass
return []
Da cui si evince che se nel modello c'è un campo che si chiama "user_id", che sia collegato alla "res.users" ed abbia il tracking attivato, allora viene inserito di default tra i follower. E non ci sono ca22i.
Detto questo ho poi scoperto che alcune cose possono essere gestite opportunamente disabilitando le cose dal contesto.
Nello specifico al momento io sto usando tutti i modificatori che ho trovato
es:
partner_model.with_context(
mail_create_nosubscribe=True,
mail_auto_subscribe_no_notify=True,
mail_create_nolog=True,
mail_notify_force_send=False,
tracking_disable=True
).write(...)
e sembra funzionare ( meglio non manda mail ne scrive nel chatter).
Comunque la classe incriminata è questa:
class MailThread(models.AbstractModel):
''' mail_thread model is meant to be inherited by any model that needs to
act as a discussion topic on which messages can be attached. Public
methods are prefixed with ``message_`` in order to avoid name
collisions with methods of the models that will inherit from this class.
``mail.thread`` defines fields used to handle and display the
communication history. ``mail.thread`` also manages followers of
inheriting classes. All features and expected behavior are managed
by mail.thread. Widgets has been designed for the 7.0 and following
versions of Odoo.
Inheriting classes are not required to implement any method, as the
default implementation will work for any model. However it is common
to override at least the ``message_new`` and ``message_update``
methods (calling ``super``) to add model-specific behavior at
creation and update of a thread when processing incoming emails.
Options:
- _mail_flat_thread: if set to True, all messages without parent_id
are automatically attached to the first message posted on the
ressource. If set to False, the display of Chatter is done using
threads, and no parent_id is automatically set.
MailThread features can be somewhat controlled through context keys :
- ``mail_create_nosubscribe``: at create or message_post, do not subscribe
uid to the record thread
- ``mail_create_nolog``: at create, do not log the automatic '<Document>
created' message
- ``mail_notrack``: at create and write, do not perform the value tracking
creating messages
- ``tracking_disable``: at create and write, perform no MailThread features
(auto subscription, tracking, post, ...)
- ``mail_notify_force_send``: if less than 50 email notifications to send,
send them directly instead of using the queue; True by default
'''
Ad majora!