[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:
Rémy Voet (ryv)
2021-09-03 10:37:48 +00:00
parent 2127ded2b1
commit 6663c05abf
2 changed files with 6 additions and 8 deletions
+3 -5
View File
@@ -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 {}
+3 -3
View File
@@ -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):