تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
352 أدوات العرض

Cronjob are executed in _run_job method (/odoo/addons/base/models/ir_cron.py)

def _run_job(cls, job):
...
cron, progress = cron._add_progress(timed_out_counter=timed_out_counter)
...
cron._callback(job['cron_name'], job['ir_actions_server_id'])
...
_logger.info('Job %r (%s) processed %s records, %s records remaining',
             job['cron_name'], job['id'], progress.done, progress.remaining)
  • an ir.cron.progress record is created inside _add_progress method, 
  • the ir.cron.progress record id is set inside the cronjob context using key'ir_cron_progress_id'
  • the previously created progress record is used to log the number of processed and remaining records

Inside our cronjob, we 

  • get the progress_id related to this cronjob using the context key 'ir_cron_progress_id'
  • browse the corresponding ir.cron.progress record, and
  • update its done attribute, as per below
def periodic_cronjob(self):
processed = 2 # stub the result of processed records
progress_id = self.env.context.get('ir_cron_progress_id')
progress = self.env['ir.cron.progress'].sudo().browse(progress_id)
progress.write({'done': processed})

Then on the cronjob completion, the number of processed records will be correctly displayed.

odoo.addons.base.models.ir_cron: Job 'My job' (30) processed 2 records, 0 records remaining


الصورة الرمزية
إهمال

Nowhere is a mention of where or how you get 'processed'.

الكاتب

Hi Christoph,
I've updated the post to define 'processed', for simplicity it is hardcoded to 2, that should be displayed in the 'odoo.addons.base.models.ir_cron' log, but ir is not

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يوليو 25
470
3
يوليو 25
831
1
يونيو 25
1072
0
مارس 25
1316
3
مارس 25
1964