Reviewers: ,


Please review this at http://codereview.tryton.org/707002/

Affected files:
  M trytond/model/modelstorage.py


Index: trytond/model/modelstorage.py
===================================================================
--- a/trytond/model/modelstorage.py
+++ b/trytond/model/modelstorage.py
@@ -1407,20 +1407,25 @@
         return values

     def save(self):
-        values = self._save_values
-        if values or self.id < 0:
-            with contextlib.nested(Transaction().set_cursor(self._cursor),
-                    Transaction().set_user(self._user),
-                    Transaction().set_context(self._context)):
-                if self.id < 0:
-                    self._ids.remove(self.id)
-                    try:
-                        self.id = self.create([values])[0].id
-                    finally:
-                        self._ids.append(self.id)
-                else:
-                    self.write([self], values)
+        save_values = self._save_values
+        values = self._values
         self._values = None
+        if save_values or self.id < 0:
+            try:
+ with contextlib.nested(Transaction().set_cursor(self._cursor),
+                        Transaction().set_user(self._user),
+                        Transaction().set_context(self._context)):
+                    if self.id < 0:
+                        self._ids.remove(self.id)
+                        try:
+                            self.id = self.create([save_values])[0].id
+                        finally:
+                            self._ids.append(self.id)
+                    else:
+                        self.write([self], save_values)
+            except:
+                self._values = values
+                raise


 class EvalEnvironment(dict):


--
--
[email protected] mailing list

--- You received this message because you are subscribed to the Google Groups "tryton-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to