Browse Source

[IMP] Backport from master at 04daefd2d1

pull/19/head
Laurent Mignon 9 years ago
committed by Laurent Mignon (ACSONE)
parent
commit
c7c6954df7
  1. 3
      account_bank_statement_import/__init__.py
  2. 9
      account_bank_statement_import/account_bank_statement_import.py
  3. 2
      account_bank_statement_import/account_bank_statement_import_view.xml
  4. 150
      account_bank_statement_import/static/description/icon_src.svg
  5. 3
      account_bank_statement_import_ofx/__init__.py
  6. 5
      account_bank_statement_import_ofx/__openerp__.py
  7. 7
      account_bank_statement_import_ofx/account_bank_statement_import_ofx.py
  8. 6
      account_bank_statement_import_ofx/tests/test_import_bank_statement.py
  9. 1
      account_bank_statement_import_qif/__init__.py
  10. 3
      account_bank_statement_import_qif/tests/test_import_bank_statement.py

3
account_bank_statement_import/__init__.py

@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
from . import account_bank_statement_import
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import account_bank_statement_import

9
account_bank_statement_import/account_bank_statement_import.py

@ -123,8 +123,9 @@ class account_bank_statement_import(osv.TransientModel):
bank_account_id = None
if account_number and len(account_number) > 4:
account_number = account_number.replace(' ', '').replace('-', '')
cr.execute("select id from res_partner_bank where replace(replace(acc_number,' ',''),'-','') like %s and journal_id is not null", ('%' + account_number + '%',))
cr.execute("select id from res_partner_bank where replace(replace(acc_number,' ',''),'-','') = %s", (account_number,))
bank_account_ids = [id[0] for id in cr.fetchall()]
bank_account_ids = self.pool.get('res.partner.bank').search(cr, uid, [('id', 'in', bank_account_ids)], context=context)
if bank_account_ids:
bank_account_id = bank_account_ids[0]
@ -132,8 +133,6 @@ class account_bank_statement_import(osv.TransientModel):
def _get_journal(self, cr, uid, currency_id, bank_account_id, account_number, context=None):
""" Find or create the journal """
if context is None:
context = {}
bank_pool = self.pool.get('res.partner.bank')
# Find the journal from context or bank account
@ -174,7 +173,7 @@ class account_bank_statement_import(osv.TransientModel):
wmca_pool = self.pool.get('wizard.multi.charts.accounts')
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
vals_account = {'currency_id': currency_id, 'acc_name': account_number, 'account_type': 'bank'}
vals_account = {'currency_id': currency_id, 'acc_name': account_number, 'account_type': 'bank', 'currency_id': currency_id}
vals_account = wmca_pool._prepare_bank_account(cr, uid, company, vals_account, context=context)
account_id = self.pool.get('account.account').create(cr, uid, vals_account, context=context)
@ -213,7 +212,7 @@ class account_bank_statement_import(osv.TransientModel):
if unique_import_id:
line_vals['unique_import_id'] = (account_number and account_number + '-' or '') + unique_import_id
if not line_vals.get('partner_id') and not line_vals.get('bank_account_id'):
if not 'bank_account_id' in line_vals or not line_vals['bank_account_id']:
# Find the partner and his bank account or create the bank account. The partner selected during the
# reconciliation process will be linked to the bank when the statement is closed.
partner_id = False

2
account_bank_statement_import/account_bank_statement_import_view.xml

@ -23,7 +23,7 @@
</record>
<record id="action_account_bank_statement_import" model="ir.actions.act_window">
<field name="name">Import Bank Statement</field>
<field name="name">Import</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.bank.statement.import</field>
<field name="view_type">form</field>

150
account_bank_statement_import/static/description/icon_src.svg

@ -14,14 +14,14 @@
viewBox="0 0 100 100"
width="100px"
xml:space="preserve"
inkscape:version="0.91 r"
sodipodi:docname="icon_src.svg"
inkscape:export-filename="icon.png"
inkscape:version="0.48.2 r9819"
sodipodi:docname="1409271720_Noun_Project_100Icon_10px_grid-17.svg"
inkscape:export-filename="/Users/arthurmaniet/Desktop/icon.png"
inkscape:export-xdpi="115.2"
inkscape:export-ydpi="115.2"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
@ -37,128 +37,128 @@
showgrid="false"
inkscape:zoom="11.62"
inkscape:cx="21.99675"
inkscape:cy="62.279535"
inkscape:cy="56.127828"
inkscape:window-x="76"
inkscape:window-y="24"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_1" /><path
d="M79.043,31.615l-5.742,5.742V13h-58v74h58V48.67l11.398-11.399L79.043,31.615z M71.301,39.357L50.758,59.898l-1.414,4.242 l-1.414,4.244l8.486-2.828L71.301,50.67V85h-54V15h54V39.357z M54.564,65.119l-3.182,1.06l-1.248-1.248l1.061-3.182l3.1,3.099 L54.564,65.119z"
id="path3" /><text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:37.90610123px;line-height:125%;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
x="18.012672"
y="17.773424"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="18.006462"
y="17.887218"
id="text2986"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="18.012672"
y="17.773424"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="17.887218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3520">08/12/13 1000.00 Delta PC</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="21.523424"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="21.637218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3731">08/15/13 75.46 Walts Drugs</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="25.273424"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="25.387218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3733">03/03/13 379.00 Epic Technologies</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="29.023424"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="29.137218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3735">03/04/13 20.28 YOUR LOCAL SU</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="32.773422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="32.887218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3737">03/03/13 421.35 SPRINGFIELD WA</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="36.523422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="36.637218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3739">03/03/13 379.00 Epic Technologies</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="40.273422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="40.387218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3743">03/04/13 20.28 YOUR LOCAL SUP</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="44.023422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="44.137218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3846">08/15/13 75.46 Walts Drugs</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="47.773422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="47.887218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3745">08/12/13 1000.00 Delta PC</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="51.523422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="51.637218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3747">03/03/13 421.35 SPRINGFIELD WA</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="55.273422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="55.387218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3749">03/04/13 20.28 YOUR LOCAL SU</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="59.023422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="59.137218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3751">03/03/13 379.00 Epic Technologies</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="62.773422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="62.887218"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3753">08/12/13 1000.00 De a PC</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="66.523422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="66.637222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3755">03/03/13 379.00 E Technologies</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="70.273422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="70.387222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3757">08/15/13 75.46 Walts Drugs</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="74.023422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="74.137222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3759">03/04/13 20.28 YOUR LOCAL SU</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="77.773422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="77.887222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3761">03/03/13 379.00 Epic Technologies</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="81.523422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="81.637222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3763">08/12/13 1000.00 Delta PC</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="85.273422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="85.387222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3765">08/15/13 75.46 Walts Drugs</tspan><tspan
sodipodi:role="line"
x="18.012672"
y="89.023422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="89.137222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3783" /><tspan
sodipodi:role="line"
x="18.012672"
y="92.773422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="92.887222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3799" /><tspan
sodipodi:role="line"
x="18.012672"
y="96.523422"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.8429575px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans Bold'"
x="18.006462"
y="96.637222"
style="font-size:3px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:Arial Bold"
id="tspan3801" /></text>
<text
xml:space="preserve"

3
account_bank_statement_import_ofx/__init__.py

@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
from . import account_bank_statement_import_ofx
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import account_bank_statement_import_ofx

5
account_bank_statement_import_ofx/__openerp__.py

@ -25,9 +25,10 @@ base account_bank_statement_import module has been imported, or manually
create periods for the year 2013.
""",
'data' : [],
'depends': ['account_bank_statement_import'],
'demo': [
'demo/demo_data.xml',
],
'auto_install': False,
],
'auto_install': True,
'installable': True,
}

7
account_bank_statement_import_ofx/account_bank_statement_import_ofx.py

@ -14,8 +14,7 @@ _logger = logging.getLogger(__name__)
try:
from ofxparse import OfxParser as ofxparser
except ImportError:
_logger.error("OFX parser unavailable because the `ofxparse` Python library cannot be found."
"It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.")
_logger.warn("ofxparse not found, OFX parsing disabled.")
ofxparser = None
class account_bank_statement_import(osv.TransientModel):
@ -63,7 +62,7 @@ class account_bank_statement_import(osv.TransientModel):
vals_bank_statement = {
'name': ofx.account.routing_number,
'transactions': transactions,
'balance_start': float(ofx.account.statement.balance) - total_amt,
'balance_end_real': float(ofx.account.statement.balance),
'balance_start': ofx.account.statement.balance,
'balance_end_real': float(ofx.account.statement.balance) + total_amt,
}
return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement]

6
account_bank_statement_import_ofx/tests/test_import_bank_statement.py

@ -25,8 +25,8 @@ class TestOfxFile(TransactionCase):
bank_statement_id = self.statement_import_model.create(cr, uid, dict(
data_file=ofx_file,
))
self.statement_import_model.import_file(cr, uid, [bank_statement_id], {'allow_auto_create_journal': True})
self.statement_import_model.import_file(cr, uid, [bank_statement_id])
statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0]
bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
self.assertEquals(bank_st_record.balance_start, 2516.56)
self.assertEquals(bank_st_record.balance_end_real, 2156.56)
self.assertEquals(bank_st_record.balance_start, 2156.56)
self.assertEquals(bank_st_record.balance_end_real, 1796.56)

1
account_bank_statement_import_qif/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from . import account_bank_statement_import_qif
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

3
account_bank_statement_import_qif/tests/test_import_bank_statement.py

@ -23,8 +23,7 @@ class TestQifFile(TransactionCase):
data_file=qif_file,
))
context = {
'journal_id': self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'bank_journal')[1],
'allow_auto_create_journal': True,
'journal_id': self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'bank_journal')[1]
}
self.statement_import_model.import_file(cr, uid, [bank_statement_id], context=context)
line_id = self.bank_statement_line_model.search(cr, uid, [('name', '=', 'YOUR LOCAL SUPERMARKET')])[0]

Loading…
Cancel
Save