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
=== modified file 'sync_client/update.py'
--- sync_client/update.py 2016-02-26 09:14:22 +0000
+++ sync_client/update.py 2016-03-10 09:45:25 +0000
@@ -449,7 +449,7 @@
449 'execution_date': execution_date,449 'execution_date': execution_date,
450 'editable' : False,450 'editable' : False,
451 'run' : True,451 'run' : True,
452 'log' : '',452 #'log' : '', #SP-228: Do not reset the log message even the update got run.
453 }, context=context)453 }, context=context)
454 for update_id, log in logs.items():454 for update_id, log in logs.items():
455 self.write(cr, uid, [update_id], {455 self.write(cr, uid, [update_id], {
@@ -484,23 +484,31 @@
484 for update in updates:484 for update in updates:
485485
486 row = eval(update.values)486 row = eval(update.values)
487487
488 #4 check for fallback value : report missing fallback_value488 #4 check for fallback value : report missing fallback_value
489 self._check_and_replace_missing_id(cr, uid, import_fields, row, fallback, message, context=context)489 #US-852: in case the account_move_line is given but not exist, then do not let the import of the current entry
490 ret_fb = self._check_and_replace_missing_id(cr, uid, import_fields, row, fallback, message, context=context)
490491
491 if bad_fields :492 if bad_fields :
492 row = [row[i] for i in range(len(import_fields)) if i not in bad_fields]493 row = [row[i] for i in range(len(import_fields)) if i not in bad_fields]
493494
494 values.append(row)495 if ret_fb: #US-852: if everything is Ok, then do import as normal
495 update_ids.append(update.id)496 values.append(row)
496 versions.append( (update.sdref, update.version) )497 update_ids.append(update.id)
497498 versions.append( (update.sdref, update.version) )
498 #1 conflict detection499
499 if self._conflict(cr, uid, update.sdref, update.version, context=context):500 #1 conflict detection
500 #2 if conflict => manage conflict according rules : report conflict and how it's solve501 if self._conflict(cr, uid, update.sdref, update.version, context=context):
501 index_id = eval(update.fields).index('id')502 #2 if conflict => manage conflict according rules : report conflict and how it's solve
502 sd_ref = eval(update.values)[index_id]503 index_id = eval(update.fields).index('id')
503 logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)504 sd_ref = eval(update.values)[index_id]
505 logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)
506 else: #US-852: if account_move_line is missing then ignore the import, and set it as not run
507 self.write(cr, uid, [update.id], {
508 'execution_date': datetime.now(),
509 'run' : False,
510 'log' : "Cannot execute due to missing the account_move_line"
511 }, context=context)
504512
505 if bad_fields:513 if bad_fields:
506 import_fields = [import_fields[i] for i in range(len(import_fields)) if i not in bad_fields]514 import_fields = [import_fields[i] for i in range(len(import_fields)) if i not in bad_fields]
@@ -790,6 +798,10 @@
790 raise ValueError798 raise ValueError
791 except ValueError:799 except ValueError:
792 try:800 try:
801 #US-852: if account_move_line is given, then cannot use the fallback value, but exit the import!
802 # THIS FIX COULD ALSO OPEN FOR OTHER BUG, BUT CHECK IF THE RULES THAT CONTAIN THE OBJECT (HERE account_move_line)
803 if 'account_move_line' in xmlid:
804 return False
793 fb = fallback.get(field, False)805 fb = fallback.get(field, False)
794 if not fb:806 if not fb:
795 raise ValueError("no fallback value defined")807 raise ValueError("no fallback value defined")
@@ -806,7 +818,8 @@
806 else:818 else:
807 res_val.append(xmlid)819 res_val.append(xmlid)
808 values[i] = ','.join(res_val) if res_val else False820 values[i] = ','.join(res_val) if res_val else False
809821 return True
822
810 _order = 'create_date desc, id desc'823 _order = 'create_date desc, id desc'
811824
812update_received()825update_received()

Subscribers

People subscribed via source and target branches

to all changes: