Merge lp:~jfb-tempo-consulting/unifield-server/US-4490 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4925
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-4490
Merge into: lp:unifield-server
Diff against target: 125 lines (+49/-13)
3 files modified
bin/addons/msf_homere_interface/hr.py (+21/-0)
bin/addons/msf_outgoing/msf_outgoing.py (+10/-3)
bin/addons/sync_client/update.py (+18/-10)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-4490
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+343621@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 'bin/addons/msf_homere_interface/hr.py'
--- bin/addons/msf_homere_interface/hr.py 2017-10-27 12:04:12 +0000
+++ bin/addons/msf_homere_interface/hr.py 2018-04-19 14:23:11 +0000
@@ -116,6 +116,27 @@
116 'ex_allow_edition': lambda *a: True,116 'ex_allow_edition': lambda *a: True,
117 }117 }
118118
119 def _set_sync_update_as_run(self, cr, uid, data, sdref, context=None):
120 if not data.get('identification_id') or not data.get('name'):
121 return False
122
123 employee_name = data['name'].strip()
124 existing_id = self.find_sd_ref(cr, uid, sdref)
125 if not existing_id:
126 # never run, but exists with the same id and name => ignore
127 if self.search_exist(cr, uid, [('identification_id', '=', data['identification_id']), ('name', '=', employee_name)]):
128 return True
129
130 else:
131 same_ids = self.search(cr, uid, [('identification_id', '=', data['identification_id']), ('name', '=', employee_name)])
132 if same_ids and existing_id not in same_ids:
133 # Run on the instance but has a different Employee ID (identification_id) than on the one run on the instance
134 return True
135
136 return False
137
138
139
119 def _check_unicity(self, cr, uid, ids, context=None):140 def _check_unicity(self, cr, uid, ids, context=None):
120 """141 """
121 Check that identification_id is not used yet.142 Check that identification_id is not used yet.
122143
=== modified file 'bin/addons/msf_outgoing/msf_outgoing.py'
--- bin/addons/msf_outgoing/msf_outgoing.py 2018-04-03 12:31:40 +0000
+++ bin/addons/msf_outgoing/msf_outgoing.py 2018-04-19 14:23:11 +0000
@@ -3365,6 +3365,7 @@
3365 picking = wizard.picking_id3365 picking = wizard.picking_id
3366 new_picking_id = False3366 new_picking_id = False
3367 processed_moves = []3367 processed_moves = []
3368 new_split_move = {}
3368 move_data = {}3369 move_data = {}
3369 for line in wizard.move_ids:3370 for line in wizard.move_ids:
3370 move = line.move_id3371 move = line.move_id
@@ -3376,6 +3377,7 @@
3376 move_data.setdefault(move.id, {3377 move_data.setdefault(move.id, {
3377 'original_qty': move.product_qty,3378 'original_qty': move.product_qty,
3378 'processed_qty': 0.00,3379 'processed_qty': 0.00,
3380 'total_qty': move.product_qty,
3379 })3381 })
33803382
3381 if line.quantity <= 0.00:3383 if line.quantity <= 0.00:
@@ -3421,10 +3423,15 @@
3421 # Create a new move3423 # Create a new move
3422 new_move_id = move_obj.copy(cr, uid, move.id, values, context=context)3424 new_move_id = move_obj.copy(cr, uid, move.id, values, context=context)
3423 processed_moves.append(new_move_id)3425 processed_moves.append(new_move_id)
3426 new_split_move[new_move_id] = True
3427
3424 # Update the original move3428 # Update the original move
3429
3430 # here we can't use move.product_qty bc this value is bowser_record cached on not flush with the following write
3431 move_data[move.id]['total_qty'] -= quantity
3425 wr_vals = {3432 wr_vals = {
3426 'product_qty': move.product_qty - quantity,3433 'product_qty': move_data[move.id]['total_qty'],
3427 'product_uos_qty': move.product_qty - quantity,3434 'product_uos_qty': move_data[move.id]['total_qty'],
3428 }3435 }
3429 move_obj.write(cr, uid, [move.id], wr_vals, context=context)3436 move_obj.write(cr, uid, [move.id], wr_vals, context=context)
3430 else:3437 else:
@@ -3447,7 +3454,7 @@
3447 # If not, create a backorder3454 # If not, create a backorder
3448 need_new_picking = False3455 need_new_picking = False
3449 for move in picking.move_lines:3456 for move in picking.move_lines:
3450 if move.state not in ('done', 'cancel') and (not move_data.get(move.id, False) or \3457 if not new_split_move.get(move.id) and move.state not in ('done', 'cancel') and (not move_data.get(move.id, False) or \
3451 move_data[move.id]['original_qty'] != move_data[move.id]['processed_qty']):3458 move_data[move.id]['original_qty'] != move_data[move.id]['processed_qty']):
3452 need_new_picking = True3459 need_new_picking = True
3453 break3460 break
34543461
=== modified file 'bin/addons/sync_client/update.py'
--- bin/addons/sync_client/update.py 2017-09-19 12:24:09 +0000
+++ bin/addons/sync_client/update.py 2018-04-19 14:23:11 +0000
@@ -572,16 +572,24 @@
572 row = [row[i] for i in range(len(import_fields)) if i not in bad_fields]572 row = [row[i] for i in range(len(import_fields)) if i not in bad_fields]
573573
574 if result['res']: #US-852: if everything is Ok, then do import as normal574 if result['res']: #US-852: if everything is Ok, then do import as normal
575 values.append(row)575 if obj._name == 'hr.employee' and obj._set_sync_update_as_run(cr, uid, dict(zip(import_fields, row)), update.sdref, context=context):
576 update_ids.append(update.id)576 self.write(cr, uid, update.id, {
577 versions.append( (update.sdref, update.version) )577 'run': True,
578 'editable': False,
579 'execution_date': datetime.now(),
580 'log': 'Set as Run because this employee already exists in the instance',
581 })
582 else:
583 values.append(row)
584 update_ids.append(update.id)
585 versions.append( (update.sdref, update.version) )
578586
579 #1 conflict detection587 #1 conflict detection
580 if self._conflict(cr, uid, update.sdref, update.version, context=context):588 if self._conflict(cr, uid, update.sdref, update.version, context=context):
581 #2 if conflict => manage conflict according rules : report conflict and how it's solve589 #2 if conflict => manage conflict according rules : report conflict and how it's solve
582 index_id = eval(update.fields).index('id')590 index_id = eval(update.fields).index('id')
583 sd_ref = eval(update.values)[index_id]591 sd_ref = eval(update.values)[index_id]
584 logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)592 logs[update.id] = "Warning: Conflict detected! in content: (%s, %r)" % (update.id, sd_ref)
585 else: #US-852: if account_move_line is missing then ignore the import, and set it as not run593 else: #US-852: if account_move_line is missing then ignore the import, and set it as not run
586 self._set_not_run(cr, uid, [update.id],594 self._set_not_run(cr, uid, [update.id],
587 log=result['error_message'],595 log=result['error_message'],
@@ -911,7 +919,7 @@
911 except ValueError:919 except ValueError:
912 try:920 try:
913 #US-852: if account_move_line is given, then cannot use the fallback value, but exit the import!921 #US-852: if account_move_line is given, then cannot use the fallback value, but exit the import!
914 # THIS FIX COULD ALSO OPEN FOR OTHER BUG, BUT CHECK IF THE RULES THAT CONTAIN THE OBJECT (HERE account_move_line) 922 # THIS FIX COULD ALSO OPEN FOR OTHER BUG, BUT CHECK IF THE RULES THAT CONTAIN THE OBJECT (HERE account_move_line)
915 if 'account_move_line' in xmlid:923 if 'account_move_line' in xmlid:
916 m, sep, sdref = xmlid.partition('.')924 m, sep, sdref = xmlid.partition('.')
917 if self.search(cr, uid, [('sdref', '=', sdref), ('run', '=', False)], order='NO_ORDER', context=context):925 if self.search(cr, uid, [('sdref', '=', sdref), ('run', '=', False)], order='NO_ORDER', context=context):

Subscribers

People subscribed via source and target branches