mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_cycle_count: prevent creating infinte cycle counts
This commit is contained in:
@@ -106,12 +106,17 @@ class StockWarehouse(models.Model):
|
||||
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 @@ class StockWarehouse(models.Model):
|
||||
"cycle_count_rule_id": cycle_count_proposed["rule_type"].id,
|
||||
}
|
||||
)
|
||||
return existing_cycle_counts
|
||||
|
||||
@api.model
|
||||
def cron_cycle_count(self):
|
||||
|
||||
Reference in New Issue
Block a user