[MERGE] OPW 585231: edi: wait longer for parent transaction to complete
authorXavier ALT <xal@openerp.com>
Thu, 28 Feb 2013 15:30:34 +0000 (16:30 +0100)
committerXavier ALT <xal@openerp.com>
Thu, 28 Feb 2013 15:30:34 +0000 (16:30 +0100)
  Wait for parent transaction to complete by watching if it's parent cursor
  has been closed or not. For batch transaction (ex: confirming 50 invoices
  at once using 'Confirm Draft Invoices' wizard) that might take longer
  that 3 seconds! and we end up sending edi mail with old record values.

bzr revid: xal@openerp.com-20130228153034-6ttt05qzwoo02ah4

addons/edi/models/edi.py

index 45fbbbc..7ade5db 100644 (file)
@@ -459,7 +459,11 @@ class EDIMixin(object):
             db = pooler.get_db(cr.dbname)
             local_cr = None
             try:
-                time.sleep(3) # lame workaround to wait for commit of parent transaction
+                # lame workaround to wait for commit of parent transaction
+                wait_try, wait_max_try = 0, 50
+                while not cr._Cursor__closed and wait_try < wait_max_try:
+                    time.sleep(3)
+                    wait_try += 1
                 # grab a fresh browse_record on local cursor
                 local_cr = db.cursor()
                 web_root_url = self.pool.get('ir.config_parameter').get_param(local_cr, uid, 'web.base.url')