diff --git a/async_move_line_importer/__init__.py b/async_move_line_importer/__init__.py
new file mode 100644
index 000000000..85040e93f
--- /dev/null
+++ b/async_move_line_importer/__init__.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import model
diff --git a/async_move_line_importer/__openerp__.py b/async_move_line_importer/__openerp__.py
new file mode 100644
index 000000000..f0f340693
--- /dev/null
+++ b/async_move_line_importer/__openerp__.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{'name': 'Asynchron move line importer',
+ 'version': '0.1.1',
+ 'author': 'Camptocamp',
+ 'maintainer': 'Camptocamp',
+ 'category': 'categ',
+ 'complexity': 'normal',
+ 'depends': ['base', 'account'],
+ 'description': """Allows to move/moveline asynchronously""",
+ 'website': 'http://www.camptocamp.com',
+ 'data': ['view/move_line_importer_view.xml',
+ 'security/ir.model.access.csv',
+ 'security/multi_company.xml'],
+ 'demo': [],
+ 'test': [],
+ 'installable': True,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': False,
+ }
diff --git a/async_move_line_importer/model/__init__.py b/async_move_line_importer/model/__init__.py
new file mode 100644
index 000000000..5db0b24e8
--- /dev/null
+++ b/async_move_line_importer/model/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import move_line_importer
+#from . import account
diff --git a/async_move_line_importer/model/account.py b/async_move_line_importer/model/account.py
new file mode 100644
index 000000000..b912c5b75
--- /dev/null
+++ b/async_move_line_importer/model/account.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from openerp.osv import orm
+
+
+class account_move(orm.Model):
+ """redefine account move create to bypass orm
+ if async_bypass_create is True in context"""
+
+ _inherit = "account.move"
+
+ def _bypass_create(self, cr, uid, vals, context=None):
+ pass
+
+ def create(self, cr, uid, vals, context=None):
+ if context is None:
+ context = {}
+ if context.get('async_bypass_create'):
+ return self._bypass_create(cr, uid, vals, context=context)
+ return super(account_move, self).create(cr, uid, vals, context=context)
+
+
+class account_move_line(orm.Model):
+ """redefine account move line create to bypass orm
+ if async_bypass_create is True in context"""
+
+ _inherit = "account.move.line"
+
+ def create(self, cr, uid, vals, context=None):
+ if context is None:
+ context = {}
+ if context.get('async_bypass_create'):
+ return self._bypass_create(cr, uid, vals, context=context)
+ return super(account_move_line, self).create(cr, uid, vals, context=context)
+
+ def _bypass_create(self, cr, uid, vals, context=None):
+ pass
diff --git a/async_move_line_importer/model/move_line_importer.py b/async_move_line_importer/model/move_line_importer.py
new file mode 100644
index 000000000..8ecb00cda
--- /dev/null
+++ b/async_move_line_importer/model/move_line_importer.py
@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+import base64
+import csv
+import tempfile
+from openerp.osv import orm, fields
+
+
+class move_line_importer(orm.Model):
+ """Move line importer"""
+
+ _name = "move.line.importer"
+ _inherit = ['mail.thread']
+ # _track = {
+ # 'state': {
+ # 'import.success': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done',
+ # 'import.error': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'error',
+ # },
+ # }
+
+ _columns = {'name': fields.datetime('Name',
+ required=True,
+ readonly=True),
+ 'state': fields.selection([('draft', 'New'),
+ ('running', 'Running'),
+ ('done', 'Success'),
+ ('error', 'Error')],
+ readonly=True,
+ string='Status'),
+
+ 'report': fields.text('Report',
+ readonly=True),
+ 'file': fields.binary('File',
+ required=True),
+ 'delimiter': fields.selection([(',', ','), (';', ';'), ('|', '|')],
+ string="CSV delimiter",
+ required=True),
+ 'company_id': fields.many2one('res.company',
+ 'Company')
+ }
+
+ _defaults = {'delimiter': ','}
+
+ def _get_current_company(self, cr, uid, context=None, model="move.line.importer"):
+ return self.pool.get('res.company')._company_default_get(cr, uid, model,
+ context=context)
+
+ _defaults = {'state': 'draft',
+ 'name': fields.datetime.now(),
+ 'company_id': _get_current_company}
+
+ def _parse_csv(self, cr, uid, imp_id):
+ with tempfile.TemporaryFile() as src:
+ imp = self.read(cr, uid, imp_id, ['file', 'delimiter'])
+ content = imp['file'],
+ delimiter = imp['delimiter']
+ src.write(content)
+ with tempfile.TemporaryFile() as decoded:
+ src.seek(0)
+ base64.decode(src, decoded)
+ decoded.seek(0)
+ return self._prepare_csv_data(decoded, delimiter)
+
+ def _prepare_data(self, csv_file, delimiter=","):
+ data = csv.reader(csv_file, delimiter=str(delimiter))
+ head = data.next()
+ # generator does not work in load
+ values = [x for x in data]
+ return (head, values)
+
+ def import_file(self, cr, uid, imp_id, context=None):
+ if isinstance(imp_id, list):
+ imp_id = imp_id[0]
+ import pdb; pdb.set_trace()
+ head, data = self._parse_csv(cr, uid, imp_id)
diff --git a/async_move_line_importer/security/ir.model.access.csv b/async_move_line_importer/security/ir.model.access.csv
new file mode 100644
index 000000000..21f33c51c
--- /dev/null
+++ b/async_move_line_importer/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_move_line_importer_manager,access_move_line_importer_manager,model_move_line_importer,account.group_account_manager,1,1,1,0
diff --git a/async_move_line_importer/security/multi_company.xml b/async_move_line_importer/security/multi_company.xml
new file mode 100644
index 000000000..c359d755e
--- /dev/null
+++ b/async_move_line_importer/security/multi_company.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ Move line importer company rule
+
+
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+
+
+
diff --git a/async_move_line_importer/view/move_line_importer_view.xml b/async_move_line_importer/view/move_line_importer_view.xml
new file mode 100644
index 000000000..4660f051e
--- /dev/null
+++ b/async_move_line_importer/view/move_line_importer_view.xml
@@ -0,0 +1,75 @@
+
+
+
+
+ move line importer form
+ move.line.importer
+
+
+
+
+
+ move line importer tree
+ move.line.importer
+
+
+
+
+
+
+
+
+
+
+ Import Move lines
+ ir.actions.act_window
+ move.line.importer
+
+ form
+ tree,form
+
+
+
+
+
+