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
1=== modified file 'sync_client/orm.py'
2--- sync_client/orm.py 2014-07-24 12:14:44 +0000
3+++ sync_client/orm.py 2014-09-17 12:20:52 +0000
4@@ -260,6 +260,13 @@
5 "Please update the server to the latest version."
6 assert synchronize or previous_values is not None, \
7 "This call is useless"
8+
9+ # UF-2272
10+ # enumeration of models where to skip their one2many(s)
11+ # was decided to do a specific skip versus global impact of touch...
12+ write_skip_o2m = [
13+ 'supplier.catalogue',
14+ ]
15
16 _previous_calls = _previous_calls or []
17 me = (self._name, ids)
18@@ -350,6 +357,10 @@
19 # handle one2many (because orm don't call write() on them)
20 if synchronize:
21 for field, column in filter_o2m(whole_fields):
22+ if context.get('from_orm_write', False) and \
23+ write_skip_o2m and self._name in write_skip_o2m:
24+ # UF-2272 skip model's one2many(s)
25+ continue
26 self.pool.get(column._obj).touch(
27 cr, uid, list(set(prev_rec[field] + next_rec[field])),
28 None, data_base_values,
29@@ -506,10 +517,15 @@
30 audit_obj.audit_log(cr, uid, audit_rule_ids, self, ids, 'write', previous_values, current_values, context=context)
31
32 if to_be_synchronized or hasattr(self, 'on_change'):
33+ # UF-2272 flag we are in orm write (for touch() function)
34+ from_orm_write = context.get('from_orm_write', True)
35+ context['from_orm_write'] = from_orm_write
36 changes = self.touch(cr, uid, ids, previous_values,
37 to_be_synchronized, current_values=current_values, context=context)
38 if hasattr(self, 'on_change'):
39 self.on_change(cr, uid, changes, context=context)
40+ if from_orm_write:
41+ del context['from_orm_write']
42 return result
43
44 # 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: