Skip to content

Commit

Permalink
[FIX] stock_cycle_count: prevent creating infinte cycle counts
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnauCForgeFlow committed Jun 27, 2024
1 parent bdc8e31 commit 2e5b1f0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions stock_cycle_count/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,17 @@ def _process_cycle_counts(self, proposed_cycle_counts):
cycle_count_proposed = next(
filter(lambda x: x["date"] == earliest_date, proposed_for_loc)
)
self._handle_existing_cycle_counts(loc, cycle_count_proposed)
existing_cycle_counts = self._handle_existing_cycle_counts(
loc, cycle_count_proposed
)
delta = (
fields.Datetime.from_string(cycle_count_proposed["date"])
- datetime.today()
)
if delta.days < self.cycle_count_planning_horizon:
if (
not existing_cycle_counts
and delta.days < self.cycle_count_planning_horizon
):
cc_vals = self._prepare_cycle_count(cycle_count_proposed)
cc_vals_list.append(cc_vals)
return cc_vals_list
Expand All @@ -137,6 +142,7 @@ def _handle_existing_cycle_counts(self, location, cycle_count_proposed):
"cycle_count_rule_id": cycle_count_proposed["rule_type"].id,
}
)
return existing_cycle_counts

@api.model
def cron_cycle_count(self):
Expand Down

0 comments on commit 2e5b1f0

Please sign in to comment.