[IMP] Scale up number of processed attachments a little bit

[FIX] Actually truncate the list of ids to length of <count>
This commit is contained in:
Stefan Rijnhart 2015-02-18 19:23:25 +01:00
parent 3901852379
commit beb84c7c59
2 changed files with 9 additions and 3 deletions

View File

@ -11,7 +11,7 @@
<field name="doall" eval="False" />
<field name="model">ir.attachment</field>
<field name="function">update_file_type_from_cron</field>
<field name="args">(1000,)</field>
<field name="args">(10000,)</field>
</record>
</data>

View File

@ -26,13 +26,19 @@ from base64 import b64decode
class Attachment(orm.Model):
_inherit = 'ir.attachment'
def update_file_type_from_cron(self, cr, uid, count=1000, context=None):
def update_file_type_from_cron(self, cr, uid, count=10000, context=None):
ids = self.search(
cr, uid, [('file_type', '=', False)], context=context)
logging.getLogger('openerp.addons.attachment_file_type').info(
'Found %s attachments without file type in the database.',
len(ids))
self.update_file_type(cr, uid, ids, force=True, context=None)
if ids:
logging.getLogger('openerp.addons.attachment_file_type').info(
'Providing file types for a maximum of %s of them',
count)
return self.update_file_type(
cr, uid, ids[:count], force=True, context=None)
return False
def update_file_type(self, cr, uid, ids, force=False, context=None):
""" Write the file types for these attachments. If the document module