[IMP] don't duplicate functionality from core

This commit is contained in:
Holger Brunn 2015-02-02 12:19:30 +01:00
parent 3572d0d2f4
commit 200b894bce
2 changed files with 7 additions and 36 deletions

View File

@ -12,9 +12,11 @@ data path (the odoo configuration value `data_dir`) in a subdirectory called
Then it will create a cron job that does the actual transfer and schedule it
for 01:42 at night in the installing user's time zone. The cronjob will do a
maximum of 10000 conversions, after which it creates a new cronjob to run for
the next batch 24 hours later. The limit is configurable with the parameter
`attachments_to_filesystem.limit`.
maximum of 10000 conversions per run and is run every night.
The limit is configurable with the parameter `attachments_to_filesystem.limit`.
After all attachments are migrated (the log will show then `moving 0
attachments to filestore`), you can disable or delete the cronjob.
If you need to run the migration synchronously during install, set the
parameter `attachments_to_filesystem.move_during_init` *before* installing this

View File

@ -75,6 +75,8 @@ class IrAttachment(Model):
'nextcall':
next_night.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'doall': True,
'interval_type': 'days',
'interval_number': 1,
},
context=context)
@ -110,36 +112,3 @@ class IrAttachment(Model):
if not counter % (len(attachment_ids) / 100 or limit):
logging.info('moving attachments: %d done', counter)
counter += 1
# see if we need to create a new cronjob for the next batch
if ir_attachment.search(
cr, uid, [('db_datas', '!=', False)], limit=1,
context=context):
module_name = __name__.split('.')[-3]
ir_cron = self.pool['ir.cron']
last_job_id = ir_cron.search(
cr, uid,
[
('model', '=', 'ir.attachment'),
('function', '=', '_attachments_to_filesystem_cron'),
],
order='nextcall desc',
limit=1,
context=context)
if not last_job_id:
return
new_job_data = ir_cron.copy_data(
cr, uid, last_job_id[0], context=context)
new_job_data.update(
nextcall=(
datetime.strptime(
new_job_data['nextcall'],
DEFAULT_SERVER_DATETIME_FORMAT) +
relativedelta(days=1)
).strftime(DEFAULT_SERVER_DATETIME_FORMAT),
)
self.pool['ir.model.data']._update(
cr, uid, 'ir.cron', module_name,
new_job_data,
xml_id='config_parameter_ir_attachment_location' + str(
last_job_id[0]),
context=context)