Skip to content

Commit 659dc7a

Browse files
committed
stock_quant_history_snapshot: improve logging messages
1 parent c3d2112 commit 659dc7a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

stock_quant_history/models/stock_quant_history_snapshot.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ def _generate_stock_quant_history(self):
111111
}
112112
)
113113
)
114-
115114
self.previous_snapshot_id = previous_quant_snapshot
115+
116+
_logger.info("Processing %s from %s", self.name, self.previous_snapshot_id.name)
116117
if previous_quant_snapshot.stock_quant_history_ids.exists():
117-
_logger.info("Duplicate previous stock.quant.history...")
118+
_logger.info(
119+
"Duplicate %s previous stock.quant.history...",
120+
len(previous_quant_snapshot.stock_quant_history_ids),
121+
)
118122
for stock_quant_history in previous_quant_snapshot.stock_quant_history_ids:
119123
# copy is around 3x slower than create !
120124
quant_copy = quant_history[
@@ -126,14 +130,17 @@ def _generate_stock_quant_history(self):
126130
]
127131
quant_copy.quantity = stock_quant_history.quantity
128132

129-
_logger.info("Apply stock.move.line since previous snapshot")
130-
for move_line in (
133+
stock_move_lines = (
131134
self.env["stock.move.line"]
132135
.sudo()
133136
.search(
134137
self._prepare_stock_move_line_filter(previous_quant_snapshot),
135138
)
136-
):
139+
)
140+
_logger.info(
141+
"Apply %s stock.move.line since previous snapshot", len(stock_move_lines)
142+
)
143+
for move_line in stock_move_lines:
137144
quant_history[
138145
(move_line.product_id, move_line.lot_id, move_line.location_id)
139146
].quantity -= move_line.qty_done

0 commit comments

Comments
 (0)