diff --git a/locale/de.po b/locale/de.po
index 124fc7b..023f10b 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -14,6 +14,10 @@ msgctxt "model:ir.message,text:msg_wiz_transactions_found"
msgid "The following transactionen are now imported:\nBalance: %(balance)s\nNumber of transactions: %(quantity)s"
msgstr "Die folgenden Transaktionen werden nun importiert:\nSaldo: %(balance)s\nAnzahl Transactionen: %(quantity)s"
+msgctxt "model:ir.message,text:msg_wiz_parties_found"
+msgid "The following %(numparties)s parties are now imported:"
+msgstr "Die folgenden %(numparties)s Parteien werden nun importiert:"
+
msgctxt "model:ir.message,name:msg_wiz_no_categories"
msgid "No categories were found in the file."
msgstr "In der Datei wurden keine Kategorien gefunden."
diff --git a/message.xml b/message.xml
index b03a6a2..772adaa 100644
--- a/message.xml
+++ b/message.xml
@@ -14,6 +14,9 @@ full copyright notices and license terms. -->
No transactions were found in the file.
+
+ The following %(numparties)s parties are now imported:
+
The following transactionen are now imported:\nBalance: %(balance)s\nNumber of transactions: %(quantity)s
diff --git a/qif_import_wiz.py b/qif_import_wiz.py
index ef50af0..5b985a3 100644
--- a/qif_import_wiz.py
+++ b/qif_import_wiz.py
@@ -148,6 +148,21 @@ class ImportQifWizard(Wizard):
self.showinfo.allowimport = True
else :
self.showinfo.info = gettext('cashbook_dataexchange.msg_wiz_no_categories')
+ elif model == 'party.party':
+ # read file content, extract parties
+ qif_content = QifTool.split_by_type(file_content)
+ if 'Bank' in qif_content.keys():
+ to_create = QifTool.convert_parties_to_create(
+ QifTool.qif_read_transactions(qif_content['Bank'])
+ )
+ self.showinfo.info = gettext(
+ 'cashbook_dataexchange.msg_wiz_parties_found',
+ numparties = len(to_create),
+ ) + '\n\n' + '\n'.join([x['name'] for x in to_create])
+ if len(to_create) > 0:
+ self.showinfo.allowimport = True
+ else :
+ self.showinfo.info = gettext('cashbook_dataexchange.msg_wiz_no_bank')
elif model == 'cashbook.book':
# read file content, extract categories
qif_content = QifTool.split_by_type(file_content)
@@ -188,6 +203,8 @@ class ImportQifWizard(Wizard):
pool = Pool()
Category = pool.get('cashbook.category')
Book = pool.get('cashbook.book')
+ Party = pool.get('party.party')
+ QifTool = pool.get('cashbook_dataexchange.qiftool')
model = Transaction().context.get('active_model', '')
file_content = None
@@ -200,6 +217,13 @@ class ImportQifWizard(Wizard):
elif model == 'cashbook.book':
if file_content:
Book.create_from_qif(self.showinfo.book, file_content)
+ elif model == 'party.party':
+ qif_content = QifTool.split_by_type(file_content)
+ if 'Bank' in qif_content.keys():
+ to_create = QifTool.convert_parties_to_create(
+ QifTool.qif_read_transactions(qif_content['Bank'])
+ )
+ Party.create(to_create)
return 'end'
# end ImportQifWizard
diff --git a/qif_import_wiz.xml b/qif_import_wiz.xml
index cb345e2..ea49a0e 100644
--- a/qif_import_wiz.xml
+++ b/qif_import_wiz.xml
@@ -36,5 +36,12 @@ full copyright notices and license terms. -->
+
+
+ form_action
+ party.party,-1
+
+
+
diff --git a/qiftool.py b/qiftool.py
index 29b454d..8a498ef 100644
--- a/qiftool.py
+++ b/qiftool.py
@@ -149,6 +149,34 @@ class QifTool(Model):
cat_id = categories[0].id
return (cat_id, msg_txt)
+ @classmethod
+ def convert_parties_to_create(cls, transactions):
+ """ extract party from transaction, check if exist,
+ create 'to_create'
+ """
+ Party = Pool().get('party.party')
+
+ to_create = []
+ party_cache = []
+ for transaction in transactions:
+ if 'party' in transaction.keys():
+ if transaction['party'] in party_cache:
+ continue
+
+ party_cache.append(transaction['party'])
+ if Party.search_count([
+ ('rec_name', 'ilike', '%%%(pname)s%%' % {
+ 'pname': transaction['party'],
+ })
+ ]) == 0:
+ to_create.append({
+ 'name': transaction['party'],
+ 'addresses': [('create', [{
+ 'street': transaction.get('address', None),
+ }])],
+ })
+ return to_create
+
@classmethod
def convert_transactions_to_create(cls, transactions, split2edit=True):
""" convert read transactions to create-command