Skip to content

Commit

Permalink
Merge pull request #18 from guewen/base_import_async-clean-deprecated
Browse files Browse the repository at this point in the history
base_import_async: remove deprecated calls
  • Loading branch information
sbidoul committed Jun 23, 2015
2 parents bbef214 + 286fbb3 commit 14a1d8b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
1 change: 0 additions & 1 deletion base_import_async/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
###############################################################################

from . import models
from . import connector
27 changes: 0 additions & 27 deletions base_import_async/connector.py

This file was deleted.

12 changes: 6 additions & 6 deletions base_import_async/models/base_import_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def _create_csv_attachment(session, fields, data, options, file_name):
for row in data:
writer.writerow(_encode(row, encoding))
# create attachment
att_id = session.create('ir.attachment', {
attachment = session.env['ir.attachment'].create({
'name': file_name,
'datas': f.getvalue().encode('base64')
})
return att_id
return attachment.id


def _read_csv_attachment(session, att_id, options):
att = session.browse('ir.attachment', att_id)
att = session.env['ir.attachment'].browse(att_id)
f = StringIO(att.datas.decode('base64'))
reader = csv.reader(f,
delimiter=options.get(OPT_SEPARATOR),
Expand All @@ -88,10 +88,10 @@ def _read_csv_attachment(session, att_id, options):


def _link_attachment_to_job(session, job_uuid, att_id):
job_ids = session.search('queue.job', [('uuid', '=', job_uuid)])
session.write('ir.attachment', att_id, {
job = session.env['queue.job'].search([('uuid', '=', job_uuid)], limit=1)
session.env['ir.attachment'].browse(att_id).write({
'res_model': 'queue.job',
'res_id': job_ids[0],
'res_id': job.id,
})


Expand Down

0 comments on commit 14a1d8b

Please sign in to comment.