Merge lp:~unifield-team/unifield-wm/sync-852-acc_move_line_empty into lp:unifield-wm/sync

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/sync-852-acc_move_line_empty
Merge into: lp:unifield-wm/sync
Diff against target: 77 lines (+27/-14)
1 file modified
sync_client/update.py (+27/-14)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/sync-852-acc_move_line_empty
Reviewer Review Type Date Requested Status
UniField Sync Reviewer Pending
Review via email: mp+288620@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

639. By Duy VO

SP-228: Do not reset the log message when the update got run. Keep for analysis purpose

638. By Duy VO

US-852: Moved code

637. By Duy VO

US-852: if account_move_line is given and if the value does not exist, then do not import the current update sync

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-10 09:45:25 +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@@ -484,23 +484,31 @@
14 for update in updates:
15
16 row = eval(update.values)
17-
18+
19 #4 check for fallback value : report missing fallback_value
20- self._check_and_replace_missing_id(cr, uid, import_fields, row, fallback, message, context=context)
21+ #US-852: in case the account_move_line is given but not exist, then do not let the import of the current entry
22+ ret_fb = self._check_and_replace_missing_id(cr, uid, import_fields, row, fallback, message, context=context)
23
24 if bad_fields :
25 row = [row[i] for i in range(len(import_fields)) if i not in bad_fields]
26
27- values.append(row)
28- update_ids.append(update.id)
29- versions.append( (update.sdref, update.version) )
30-
31- #1 conflict detection
32- if self._conflict(cr, uid, update.sdref, update.version, context=context):
33- #2 if conflict => manage conflict according rules : report conflict and how it's solve
34- index_id = eval(update.fields).index('id')
35- sd_ref = eval(update.values)[index_id]
36- logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)
37+ if ret_fb: #US-852: if everything is Ok, then do import as normal
38+ values.append(row)
39+ update_ids.append(update.id)
40+ versions.append( (update.sdref, update.version) )
41+
42+ #1 conflict detection
43+ if self._conflict(cr, uid, update.sdref, update.version, context=context):
44+ #2 if conflict => manage conflict according rules : report conflict and how it's solve
45+ index_id = eval(update.fields).index('id')
46+ sd_ref = eval(update.values)[index_id]
47+ logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)
48+ else: #US-852: if account_move_line is missing then ignore the import, and set it as not run
49+ self.write(cr, uid, [update.id], {
50+ 'execution_date': datetime.now(),
51+ 'run' : False,
52+ 'log' : "Cannot execute due to missing the account_move_line"
53+ }, context=context)
54
55 if bad_fields:
56 import_fields = [import_fields[i] for i in range(len(import_fields)) if i not in bad_fields]
57@@ -790,6 +798,10 @@
58 raise ValueError
59 except ValueError:
60 try:
61+ #US-852: if account_move_line is given, then cannot use the fallback value, but exit the import!
62+ # THIS FIX COULD ALSO OPEN FOR OTHER BUG, BUT CHECK IF THE RULES THAT CONTAIN THE OBJECT (HERE account_move_line)
63+ if 'account_move_line' in xmlid:
64+ return False
65 fb = fallback.get(field, False)
66 if not fb:
67 raise ValueError("no fallback value defined")
68@@ -806,7 +818,8 @@
69 else:
70 res_val.append(xmlid)
71 values[i] = ','.join(res_val) if res_val else False
72-
73+ return True
74+
75 _order = 'create_date desc, id desc'
76
77 update_received()

Subscribers

People subscribed via source and target branches

to all changes: