sobjects/notification.py
changeset 9005 63cf580accfc
parent 9004 a3594bf2b6bf
child 9006 e4ea8f9ffa11
--- a/sobjects/notification.py	Wed Jun 12 12:27:00 2013 +0200
+++ b/sobjects/notification.py	Thu Jun 13 12:03:59 2013 +0200
@@ -120,6 +120,7 @@
             if isinstance(something, Entity):
                 # hi-jack self._cw to get a session for the returned user
                 self._cw = Session(something, self._cw.repo)
+                self._cw.set_cnxset()
                 emailaddr = something.cw_adapt_to('IEmailable').get_email()
             else:
                 emailaddr, lang = something
@@ -143,6 +144,10 @@
             msg = format_mail(self.user_data, [emailaddr], content, subject,
                               config=self._cw.vreg.config, msgid=msgid, references=refs)
             yield [emailaddr], msg
+            if isinstance(something, Entity):
+                self._cw.commit()
+                self._cw.close()
+                self._cw = req
         # restore language
         req.set_language(origlang)