Add last version of review1961002 which works for me
This commit is contained in:
parent
569988b939
commit
501e587f29
|
@ -1,11 +1,12 @@
|
|||
Index: trytond/trytond/tests/test_transaction.py
|
||||
===================================================================
|
||||
|
||||
--- a/trytond/trytond/tests/test_transaction.py
|
||||
+++ b/trytond/trytond/tests/test_transaction.py
|
||||
@@ -56,6 +56,41 @@
|
||||
Exception, manipulate_cursor, DB_NAME, USER, context=CONTEXT)
|
||||
self.assertTrue(empty_transaction(DB_NAME, USER, context=CONTEXT))
|
||||
|
||||
|
||||
+ def test0030set_user(self):
|
||||
+ '''
|
||||
+ Test set_user
|
||||
|
@ -41,21 +42,25 @@ Index: trytond/trytond/tests/test_transaction.py
|
|||
+ with Transaction().set_user(2):
|
||||
+ self.assertEqual(transaction.user, 2)
|
||||
+
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(TransactionTestCase)
|
||||
|
||||
Index: trytond/trytond/transaction.py
|
||||
===================================================================
|
||||
|
||||
--- a/trytond/trytond/transaction.py
|
||||
+++ b/trytond/trytond/transaction.py
|
||||
@@ -118,10 +118,15 @@
|
||||
@@ -118,10 +118,16 @@
|
||||
return manager
|
||||
|
||||
|
||||
def set_user(self, user, set_context=False):
|
||||
+ if user != 0 and set_context:
|
||||
+ raise ValueError('set_context only allowed for root')
|
||||
manager = _AttributeManager(user=self.user,
|
||||
context=self.context.copy())
|
||||
- context=self.context.copy())
|
||||
+ context=self.context)
|
||||
+ self.context = self.context.copy()
|
||||
if set_context:
|
||||
- self.context.update({'user': self.user})
|
||||
+ if user != self.user:
|
||||
|
@ -64,4 +69,5 @@ Index: trytond/trytond/transaction.py
|
|||
+ self.context.pop('user', None)
|
||||
self.user = user
|
||||
return manager
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue