I want to send a message to the salesperson assigned to an Account when that account is edited by another user. How to I tie into the ORM to trigger my function on object save? The closest I have gotten is the on_change method on specific fields; I don't want to add this per field.
You can override the write() method of the desired object (e.g.
def write(self, cr, uid, ids, vals, context=None): my_custom_send_mail_function() res = super(my_class, self).write(cr, uid, ids, vals, context=context) return res
But this is a very deep intrusion into the system and may have side effects.
Mabye you can also use
Automated Actions for this purpose. See menu "Settings / Technical / Automated Actions".
You should not develop custom modules for such customizations. Use the base_action_rule module that allows to create such a rule in just a few clicks.
Is it possible to use Automated Actions to trigger client-side wizards/popups? For example, I'm trying to add the ability to detect potential duplicate Partners as a new one is entered (rather than relying on deduplication after the face). You can't trigger a wizard from inside an onchange() where this functionality would be the most useful, but I might be able to trigger a popup when the user attempts to Save a record that could be a duplicate. I've attempted to test this by using Automated Actions to link Partner Create or Write with the Deduplicate Contacts action, but nothing seems to happen.
The solution I found is overwriting the object in questions write() function. I was hoping there was a flag or setting instead, but this does the trick too.
def write(self, cr, uid, ids, vals, context=None): # Function calls and such here return super(sale_order, self).write(cr, uid, ids, vals, context=context)