Skip to content

Commit

Permalink
[FIX] use batch on planned and replenishment
Browse files Browse the repository at this point in the history
closes #560

X-original-commit: 3fcfa7c
Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
jjscarafia committed Dec 21, 2023
1 parent e0f2e52 commit e0838ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion product_planned_price/models/product_template.py
Expand Up @@ -83,7 +83,7 @@ def cron_update_prices_from_planned(self, batch_size=1000):
domain = [('list_price_type', '!=', False), ('id', '>', int(last_updated_param.value))]
records = self.with_context(prefetch_fields=False).search(domain, order='id asc')

records.with_context(bypass_base_automation=True)._update_prices_from_planned()
records[:batch_size].with_context(bypass_base_automation=True)._update_prices_from_planned()

if len(records) > batch_size:
last_updated_id = records[batch_size].id
Expand Down
4 changes: 2 additions & 2 deletions product_replenishment_cost/models/product_template.py
Expand Up @@ -112,7 +112,7 @@ def cron_update_cost_from_replenishment_cost(self, limit=None, company_ids=None,
if not last_updated_param:
last_updated_param = self.env['ir.config_parameter'].sudo().create({'key': parameter_name, 'value': '0'})
# Obtiene los registros ordenados por id
domain = [('id', '>', int(last_updated_param.value))]
domain = [('id', '>', int(last_updated_param.value))]
records = self.with_context(prefetch_fields=False).search(domain, order='id asc')

# use company_ids or force_company or search for all companies
Expand All @@ -123,7 +123,7 @@ def cron_update_cost_from_replenishment_cost(self, limit=None, company_ids=None,

for company_id in company_ids:
_logger.info('Running cron update cost from replenishment for company %s', company_id)
records.with_company(company=company_id).with_context(bypass_base_automation=True)._update_cost_from_replenishment_cost()
records[:batch_size].with_company(company=company_id).with_context(bypass_base_automation=True)._update_cost_from_replenishment_cost()

if len(records) > batch_size:
last_updated_id = records[batch_size].id
Expand Down

0 comments on commit e0838ab

Please sign in to comment.