Skip to content

Commit

Permalink
[IMP] stock_cycle_count: start inv adjustments depending on setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnauCForgeFlow authored and JoanSForgeFlow committed Jun 25, 2024
1 parent 3f52594 commit 3983318
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 8 additions & 1 deletion stock_cycle_count/models/stock_cycle_count.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Copyright 2017-18 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging

from odoo import _, api, fields, models
from odoo.exceptions import UserError

_logger = logging.getLogger(__name__)


class StockCycleCount(models.Model):
_name = "stock.cycle.count"
Expand Down Expand Up @@ -117,7 +120,11 @@ def action_create_inventory_adjustment(self):
inv.prefill_counted_quantity = (
rec.company_id.inventory_adjustment_counted_quantities
)
inv.action_state_to_in_progress()
try:
inv.action_state_to_in_progress()
except Exception as e:
_logger.info("Error when beginning an adjustment: %s", str(e))

if inv.prefill_counted_quantity == "zero":
inv.stock_quant_ids.write({"inventory_quantity": 0})
else:
Expand Down
4 changes: 0 additions & 4 deletions stock_cycle_count/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ def cron_cycle_count(self):
if open_cycle_counts:
continue
cycle_count.action_create_inventory_adjustment()
try:
cycle_count.stock_adjustment_ids.action_state_to_in_progress()
except Exception as e:
_logger.info("Error when beginning an adjustment: %s", str(e))
except Exception as e:
_logger.info("Error while running stock_cycle_count cron job: %s", str(e))
raise
Expand Down

0 comments on commit 3983318

Please sign in to comment.