Merge lp:~fabien-morin/unifield-server/fm-uf3-0rc1_small_fixes into lp:unifield-server

Proposed by Fabien MORIN
Status: Needs review
Proposed branch: lp:~fabien-morin/unifield-server/fm-uf3-0rc1_small_fixes
Merge into: lp:unifield-server
Diff against target: 87 lines (+20/-10)
4 files modified
bin/addons/base/ir/ir_actions.py (+2/-1)
bin/addons/base/res/res_user.py (+6/-4)
bin/addons/sync_client/operations.py (+4/-2)
bin/addons/sync_client/sync_client.py (+8/-3)
To merge this branch: bzr merge lp:~fabien-morin/unifield-server/fm-uf3-0rc1_small_fixes
Reviewer Review Type Date Requested Status
jftempo Pending
Review via email: mp+311630@code.launchpad.net

Description of the change

this should fix the problem of sync_server where we cannot login because of the new "synchronize" property on res_users.

To post a comment you must log in.
4086. By Fabien MORIN

[FIX] it's needed here too not to browse all fields of res.users to avoid crash
when a new property has been added to this model and the modules haven't been
upgraded yet.

Unmerged revisions

4086. By Fabien MORIN

[FIX] it's needed here too not to browse all fields of res.users to avoid crash
when a new property has been added to this model and the modules haven't been
upgraded yet.

4085. By Fabien MORIN

[FIX] add the possibility to pass fields_to_fetch to get_entity and res_users.
This is made possible to login on sync_server when some new properties have been added to this
models but the module upgrade have not been done.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/addons/base/ir/ir_actions.py'
--- bin/addons/base/ir/ir_actions.py 2016-11-08 16:43:27 +0000
+++ bin/addons/base/ir/ir_actions.py 2016-11-24 16:58:14 +0000
@@ -249,7 +249,8 @@
249 return res249 return res
250250
251 def _get_help_status(self, cr, uid, ids, name, arg, context=None):251 def _get_help_status(self, cr, uid, ids, name, arg, context=None):
252 activate_tips = self.pool.get('res.users').browse(cr, uid, uid).menu_tips252 activate_tips = self.pool.get('res.users').browse(cr, uid, uid,
253 fields_to_fetch=['menu_tips']).menu_tips
253 return dict([(id, activate_tips) for id in ids])254 return dict([(id, activate_tips) for id in ids])
254255
255 def _get_groups_txt(self, cr, uid, ids, name, arg, context=None):256 def _get_groups_txt(self, cr, uid, ids, name, arg, context=None):
256257
=== modified file 'bin/addons/base/res/res_user.py'
--- bin/addons/base/res/res_user.py 2016-11-21 09:55:11 +0000
+++ bin/addons/base/res/res_user.py 2016-11-24 16:58:14 +0000
@@ -515,11 +515,13 @@
515 return super(users, self).copy(cr, uid, id, copydef, context)515 return super(users, self).copy(cr, uid, id, copydef, context)
516516
517 def context_get(self, cr, uid, context=None):517 def context_get(self, cr, uid, context=None):
518 user = self.browse(cr, uid, uid, context)
519 result = {}518 result = {}
520 for k in self._columns.keys():519 fields_to_fetch = [k for k in self._columns.keys() if k.startswith('context_')]
521 if k.startswith('context_'):520 if fields_to_fetch:
522 res = getattr(user,k) or False521 user = self.browse(cr, uid, uid, context=context,
522 fields_to_fetch=fields_to_fetch)
523 for k in fields_to_fetch:
524 res = getattr(user, k) or False
523 if isinstance(res, browse_record):525 if isinstance(res, browse_record):
524 res = res.id526 res = res.id
525 result[k[8:]] = res or False527 result[k[8:]] = res or False
526528
=== modified file 'bin/addons/sync_client/operations.py'
--- bin/addons/sync_client/operations.py 2016-11-08 15:31:23 +0000
+++ bin/addons/sync_client/operations.py 2016-11-24 16:58:14 +0000
@@ -130,7 +130,8 @@
130 _logger = logging.getLogger('operations.event')130 _logger = logging.getLogger('operations.event')
131131
132 def _get_inst(self, cr, uid):132 def _get_inst(self, cr, uid):
133 i = self.pool.get('sync.client.entity').get_entity(cr, uid).name;133 i = self.pool.get('sync.client.entity').get_entity(cr, uid,
134 fields_to_fetch=['name']).name;
134 if i is None:135 if i is None:
135 return "unknown"136 return "unknown"
136 return i137 return i
@@ -198,7 +199,8 @@
198 self.histogram['sql'] = Histogram( buckets=20, name='sql')199 self.histogram['sql'] = Histogram( buckets=20, name='sql')
199200
200 def _get_inst(self, cr, uid):201 def _get_inst(self, cr, uid):
201 i = self.pool.get('sync.client.entity').get_entity(cr, uid).name;202 i = self.pool.get('sync.client.entity').get_entity(cr, uid,
203 fields_to_fetch=['name']).name;
202 if i is None:204 if i is None:
203 return "unknown"205 return "unknown"
204 return i206 return i
205207
=== modified file 'bin/addons/sync_client/sync_client.py'
--- bin/addons/sync_client/sync_client.py 2016-11-18 13:31:06 +0000
+++ bin/addons/sync_client/sync_client.py 2016-11-24 16:58:14 +0000
@@ -466,15 +466,20 @@
466 'message_last' : 0,466 'message_last' : 0,
467 }467 }
468468
469 def get_entity(self, cr, uid, context=None):469 def get_entity(self, cr, uid, context=None, fields_to_fetch=None):
470 ids = self.search(cr, uid, [], context=context)470 ids = self.search(cr, uid, [], context=context)
471 return self.browse(cr, uid, ids, context=context)[0]471 if fields_to_fetch is None:
472 fields_to_fetch = []
473 return self.browse(cr, uid, ids, context=context,
474 fields_to_fetch=fields_to_fetch)[0]
472475
473 def _get_entity(self, cr):476 def _get_entity(self, cr, fields_to_fetch=None):
474 """477 """
475 private method to get entity with uid = 1478 private method to get entity with uid = 1
476 """479 """
477 ids = self.search(cr, 1, [])480 ids = self.search(cr, 1, [])
481 if fields_to_fetch:
482 return self.browse(cr, 1, ids, fields_to_fetch=fields_to_fetch)[0]
478 return self.browse(cr, 1, ids)[0]483 return self.browse(cr, 1, ids)[0]
479484
480 def generate_uuid(self):485 def generate_uuid(self):

Subscribers

People subscribed via source and target branches