mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-23 17:08:46 -06:00
[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:
parent
3901852379
commit
beb84c7c59
@ -11,7 +11,7 @@
|
|||||||
<field name="doall" eval="False" />
|
<field name="doall" eval="False" />
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment</field>
|
||||||
<field name="function">update_file_type_from_cron</field>
|
<field name="function">update_file_type_from_cron</field>
|
||||||
<field name="args">(1000,)</field>
|
<field name="args">(10000,)</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
@ -26,13 +26,19 @@ from base64 import b64decode
|
|||||||
class Attachment(orm.Model):
|
class Attachment(orm.Model):
|
||||||
_inherit = 'ir.attachment'
|
_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(
|
ids = self.search(
|
||||||
cr, uid, [('file_type', '=', False)], context=context)
|
cr, uid, [('file_type', '=', False)], context=context)
|
||||||
logging.getLogger('openerp.addons.attachment_file_type').info(
|
logging.getLogger('openerp.addons.attachment_file_type').info(
|
||||||
'Found %s attachments without file type in the database.',
|
'Found %s attachments without file type in the database.',
|
||||||
len(ids))
|
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):
|
def update_file_type(self, cr, uid, ids, force=False, context=None):
|
||||||
""" Write the file types for these attachments. If the document module
|
""" Write the file types for these attachments. If the document module
|
||||||
|
Loading…
Reference in New Issue
Block a user