mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] account_statement_import_online_ofx: Change way to import institution list
This commit is contained in:
committed by
Christopher Ormaza
parent
6e1b366c6a
commit
addd76414d
@@ -3,8 +3,10 @@
|
||||
|
||||
import io
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from ofxparse import OfxParser
|
||||
from ofxtools import ofxhome, utils
|
||||
from ofxtools.Client import OFXClient, StmtRq
|
||||
@@ -115,7 +117,16 @@ class OnlineBankStatementProviderOFX(models.Model):
|
||||
|
||||
def import_ofx_institutions(self):
|
||||
OfxInstitution = self.env["ofx.institution"]
|
||||
for ofxhome_id, name in ofxhome.list_institutions().items():
|
||||
try:
|
||||
with requests.get("http://www.ofxhome.com/api.php?all=yes") as f:
|
||||
response = f.text
|
||||
institute_list = {
|
||||
fi.get("id").strip(): fi.get("name").strip()
|
||||
for fi in ET.fromstring(response)
|
||||
}
|
||||
except Exception as e:
|
||||
raise UserError(_(e))
|
||||
for ofxhome_id, name in institute_list.items():
|
||||
institute = OfxInstitution.search([("ofxhome_id", "=", ofxhome_id)])
|
||||
vals = {
|
||||
"name": name,
|
||||
|
||||
Reference in New Issue
Block a user