Review: Needs Fixing

Please don't create "hook" methods, the preferred way to provide `extension 
points` is by making the model methods small enough to make it easy to override 
them when needed.
If overriding the "send()" methods is not sufficient for your need, then try to 
design a clean way of splitting it into smaller methods from which you can find 
the ideal method to override. For example if you're interested in handling the 
post-processing that happens for a mail that was just sent, you could split out 
a method for that and override only this one. Here is an example:
   def _postprocess_sent_message(self, cr, uid, message, context=None):
       """TODO: proper docstring - see other methods!"""
       if message.auto_delete:
           self.pool.get('ir.attachment').unlink(cr, uid,
                                                 [x.id for x in 
message.attachment_ids \
                                                      if x.res_model == 
self._name and \
                                                         x.res_id == 
message.id],
                                                 context=context)
           message.unlink()

and you would call it in send() in place of the code that used to be:
    ...
    message.refresh()   
    if message.state == 'sent':
        self._postprocess_sent_message(cr, uid, message, context=context_
    ...

This way there is no empty hook or magic method to create, it's just a clean 
modular design where each method has its own responsibility and inheriting 
modules may properly extend what they need.


For the other part of the patch, it makes no sense to keep the HTML version of 
the template in the mail composition wizard, especially if it is made 
invisible, because the user will be unable to edit it, so it will presumably 
*not* match what was written! If the user modifies the text, the message 
recipient would still see the original HTML text, because HTML version is 
usually displayed by default in most email clients!
We did not enable the HTML version currently *on purpose* because there is no 
WYSIWYG widget for editing HTML in the web client, so it makes no sense.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_improvement-psi/+merge/97803
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-mail_improvement-psi.

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to