Merge lp:~unifield-team/unifield-wm/uf-2272-sync into lp:unifield-wm/sync

Proposed by jftempo
Status: Merged
Merged at revision: 485
Proposed branch: lp:~unifield-team/unifield-wm/uf-2272-sync
Merge into: lp:unifield-wm/sync
Diff against target: 44 lines (+16/-0)
1 file modified
sync_client/orm.py (+16/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/uf-2272-sync
Reviewer Review Type Date Requested Status
UniField Sync Reviewer Pending
Review via email: mp+234952@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'sync_client/orm.py'
--- sync_client/orm.py 2014-07-24 12:14:44 +0000
+++ sync_client/orm.py 2014-09-17 12:20:52 +0000
@@ -260,6 +260,13 @@
260 "Please update the server to the latest version."260 "Please update the server to the latest version."
261 assert synchronize or previous_values is not None, \261 assert synchronize or previous_values is not None, \
262 "This call is useless"262 "This call is useless"
263
264 # UF-2272
265 # enumeration of models where to skip their one2many(s)
266 # was decided to do a specific skip versus global impact of touch...
267 write_skip_o2m = [
268 'supplier.catalogue',
269 ]
263270
264 _previous_calls = _previous_calls or []271 _previous_calls = _previous_calls or []
265 me = (self._name, ids)272 me = (self._name, ids)
@@ -350,6 +357,10 @@
350 # handle one2many (because orm don't call write() on them)357 # handle one2many (because orm don't call write() on them)
351 if synchronize:358 if synchronize:
352 for field, column in filter_o2m(whole_fields):359 for field, column in filter_o2m(whole_fields):
360 if context.get('from_orm_write', False) and \
361 write_skip_o2m and self._name in write_skip_o2m:
362 # UF-2272 skip model's one2many(s)
363 continue
353 self.pool.get(column._obj).touch(364 self.pool.get(column._obj).touch(
354 cr, uid, list(set(prev_rec[field] + next_rec[field])),365 cr, uid, list(set(prev_rec[field] + next_rec[field])),
355 None, data_base_values,366 None, data_base_values,
@@ -506,10 +517,15 @@
506 audit_obj.audit_log(cr, uid, audit_rule_ids, self, ids, 'write', previous_values, current_values, context=context)517 audit_obj.audit_log(cr, uid, audit_rule_ids, self, ids, 'write', previous_values, current_values, context=context)
507518
508 if to_be_synchronized or hasattr(self, 'on_change'):519 if to_be_synchronized or hasattr(self, 'on_change'):
520 # UF-2272 flag we are in orm write (for touch() function)
521 from_orm_write = context.get('from_orm_write', True)
522 context['from_orm_write'] = from_orm_write
509 changes = self.touch(cr, uid, ids, previous_values,523 changes = self.touch(cr, uid, ids, previous_values,
510 to_be_synchronized, current_values=current_values, context=context)524 to_be_synchronized, current_values=current_values, context=context)
511 if hasattr(self, 'on_change'):525 if hasattr(self, 'on_change'):
512 self.on_change(cr, uid, changes, context=context)526 self.on_change(cr, uid, changes, context=context)
527 if from_orm_write:
528 del context['from_orm_write']
513 return result529 return result
514530
515 # BECAREFUL: This method is ONLY for deleting account.analytic.line by sync. NOT GENERIC!531 # BECAREFUL: This method is ONLY for deleting account.analytic.line by sync. NOT GENERIC!

Subscribers

People subscribed via source and target branches

to all changes: