[FIX] stock: do not propagate date when negative delta
In Pick - Ship: - validate a sale order which scheduled date is an hour in the future. - validate the WH/PICK picking Before this commit the WH/OUT picking 's scheduled date was set a day in the **past** This was due to the implementation of datetime substraction and timedelta, which, in case of a negative value, would take -1 day and some complementary values (hours, minutes etc...) (the difference is complementary) After this commit, the WH/OUT picking 's scheduled date stays what it was in that particular use case. OPW 784452
This commit is contained in:
@@ -283,7 +283,7 @@ class StockMove(models.Model):
|
||||
if propagated_date_field:
|
||||
current_date = datetime.strptime(move.date_expected, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
new_date = datetime.strptime(vals.get(propagated_date_field), DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
delta = new_date - current_date
|
||||
delta = relativedelta.relativedelta(new_date, current_date)
|
||||
if abs(delta.days) >= move.company_id.propagation_minimum_delta:
|
||||
old_move_date = datetime.strptime(move.move_dest_id.date_expected, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
new_move_date = (old_move_date + relativedelta.relativedelta(days=delta.days or 0)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
Reference in New Issue
Block a user