[FIX] stock: fix wrong scheduler log.
The logs of the scheduler wasn't correct ( 4467734b77 ):
- The number of object process wasn't correct for the last batch
- Fix Spelling of "commited"
Also, we commit every 1000 moves assignation instead of 100.
(Because the prefetch already prefetch by 1000 and to benefit
futher the batch optimisation of _action_assign).
Part-of: odoo/odoo#75041
This commit is contained in:
@@ -482,14 +482,12 @@ class StockWarehouseOrderpoint(models.Model):
|
||||
This is appropriate for batch jobs only.
|
||||
"""
|
||||
self = self.with_company(company_id)
|
||||
orderpoints_noprefetch = self.read(['id'])
|
||||
orderpoints_noprefetch = [orderpoint['id'] for orderpoint in orderpoints_noprefetch]
|
||||
|
||||
for orderpoints_batch in split_every(1000, orderpoints_noprefetch):
|
||||
for orderpoints_batch_ids in split_every(1000, self.ids):
|
||||
if use_new_cursor:
|
||||
cr = registry(self._cr.dbname).cursor()
|
||||
self = self.with_env(self.env(cr=cr))
|
||||
orderpoints_batch = self.env['stock.warehouse.orderpoint'].browse(orderpoints_batch)
|
||||
orderpoints_batch = self.env['stock.warehouse.orderpoint'].browse(orderpoints_batch_ids)
|
||||
all_orderpoints_exceptions = []
|
||||
while orderpoints_batch:
|
||||
procurements = []
|
||||
@@ -547,7 +545,7 @@ class StockWarehouseOrderpoint(models.Model):
|
||||
if use_new_cursor:
|
||||
cr.commit()
|
||||
cr.close()
|
||||
_logger.info("A batch of 1000 orderpoints is processed and commited")
|
||||
_logger.info("A batch of %d orderpoints is processed and committed", len(orderpoints_batch_ids))
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
@@ -532,18 +532,18 @@ class ProcurementGroup(models.Model):
|
||||
domain = self._get_moves_to_assign_domain(company_id)
|
||||
moves_to_assign = self.env['stock.move'].search(domain, limit=None,
|
||||
order='reservation_date, priority desc, date asc')
|
||||
for moves_chunk in split_every(100, moves_to_assign.ids):
|
||||
for moves_chunk in split_every(1000, moves_to_assign.ids):
|
||||
self.env['stock.move'].browse(moves_chunk).sudo()._action_assign()
|
||||
if use_new_cursor:
|
||||
self._cr.commit()
|
||||
_logger.info("A batch of 100 moves are assigned and commited")
|
||||
_logger.info("A batch of %d moves are assigned and committed", len(moves_chunk))
|
||||
|
||||
# Merge duplicated quants
|
||||
self.env['stock.quant']._quant_tasks()
|
||||
|
||||
if use_new_cursor:
|
||||
self._cr.commit()
|
||||
_logger.info("_run_scheduler_tasks is finished and commited")
|
||||
_logger.info("_run_scheduler_tasks is finished and committed")
|
||||
|
||||
@api.model
|
||||
def run_scheduler(self, use_new_cursor=False, company_id=False):
|
||||
|
||||
Reference in New Issue
Block a user