diff --git a/stock_cycle_count/models/stock_warehouse.py b/stock_cycle_count/models/stock_warehouse.py index db84413d1418..8585dfc1c70e 100644 --- a/stock_cycle_count/models/stock_warehouse.py +++ b/stock_cycle_count/models/stock_warehouse.py @@ -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 @@ -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):