mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_cycle_count: start inv adjustments depending on setting
This commit is contained in:
@@ -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"
|
||||
@@ -117,7 +120,11 @@ class StockCycleCount(models.Model):
|
||||
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:
|
||||
|
||||
@@ -35,7 +35,6 @@ class StockInventory(models.Model):
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
||||
def _update_cycle_state(self):
|
||||
for inv in self:
|
||||
if inv.cycle_count_id and inv.state == "done":
|
||||
|
||||
@@ -158,10 +158,6 @@ class StockWarehouse(models.Model):
|
||||
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
|
||||
|
||||
@@ -77,7 +77,7 @@ class TestStockCycleCount(common.TransactionCase):
|
||||
cls.product1 = cls.product_model.create(
|
||||
{"name": "Test Product 1", "type": "product", "default_code": "PROD1"}
|
||||
)
|
||||
self.product2 = self.product_model.create(
|
||||
cls.product2 = cls.product_model.create(
|
||||
{"name": "Test Product 2", "type": "product", "default_code": "PROD2"}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user