Merge lp:~unifield-team/unifield-wm/sync-us-1025 into lp:unifield-wm/sync

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/sync-us-1025
Merge into: lp:unifield-wm/sync
Diff against target: 85 lines (+27/-12)
2 files modified
sync_client/update.py (+26/-11)
sync_server/update.py (+1/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/sync-us-1025
Reviewer Review Type Date Requested Status
UniField Sync Reviewer Pending
Review via email: mp+289496@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

639. By jftempo

US-1025 [FIX] Recoved update on sync server

638. By jftempo

US-852 [FIX] AJIs sync: do not execute AJI sync update if the linked JI is not run
If coordo allocates a JI to a project CC, at project the AJI is not linked to a JI, but the update should be executed at project

637. By jftempo

US-852 [FIX] AJI/JI: block the creation of AJI if the relevant JI is not-run
lp:~unifield-team/unifield-wm/sync-852-acc_move_line_empty

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sync_client/update.py'
2--- sync_client/update.py 2016-02-26 09:14:22 +0000
3+++ sync_client/update.py 2016-03-18 13:06:54 +0000
4@@ -449,7 +449,7 @@
5 'execution_date': execution_date,
6 'editable' : False,
7 'run' : True,
8- 'log' : '',
9+ #'log' : '', #SP-228: Do not reset the log message even the update got run.
10 }, context=context)
11 for update_id, log in logs.items():
12 self.write(cr, uid, [update_id], {
13@@ -486,21 +486,29 @@
14 row = eval(update.values)
15
16 #4 check for fallback value : report missing fallback_value
17- self._check_and_replace_missing_id(cr, uid, import_fields, row, fallback, message, context=context)
18+ #US-852: in case the account_move_line is given but not exist, then do not let the import of the current entry
19+ ret_fb = self._check_and_replace_missing_id(cr, uid, import_fields, row, fallback, message, context=context)
20
21 if bad_fields :
22 row = [row[i] for i in range(len(import_fields)) if i not in bad_fields]
23
24- values.append(row)
25- update_ids.append(update.id)
26- versions.append( (update.sdref, update.version) )
27+ if ret_fb: #US-852: if everything is Ok, then do import as normal
28+ values.append(row)
29+ update_ids.append(update.id)
30+ versions.append( (update.sdref, update.version) )
31
32- #1 conflict detection
33- if self._conflict(cr, uid, update.sdref, update.version, context=context):
34- #2 if conflict => manage conflict according rules : report conflict and how it's solve
35- index_id = eval(update.fields).index('id')
36- sd_ref = eval(update.values)[index_id]
37- logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)
38+ #1 conflict detection
39+ if self._conflict(cr, uid, update.sdref, update.version, context=context):
40+ #2 if conflict => manage conflict according rules : report conflict and how it's solve
41+ index_id = eval(update.fields).index('id')
42+ sd_ref = eval(update.values)[index_id]
43+ logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)
44+ else: #US-852: if account_move_line is missing then ignore the import, and set it as not run
45+ self.write(cr, uid, [update.id], {
46+ 'execution_date': datetime.now(),
47+ 'run' : False,
48+ 'log' : "Cannot execute due to missing the account_move_line"
49+ }, context=context)
50
51 if bad_fields:
52 import_fields = [import_fields[i] for i in range(len(import_fields)) if i not in bad_fields]
53@@ -790,6 +798,12 @@
54 raise ValueError
55 except ValueError:
56 try:
57+ #US-852: if account_move_line is given, then cannot use the fallback value, but exit the import!
58+ # THIS FIX COULD ALSO OPEN FOR OTHER BUG, BUT CHECK IF THE RULES THAT CONTAIN THE OBJECT (HERE account_move_line)
59+ if 'account_move_line' in xmlid:
60+ m, sep, sdref = xmlid.partition('.')
61+ if self.search(cr, uid, [('sdref', '=', sdref), ('run', '=', False)], order='NO_ORDER', context=context):
62+ return False
63 fb = fallback.get(field, False)
64 if not fb:
65 raise ValueError("no fallback value defined")
66@@ -806,6 +820,7 @@
67 else:
68 res_val.append(xmlid)
69 values[i] = ','.join(res_val) if res_val else False
70+ return True
71
72 _order = 'create_date desc, id desc'
73
74
75=== modified file 'sync_server/update.py'
76--- sync_server/update.py 2016-01-25 16:33:22 +0000
77+++ sync_server/update.py 2016-03-18 13:06:54 +0000
78@@ -431,7 +431,7 @@
79 filters.append("direction = 'down' AND source IN (" + (','.join(map(str,ancestor))) + ")")
80 filters.append("direction = 'bidirectional'")
81 if recover:
82- filters.append("source = " + entity.id)
83+ filters.append("source = %s" % (entity.id,))
84 filters.append("direction = 'bi-private' AND (is_deleted = 't' OR owner IN (" + (','.join(map(str, children + [entity.id]))) + "))")
85 base_query += ' AND ((' + ') OR ('.join(filters) + '))'
86

Subscribers

People subscribed via source and target branches

to all changes: