From 501e587f2974864811e6daa8e139d2a18485066d Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 12 Dec 2013 13:30:19 +0100 Subject: [PATCH] Add last version of review1961002 which works for me --- issue1961002_40001.diff | 18 ++++++++++++------ series | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/issue1961002_40001.diff b/issue1961002_40001.diff index 9ff7669..8b4e931 100644 --- a/issue1961002_40001.diff +++ b/issue1961002_40001.diff @@ -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 - + + diff --git a/series b/series index 27f97f5..76f2cbe 100644 --- a/series +++ b/series @@ -1,2 +1,3 @@ +issue1961002_40001.diff issue10739.diff issue10467.diff