diff --git a/account_banking/__init__.py b/account_banking/__init__.py
index 0640b6cc6..b4ebb7caf 100644
--- a/account_banking/__init__.py
+++ b/account_banking/__init__.py
@@ -11,16 +11,16 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/__openerp__.py b/account_banking/__openerp__.py
index 552803eb6..81bc377d5 100644
--- a/account_banking/__openerp__.py
+++ b/account_banking/__openerp__.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV ().
@@ -8,46 +9,40 @@
#
# All Rights Reserved
#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract EduSense BV
-#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
+
{
'name': 'Account Banking',
'version': '0.1.136',
- 'license': 'GPL-3',
+ 'license': 'AGPL-3',
'author': 'Banking addons community',
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
- 'depends': ['base', 'account', 'base_iban', 'account_payment',
- 'account_iban_preserve_domestic'],
- 'init_xml': [],
- 'update_xml': [
+ 'depends': [
+ 'account_voucher',
+ 'account_iban_preserve_domestic',
+ ],
+ 'data': [
'security/ir.model.access.csv',
'data/account_banking_data.xml',
'wizard/bank_import_view.xml',
'account_banking_view.xml',
- 'account_banking_workflow.xml',
'wizard/banking_transaction_wizard.xml',
'workflow/account_invoice.xml',
],
- 'demo_xml': [],
'external_dependencies': {
'python' : ['BeautifulSoup'],
},
@@ -106,6 +101,5 @@
+ No special configuration needed for the parsers, new parsers are
recognized and made available at server (re)start.
''',
- 'active': False,
- 'installable': False,
+ 'installable': True,
}
diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py
index 7f68b1cca..8a6dd055f 100644
--- a/account_banking/account_banking.py
+++ b/account_banking/account_banking.py
@@ -1,20 +1,24 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV ().
+# (C) 2011 - 2013 Therp BV ().
+#
+# All other contributions are (C) by their respective contributors
+#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
@@ -57,20 +61,20 @@ Modifications are extensive:
default behavior is to flag the orders as 'sent', not as 'done'.
Rejected payments from the bank receive on import the status 'rejected'.
'''
-import time
-import sepa
-from osv import osv, fields
-from tools.translate import _
-from wizard.banktools import get_or_create_bank
-import decimal_precision as dp
-import netsvc
-from openerp import SUPERUSER_ID
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from openerp import netsvc, SUPERUSER_ID
+from openerp.addons.decimal_precision import decimal_precision as dp
+from openerp.addons.account_banking import sepa
+from openerp.addons.account_banking.wizard.banktools import get_or_create_bank
def warning(title, message):
'''Convenience routine'''
return {'warning': {'title': title, 'message': message}}
-class account_banking_account_settings(osv.osv):
+
+class account_banking_account_settings(orm.Model):
'''Default Journal for Bank Account'''
_name = 'account.banking.account.settings'
_description = __doc__
@@ -122,13 +126,6 @@ class account_banking_account_settings(osv.osv):
),
),
- #'multi_currency': fields.boolean(
- # 'Multi Currency Bank Account', required=True,
- # help=('Select this if your bank account is able to handle '
- # 'multiple currencies in parallel without coercing to '
- # 'a single currency.'
- # ),
- #),
}
def _default_company(self, cr, uid, context=None):
@@ -162,7 +159,8 @@ class account_banking_account_settings(osv.osv):
if not company_id:
company_id = self._default_company(cr, uid, context=context)
partner_id = self.pool.get('res.company').read(
- cr, uid, company_id, ['partner_id'], context=context)['partner_id'][0]
+ cr, uid, company_id, ['partner_id'],
+ context=context)['partner_id'][0]
bank_ids = self.pool.get('res.partner.bank').search(
cr, uid, [('partner_id', '=', partner_id)], context=context)
return bank_ids and bank_ids[0] or False
@@ -177,7 +175,8 @@ class account_banking_account_settings(osv.osv):
'res.partner', context=localcontext)
return account_def and account_def.id or False
- def _default_credit_account_id(self, cr, uid, context=None, company_id=False):
+ def _default_credit_account_id(
+ self, cr, uid, context=None, company_id=False):
localcontext = context and context.copy() or {}
localcontext['force_company'] = (
company_id or self._default_company(cr, uid, context=context))
@@ -187,9 +186,9 @@ class account_banking_account_settings(osv.osv):
return account_def and account_def.id or False
def find(self, cr, uid, journal_id, partner_bank_id=False, context=None):
- domain = [('journal_id','=',journal_id)]
+ domain = [('journal_id', '=', journal_id)]
if partner_bank_id:
- domain.append(('partner_bank_id','=',partner_bank_id))
+ domain.append(('partner_bank_id', '=', partner_bank_id))
return self.search(cr, uid, domain, context=context)
def onchange_partner_bank_id(
@@ -225,11 +224,11 @@ class account_banking_account_settings(osv.osv):
'default_debit_account_id': _default_debit_account_id,
'default_credit_account_id': _default_credit_account_id,
'partner_bank_id': _default_partner_bank_id,
- #'multi_currency': lambda *a: False,
}
account_banking_account_settings()
-class account_banking_imported_file(osv.osv):
+
+class account_banking_imported_file(orm.Model):
'''Imported Bank Statements File'''
_name = 'account.banking.imported.file'
_description = __doc__
@@ -267,74 +266,13 @@ class account_banking_imported_file(osv.osv):
),
}
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date': fields.date.context_today,
'user_id': lambda self, cursor, uid, context: uid,
}
account_banking_imported_file()
-class payment_mode_type(osv.osv):
- _name= 'payment.mode.type'
- _description= 'Payment Mode Type'
- _columns= {
- 'name': fields.char(
- 'Name', size=64, required=True,
- help='Payment Type'
- ),
- 'code': fields.char(
- 'Code', size=64, required=True,
- help='Specify the Code for Payment Type'
- ),
- # Setting suitable_bank_types to required pending
- # https://bugs.launchpad.net/openobject-addons/+bug/786845
- 'suitable_bank_types': fields.many2many(
- 'res.partner.bank.type',
- 'bank_type_payment_type_rel',
- 'pay_type_id','bank_type_id',
- 'Suitable bank types', required=True),
- 'ir_model_id': fields.many2one(
- 'ir.model', 'Payment wizard',
- help=('Select the Payment Wizard for payments of this type. '
- 'Leave empty for manual processing'),
- domain=[('osv_memory', '=', True)],
- ),
- 'payment_order_type': fields.selection(
- [('payment', 'Payment'),('debit', 'Direct debit')],
- 'Payment order type', required=True,
- ),
- }
- _defaults = {
- 'payment_order_type': lambda *a: 'payment',
- }
-
-payment_mode_type()
-
-class payment_mode(osv.osv):
- ''' Restoring the payment type from version 5,
- used to select the export wizard (if any) '''
- _inherit = "payment.mode"
-
- def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
- """ Reinstates functional code for suitable bank type filtering.
- Current code in account_payment is disfunctional.
- """
- res = []
- payment_mode = self.browse(
- cr, uid, payment_mode_id, context)
- if (payment_mode and payment_mode.type and
- payment_mode.type.suitable_bank_types):
- res = [type.code for type in payment_mode.type.suitable_bank_types]
- return res
-
- _columns = {
- 'type': fields.many2one(
- 'payment.mode.type', 'Payment type',
- help='Select the Payment Type for the Payment Mode.'
- ),
- }
-payment_mode()
-
-class account_bank_statement(osv.osv):
+class account_bank_statement(orm.Model):
'''
Extensions from account_bank_statement:
1. Removed period_id (transformed to optional boolean) - as it is no
@@ -347,45 +285,6 @@ class account_bank_statement(osv.osv):
'''
_inherit = 'account.bank.statement'
_order = 'id'
- _abf_others = []
- _abf_others_loaded = False
-
- def __init__(self, *args, **kwargs):
- '''
- See where we stand in the order of things
- '''
- super(account_bank_statement, self).__init__(*args, **kwargs)
- if not self._abf_others_loaded:
- self._abf_others_loaded = True
- self._abf_others = [x for x in self.__class__.__mro__
- if x.__module__.split('.')[0] not in [
- 'osv', 'account', 'account_banking',
- '__builtin__'
- ]
- ]
-
- #def _currency(self, cursor, user, ids, name, args, context=None):
- # '''
- # Calculate currency from contained transactions
- # '''
- # res = {}
- # res_currency_obj = self.pool.get('res.currency')
- # res_users_obj = self.pool.get('res.users')
- # default_currency = res_users_obj.browse(cursor, user,
- # user, context=context).company_id.currency_id
- # for statement in self.browse(cursor, user, ids, context=context):
- # currency = statement.journal_id.currency
- # if not currency:
- # currency = default_currency
- # res[statement.id] = currency.id
- # currency_names = {}
- # for currency_id, currency_name in res_currency_obj.name_get(cursor,
- # user, res.values(), context=context):
- # currency_names[currency_id] = currency_name
- # for statement_id in res.keys():
- # currency_id = res[statement_id]
- # res[statement_id] = (currency_id, currency_names[currency_id])
- # return res
_columns = {
'period_id': fields.many2one('account.period', 'Period',
@@ -393,13 +292,10 @@ class account_bank_statement(osv.osv):
'banking_id': fields.many2one('account.banking.imported.file',
'Imported File', readonly=True,
),
- # 'currency': fields.function(_currency, method=True, string='Currency',
- # type='many2one', relation='res.currency'),
}
_defaults = {
- 'period_id': lambda *a: False,
- # 'currency': _currency,
+ 'period_id': False,
}
def _check_company_id(self, cr, uid, ids, context=None):
@@ -408,19 +304,21 @@ class account_bank_statement(osv.osv):
move of period_id to the statement line
"""
for statement in self.browse(cr, uid, ids, context=context):
- if (statement.period_id and
- statement.company_id.id != statement.period_id.company_id.id):
- return False
for line in statement.line_ids:
if (line.period_id and
statement.company_id.id != line.period_id.company_id.id):
return False
- return True
+ if not statement.period_id:
+ statement.write({'period_id': line.period_id.id})
+ return super(account_bank_statement, self)._check_company_id(
+ cr, uid, ids, context=context)
# Redefine the constraint, or it still refer to the original method
_constraints = [
- (_check_company_id, 'The journal and period chosen have to belong to the same company.', ['journal_id','period_id']),
- ]
+ (_check_company_id,
+ 'The journal and period chosen have to belong to the same company.',
+ ['journal_id','period_id']),
+ ]
def _get_period(self, cursor, uid, date, context=None):
'''
@@ -430,231 +328,141 @@ class account_bank_statement(osv.osv):
periods = period_obj.find(cursor, uid, dt=date, context=context)
return periods and periods[0] or False
- #def compute(self, cursor, uid, ids, context=None):
- # '''
- # Compute start and end balance with mixed currencies.
- # '''
- # return None
+ def _prepare_move(
+ self, cr, uid, st_line, st_line_number, context=None):
+ """
+ Add the statement line's period to the move, overwriting
+ the period on the statement
+ """
+ res = super(account_bank_statement, self)._prepare_move(
+ cr, uid, st_line, st_line_number, context=context)
+ if context and context.get('period_id'):
+ res['period_id'] = context['period_id']
+ return res
+
+ def _prepare_move_line_vals(
+ self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
+ amount_currency=False, account_id=False, analytic_id=False,
+ partner_id=False, context=None):
+ """
+ Add the statement line's period to the move lines, overwriting
+ the period on the statement
+ """
+ res = super(account_bank_statement, self)._prepare_move_line_vals(
+ cr, uid, st_line, move_id, debit, credit, currency_id=currency_id,
+ amount_currency=amount_currency, account_id=account_id,
+ analytic_id=analytic_id, partner_id=partner_id, context=context)
+ if context and context.get('period_id'):
+ res['period_id'] = context['period_id']
+ return res
def create_move_from_st_line(self, cr, uid, st_line_id,
company_currency_id, st_line_number,
context=None):
- # This is largely a copy of the original code in account
- # Modifications are marked with AB
- # Modifications by account_voucher are merged below.
- # As there is no valid inheritance mechanism for large actions, this
- # is the only option to add functionality to existing actions.
- # WARNING: when the original code changes, this trigger has to be
- # updated in sync.
-
if context is None:
context = {}
- res_currency_obj = self.pool.get('res.currency')
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
account_bank_statement_line_obj = self.pool.get(
'account.bank.statement.line')
st_line = account_bank_statement_line_obj.browse(
cr, uid, st_line_id, context=context)
+
+ # Take period from statement line and write to context
+ # this will be picked up by the _prepare_move* methods
period_id = self._get_period(
- cr, uid, st_line.date, context=context) # AB
- # Start account voucher
- # Post the voucher and update links between statement and moves
+ cr, uid, st_line.date, context=context)
+ localctx = context.copy()
+ localctx['period_id'] = period_id
+
+ # Write date & period on the voucher, delegate to account_voucher's
+ # override of this method. Then post the related move and return.
if st_line.voucher_id:
voucher_pool = self.pool.get('account.voucher')
- wf_service = netsvc.LocalService("workflow")
voucher_pool.write(
cr, uid, [st_line.voucher_id.id], {
- 'number': st_line_number,
'date': st_line.date,
- 'period_id': period_id, # AB
+ 'period_id': period_id,
}, context=context)
- if st_line.voucher_id.state == 'cancel':
- voucher_pool.action_cancel_draft(
- cr, uid, [st_line.voucher_id.id], context=context)
- wf_service.trg_validate(
- uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr)
- v = voucher_pool.browse(
- cr, uid, st_line.voucher_id.id, context=context)
- account_bank_statement_line_obj.write(cr, uid, [st_line_id], {
- 'move_ids': [(4, v.move_id.id, False)]
- })
- account_move_line_obj.write(
- cr, uid, [x.id for x in v.move_ids],
- {'statement_id': st_line.statement_id.id}, context=context)
- # End of account_voucher
- st_line.refresh()
- # AB: The voucher journal isn't automatically posted, so post it (if needed)
+ res = super(account_bank_statement, self).create_move_from_st_line(
+ cr, uid, st_line_id, company_currency_id, st_line_number,
+ context=localctx)
+
+ st_line.refresh()
+ if st_line.voucher_id:
if not st_line.voucher_id.journal_id.entry_posted:
- account_move_obj.post(cr, uid, [st_line.voucher_id.move_id.id], context={})
- return True
-
- st = st_line.statement_id
-
- context.update({'date': st_line.date})
- ctxt = context.copy() # AB
- ctxt['company_id'] = st_line.company_id.id # AB
-
- move_id = account_move_obj.create(cr, uid, {
- 'journal_id': st.journal_id.id,
- 'period_id': period_id, # AB
- 'date': st_line.date,
- 'name': st_line_number,
- }, context=context)
- account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
- 'move_ids': [(4, move_id, False)]
- })
-
- torec = []
- if st_line.amount >= 0:
- account_id = st.journal_id.default_credit_account_id.id
+ account_move_obj.post(
+ cr, uid, [st_line.voucher_id.move_id.id], context={})
else:
- account_id = st.journal_id.default_debit_account_id.id
-
- acc_cur = ((st_line.amount <= 0 and
- st.journal_id.default_debit_account_id) or
- st_line.account_id)
- context.update({
- 'res.currency.compute.account': acc_cur,
- })
- amount = res_currency_obj.compute(cr, uid, st.currency.id,
- company_currency_id, st_line.amount, context=context)
-
- val = {
- 'name': st_line.name,
- 'date': st_line.date,
- 'ref': st_line.ref,
- 'move_id': move_id,
- 'partner_id': (((st_line.partner_id) and st_line.partner_id.id) or
- False),
- 'account_id': (st_line.account_id) and st_line.account_id.id,
- 'credit': ((amount>0) and amount) or 0.0,
- 'debit': ((amount<0) and -amount) or 0.0,
- 'statement_id': st.id,
- 'journal_id': st.journal_id.id,
- 'period_id': period_id, # AB
- 'currency_id': st.currency.id,
- 'analytic_account_id': (st_line.analytic_account_id and
- st_line.analytic_account_id.id or
- False),
- }
-
- if st.currency.id <> company_currency_id:
- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st.currency.id, amount, context=context)
- val['amount_currency'] = -amount_cur
-
- if (st_line.account_id and st_line.account_id.currency_id and
- st_line.account_id.currency_id.id <> company_currency_id):
- val['currency_id'] = st_line.account_id.currency_id.id
- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st_line.account_id.currency_id.id, amount, context=context)
- val['amount_currency'] = -amount_cur
-
- move_line_id = account_move_line_obj.create(
- cr, uid, val, context=context)
- torec.append(move_line_id)
-
- # Fill the secondary amount/currency
- # if currency is not the same than the company
- amount_currency = False
- currency_id = False
- if st.currency.id <> company_currency_id:
- amount_currency = st_line.amount
- currency_id = st.currency.id
- account_move_line_obj.create(cr, uid, {
- 'name': st_line.name,
- 'date': st_line.date,
- 'ref': st_line.ref,
- 'move_id': move_id,
- 'partner_id': (((st_line.partner_id) and st_line.partner_id.id) or
- False),
- 'account_id': account_id,
- 'credit': ((amount < 0) and -amount) or 0.0,
- 'debit': ((amount > 0) and amount) or 0.0,
- 'statement_id': st.id,
- 'journal_id': st.journal_id.id,
- 'period_id': period_id, # AB
- 'amount_currency': amount_currency,
- 'currency_id': currency_id,
- }, context=context)
-
- for line in account_move_line_obj.browse(cr, uid, [x.id for x in
- account_move_obj.browse(cr, uid, move_id,
- context=context).line_id],
- context=context):
- if line.state <> 'valid':
- raise osv.except_osv(_('Error !'),
- _('Journal Item "%s" is not valid') % line.name)
-
- # Bank statements will not consider boolean on journal entry_posted
- account_move_obj.post(cr, uid, [move_id], context=context)
-
- """
- Account-banking:
- - Write stored reconcile_id
- - Pay invoices through workflow
-
- Does not apply to voucher integration, but only to
- payments and payment orders
- """
- if st_line.reconcile_id:
- account_move_line_obj.write(cr, uid, torec, {
- (st_line.reconcile_id.line_partial_ids and
- 'reconcile_partial_id' or 'reconcile_id'):
- st_line.reconcile_id.id }, context=context)
- for move_line in (st_line.reconcile_id.line_id or []) + (
- st_line.reconcile_id.line_partial_ids or []):
- netsvc.LocalService("workflow").trg_trigger(
- uid, 'account.move.line', move_line.id, cr)
- #""" End account-banking """
-
- return move_id
+ # Write stored reconcile_id and pay invoices through workflow
+ if st_line.reconcile_id:
+ move_ids = [move.id for move in st_line.move_ids]
+ torec = account_move_obj.search(
+ cr, uid, [
+ ('move_id', 'in', move_ids),
+ ('account_id', '=', st_line.account_id.id)],
+ context=context)
+ account_move_line_obj.write(cr, uid, torec, {
+ (st_line.reconcile_id.line_partial_ids and
+ 'reconcile_partial_id' or 'reconcile_id'):
+ st_line.reconcile_id.id }, context=context)
+ for move_line in (st_line.reconcile_id.line_id or []) + (
+ st_line.reconcile_id.line_partial_ids or []):
+ netsvc.LocalService("workflow").trg_trigger(
+ uid, 'account.move.line', move_line.id, cr)
+ return res
def button_confirm_bank(self, cr, uid, ids, context=None):
- if context is None: context = {}
+ """
+ Assign journal sequence to statements without a name
+ """
+ if context is None:
+ context = {}
obj_seq = self.pool.get('ir.sequence')
- if not isinstance(ids, list): ids = [ids]
- noname_ids = self.search(cr, uid, [('id','in',ids),('name','=','/')])
+ if ids and isinstance(ids, (int, long)):
+ ids = [ids]
+ noname_ids = self.search(
+ cr, uid, [('id', 'in', ids),('name', '=', '/')],
+ context=context)
for st in self.browse(cr, uid, noname_ids, context=context):
- if st.journal_id.sequence_id:
- year = self.pool.get('account.period').browse(cr, uid, self._get_period(cr, uid, st.date)).fiscalyear_id.id
- c = {'fiscalyear_id': year}
- st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
- self.write(cr, uid, ids, {'name': st_number})
+ if st.journal_id.sequence_id:
+ period_id = self._get_period(cr, uid, st.date)
+ year = self.pool.get('account.period').browse(
+ cr, uid, period_id, context=context).fiscalyear_id.id
+ c = {'fiscalyear_id': year}
+ st_number = obj_seq.get_id(
+ cr, uid, st.journal_id.sequence_id.id, context=c)
+ self.write(
+ cr, uid, ids, {'name': st_number}, context=context)
- return super(account_bank_statement, self).button_confirm_bank(cr, uid, ids, context)
+ return super(account_bank_statement, self).button_confirm_bank(
+ cr, uid, ids, context)
account_bank_statement()
-class account_voucher(osv.osv):
+
+class account_voucher(orm.Model):
_inherit = 'account.voucher'
def _get_period(self, cr, uid, context=None):
- if context is None: context = {}
+ if context is None:
+ context = {}
if not context.get('period_id') and context.get('move_line_ids'):
- res = self.pool.get('account.move.line').browse(cr, uid , context.get('move_line_ids'))[0].period_id.id
- context['period_id'] = res
+ return self.pool.get('account.move.line').browse(
+ cr, uid , context.get('move_line_ids'))[0].period_id.id
return super(account_voucher, self)._get_period(cr, uid, context)
- def create(self, cr, uid, values, context=None):
- if values.get('period_id') == False and context.get('move_line_ids'):
- values['period_id'] = self._get_period(cr, uid, context)
- return super(account_voucher, self).create(cr, uid, values, context)
-
account_voucher()
-class account_bank_statement_line(osv.osv):
+
+class account_bank_statement_line(orm.Model):
'''
Extension on basic class:
1. Extra links to account.period and res.partner.bank for tracing and
matching.
2. Extra 'trans' field to carry the transaction id of the bank.
- 3. Extra 'international' flag to indicate the missing of a remote
- account number. Some banks use seperate international banking
- modules that do not integrate with the standard transaction files.
- 4. Readonly states for most fields except when in draft.
+ 3. Readonly states for most fields except when in draft.
'''
_inherit = 'account.bank.statement.line'
_description = 'Bank Transaction'
@@ -664,26 +472,6 @@ class account_bank_statement_line(osv.osv):
periods = self.pool.get('account.period').find(cursor, user, dt=date)
return periods and periods[0] or False
- def _seems_international(self, cursor, user, context=None):
- '''
- Some banks have seperate international banking modules which do not
- translate correctly into the national formats. Instead, they
- leave key fields blank and signal this anomaly with a special
- transfer type.
- With the introduction of SEPA, this may worsen greatly, as SEPA
- payments are considered to be analogous to international payments
- by most local formats.
- '''
- # Quick and dirty check: if remote bank account is missing, assume
- # international transfer
- return not (
- context.get('partner_bank_id') and context['partner_bank_id']
- )
- # Not so dirty check: check if partner_id is set. If it is, check the
- # default/invoice addresses country. If it is the same as our
- # company's, its local, else international.
- # TODO: to be done
-
def _get_currency(self, cursor, user, context=None):
'''
Get the default currency (required to allow other modules to function,
@@ -695,30 +483,6 @@ class account_bank_statement_line(osv.osv):
return res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
- #def _reconcile_amount(self, cursor, user, ids, name, args, context=None):
- # '''
- # Redefinition from the original: don't use the statements currency, but
- # the transactions currency.
- # '''
- # if not ids:
- # return {}
-
- # res_currency_obj = self.pool.get('res.currency')
- # res_users_obj = self.pool.get('res.users')
-
- # res = {}
- # company_currency_id = res_users_obj.browse(cursor, user, user,
- # context=context).company_id.currency_id.id
-
- # for line in self.browse(cursor, user, ids, context=context):
- # if line.reconcile_id:
- # res[line.id] = res_currency_obj.compute(cursor, user,
- # company_currency_id, line.currency.id,
- # line.reconcile_id.total_entry, context=context)
- # else:
- # res[line.id] = 0.0
- # return res
-
def _get_invoice_id(self, cr, uid, ids, name, args, context=None):
res = {}
for st_line in self.browse(cr, uid, ids, context):
@@ -736,7 +500,7 @@ class account_bank_statement_line(osv.osv):
return res
_columns = {
- # Redefines
+ # Redefines. Todo: refactor away to view attrs
'amount': fields.float('Amount', readonly=True,
digits_compute=dp.get_precision('Account'),
states={'draft': [('readonly', False)]}),
@@ -746,8 +510,6 @@ class account_bank_statement_line(osv.osv):
states={'draft': [('readonly', False)]}),
'date': fields.date('Date', required=True, readonly=True,
states={'draft': [('readonly', False)]}),
- #'reconcile_amount': fields.function(_reconcile_amount,
- # string='Amount reconciled', method=True, type='float'),
# New columns
'trans': fields.char('Bank Transaction ID', size=15, required=False,
@@ -762,12 +524,6 @@ class account_bank_statement_line(osv.osv):
states={'confirmed': [('readonly', True)]}),
'currency': fields.many2one('res.currency', 'Currency', required=True,
states={'confirmed': [('readonly', True)]}),
-
- # Not used yet, but usefull in the future.
- 'international': fields.boolean('International Transaction',
- required=False,
- states={'confirmed': [('readonly', True)]},
- ),
'reconcile_id': fields.many2one(
'account.move.reconcile', 'Reconciliation', readonly=True
),
@@ -779,427 +535,13 @@ class account_bank_statement_line(osv.osv):
_defaults = {
'period_id': _get_period,
- 'international': _seems_international,
'currency': _get_currency,
}
account_bank_statement_line()
-class payment_line(osv.osv):
- '''
- Add extra export_state and date_done fields; make destination bank account
- mandatory, as it makes no sense to send payments into thin air.
- Edit: Payments can be by cash too, which is prohibited by mandatory bank
- accounts.
- '''
- _inherit = 'payment.line'
- _columns = {
- # New fields
- 'export_state': fields.selection([
- ('draft', 'Draft'),
- ('open','Confirmed'),
- ('cancel','Cancelled'),
- ('sent', 'Sent'),
- ('rejected', 'Rejected'),
- ('done','Done'),
- ], 'State', select=True
- ),
- 'msg': fields.char('Message', size=255, required=False, readonly=True),
- # Redefined fields: added states
- 'date_done': fields.datetime('Date Confirmed', select=True,
- readonly=True),
- 'name': fields.char(
- 'Your Reference', size=64, required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'communication': fields.char(
- 'Communication', size=64, required=False,
- help=("Used as the message between ordering customer and current "
- "company. Depicts 'What do you want to say to the recipient"
- " about this order ?'"
- ),
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'communication2': fields.char(
- 'Communication 2', size=128,
- help='The successor message of Communication.',
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'move_line_id': fields.many2one(
- 'account.move.line', 'Entry line',
- domain=[('reconcile_id','=', False),
- ('account_id.type', '=','payable')
- ],
- help=('This Entry Line will be referred for the information of '
- 'the ordering customer.'
- ),
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'amount_currency': fields.float(
- 'Amount in Partner Currency', digits=(16,2),
- required=True,
- help='Payment amount in the partner currency',
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'currency': fields.many2one(
- 'res.currency', 'Partner Currency', required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'bank_id': fields.many2one(
- 'res.partner.bank', 'Destination Bank account',
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'order_id': fields.many2one(
- 'payment.order', 'Order', required=True,
- ondelete='cascade', select=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'partner_id': fields.many2one(
- 'res.partner', string="Partner", required=True,
- help='The Ordering Customer',
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'date': fields.date(
- 'Payment Date',
- help=("If no payment date is specified, the bank will treat this "
- "payment line directly"
- ),
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'state': fields.selection([
- ('normal','Free'),
- ('structured','Structured')
- ], 'Communication Type', required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- }
- _defaults = {
- 'export_state': lambda *a: 'draft',
- 'date_done': lambda *a: False,
- 'msg': lambda *a: '',
- }
-
- def fields_get(self, cr, uid, fields=None, context=None):
- res = super(payment_line, self).fields_get(cr, uid, fields, context)
- if 'communication' in res:
- res['communication'].setdefault('states', {})
- res['communication']['states']['structured'] = [('required', True)]
- if 'communication2' in res:
- res['communication2'].setdefault('states', {})
- res['communication2']['states']['structured'] = [('readonly', True)]
- res['communication2']['states']['normal'] = [('readonly', False)]
-
- return res
-
- """
- Hooks for processing direct debit orders, such as implemented in
- account_direct_debit module.
- """
- def get_storno_account_id(self, cr, uid, payment_line_id, amount,
- currency_id, context=None):
- """
- Hook for verifying a match of the payment line with the amount.
- Return the account associated with the storno.
- Used in account_banking interactive mode
- :param payment_line_id: the single payment line id
- :param amount: the (signed) amount debited from the bank account
- :param currency: the bank account's currency *browse object*
- :return: an account if there is a full match, False otherwise
- :rtype: database id of an account.account resource.
- """
-
- return False
-
- def debit_storno(self, cr, uid, payment_line_id, amount,
- currency_id, storno_retry=True, context=None):
- """
- Hook for handling a canceled item of a direct debit order.
- Presumably called from a bank statement import routine.
-
- Decide on the direction that the invoice's workflow needs to take.
- You may optionally return an incomplete reconcile for the caller
- to reconcile the now void payment.
-
- :param payment_line_id: the single payment line id
- :param amount: the (negative) amount debited from the bank account
- :param currency: the bank account's currency *browse object*
- :param boolean storno_retry: whether the storno is considered fatal \
- or not.
- :return: an incomplete reconcile for the caller to fill
- :rtype: database id of an account.move.reconcile resource.
- """
-
- return False
-
-payment_line()
-
-class payment_order(osv.osv):
- '''
- Enable extra states for payment exports
- '''
- _inherit = 'payment.order'
-
- _columns = {
- 'date_scheduled': fields.date(
- 'Scheduled date if fixed',
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- help='Select a date if you have chosen Preferred Date to be fixed.'
- ),
- 'reference': fields.char(
- 'Reference', size=128, required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'mode': fields.many2one(
- 'payment.mode', 'Payment mode', select=True, required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- help='Select the Payment Mode to be applied.',
- ),
- 'state': fields.selection([
- ('draft', 'Draft'),
- ('open','Confirmed'),
- ('cancel','Cancelled'),
- ('sent', 'Sent'),
- ('rejected', 'Rejected'),
- ('done','Done'),
- ], 'State', select=True
- ),
- 'line_ids': fields.one2many(
- 'payment.line', 'order_id', 'Payment lines',
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'user_id': fields.many2one(
- 'res.users','User', required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- ),
- 'date_prefered': fields.selection([
- ('now', 'Directly'),
- ('due', 'Due date'),
- ('fixed', 'Fixed date')
- ], "Preferred date", change_default=True, required=True,
- states={
- 'sent': [('readonly', True)],
- 'rejected': [('readonly', True)],
- 'done': [('readonly', True)]
- },
- help=("Choose an option for the Payment Order:'Fixed' stands for a "
- "date specified by you.'Directly' stands for the direct "
- "execution.'Due date' stands for the scheduled date of "
- "execution."
- )
- ),
- 'payment_order_type': fields.selection(
- [('payment', 'Payment'),('debit', 'Direct debit')],
- 'Payment order type', required=True,
- ),
- 'date_sent': fields.date('Send date', readonly=True),
- }
-
- _defaults = {
- 'payment_order_type': lambda *a: 'payment',
- }
-
- def launch_wizard(self, cr, uid, ids, context=None):
- """
- Search for a wizard to launch according to the type.
- If type is manual. just confirm the order.
- Previously (pre-v6) in account_payment/wizard/wizard_pay.py
- """
- if context == None:
- context = {}
- result = {}
- orders = self.browse(cr, uid, ids, context)
- order = orders[0]
- # check if a wizard is defined for the first order
- if order.mode.type and order.mode.type.ir_model_id:
- context['active_ids'] = ids
- wizard_model = order.mode.type.ir_model_id.model
- wizard_obj = self.pool.get(wizard_model)
- wizard_id = wizard_obj.create(cr, uid, {}, context)
- result = {
- 'name': wizard_obj._description or 'Payment Order Export',
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': wizard_model,
- 'domain': [],
- 'context': context,
- 'type': 'ir.actions.act_window',
- 'target': 'new',
- 'res_id': wizard_id,
- 'nodestroy': True,
- }
- else:
- # should all be manual orders without type or wizard model
- for order in orders[1:]:
- if order.mode.type and order.mode.type.ir_model_id:
- raise osv.except_osv(
- _('Error'),
- _('You can only combine payment orders of the same type')
- )
- # process manual payments
- wf_service = netsvc.LocalService('workflow')
- for order_id in ids:
- wf_service.trg_validate(uid, 'payment.order', order_id, 'sent', cr)
- return result
-
- def _write_payment_lines(self, cursor, uid, ids, **kwargs):
- '''
- ORM method for setting attributes of corresponding payment.line objects.
- Note that while this is ORM compliant, it is also very ineffecient due
- to the absence of filters on writes and hence the requirement to
- filter on the client(=OpenERP server) side.
- '''
- if not hasattr(ids, '__iter__'):
- ids = [ids]
- payment_line_obj = self.pool.get('payment.line')
- line_ids = payment_line_obj.search(
- cursor, uid, [
- ('order_id', 'in', ids)
- ])
- payment_line_obj.write(cursor, uid, line_ids, kwargs)
-
- def set_to_draft(self, cursor, uid, ids, *args):
- '''
- Set both self and payment lines to state 'draft'.
- '''
- self._write_payment_lines(cursor, uid, ids, export_state='draft')
- return super(payment_order, self).set_to_draft(
- cursor, uid, ids, *args
- )
-
- def action_sent(self, cursor, uid, ids, *args):
- '''
- Set both self and payment lines to state 'sent'.
- '''
- self._write_payment_lines(cursor, uid, ids, export_state='sent')
- self.write(cursor, uid, ids, {'state':'sent',
- 'date_sent': time.strftime('%Y-%m-%d')})
- return True
-
- def action_rejected(self, cursor, uid, ids, *args):
- '''
- Set both self and payment lines to state 'rejected'.
- '''
- self._write_payment_lines(cursor, uid, ids, export_state='rejected')
- wf_service = netsvc.LocalService('workflow')
- for id in ids:
- wf_service.trg_validate(uid, 'payment.order', id, 'rejected', cursor)
- return True
-
- def set_done(self, cursor, uid, ids, *args):
- '''
- Extend standard transition to update children as well.
- '''
- self._write_payment_lines(cursor, uid, ids,
- export_state='done',
- date_done=time.strftime('%Y-%m-%d')
- )
- return super(payment_order, self).set_done(
- cursor, uid, ids, *args
- )
-
- def get_wizard(self, type):
- '''
- Intercept manual bank payments to include 'sent' state. Default
- 'manual' payments are flagged 'done' immediately.
- '''
- if type == 'BANKMAN':
- # Note that self._module gets overwritten by inheriters, so make
- # the module name hard coded.
- return 'account_banking', 'wizard_account_banking_payment_manual'
- return super(payment_order, self).get_wizard(type)
-
- """
- Hooks for processing direct debit orders, such as implemented in
- account_direct_debit module.
- """
- def debit_reconcile_transfer(
- self, cr, uid, payment_order_id, amount, currency, context=None):
- """
- Reconcile the payment order if the amount is correct. Return the
- id of the reconciliation.
- """
- raise osv.except_osv(
- _("Cannot reconcile"),
- _("Cannot reconcile debit order: "+
- "Not implemented."))
-
- def debit_unreconcile_transfer(
- self, cr, uid, payment_order_id, reconcile_id, amount, currency,
- context=None):
- """ Unreconcile the payment_order if at all possible """
- raise osv.except_osv(
- _("Cannot unreconcile"),
- _("Cannot unreconcile debit order: "+
- "Not implemented."))
-
-payment_order()
-
-class res_partner_bank(osv.osv):
+class res_partner_bank(orm.Model):
'''
This is a hack to circumvent the very limited but widely used base_iban
dependency. The usage of __mro__ requires inside information of
@@ -1229,15 +571,13 @@ class res_partner_bank(osv.osv):
self._founder.__init__(*args, **kwargs)
mro = self.__class__.__mro__
for i in range(len(mro)):
- if mro[i].__module__.startswith('base.'):
+ if mro[i].__module__.startswith('openerp.addons.base.'):
self._founder = mro[i]
break
def init(self, cr):
'''
Update existing iban accounts to comply to new regime
- Note that usage of the ORM is not possible here, as the ORM cannot
- search on values not provided by the client.
'''
partner_bank_obj = self.pool.get('res.partner.bank')
@@ -1270,10 +610,11 @@ class res_partner_bank(osv.osv):
Create dual function IBAN account for SEPA countries
'''
if vals.get('state') == 'iban':
- iban = vals.get('acc_number',False) or vals.get('acc_number_domestic',False)
+ iban = (vals.get('acc_number')
+ or vals.get('acc_number_domestic', False))
vals['acc_number'], vals['acc_number_domestic'] = (
self._correct_IBAN(iban))
- return self._founder.create(cursor, uid, vals, context)
+ return self._founder.create(self, cursor, uid, vals, context)
def write(self, cr, uid, ids, vals, context=None):
'''
@@ -1293,7 +634,7 @@ class res_partner_bank(osv.osv):
self._correct_IBAN(account['acc_number']))
else:
vals['acc_number_domestic'] = False
- self._founder.write(cr, uid, account['id'], vals, context)
+ self._founder.write(self, cr, uid, account['id'], vals, context)
return True
def search(self, cursor, uid, args, *rest, **kwargs):
@@ -1355,10 +696,9 @@ class res_partner_bank(osv.osv):
# Extend search filter
newargs = extended_search_expression(args)
- # Original search (_founder)
- results = self._founder.search(cursor, uid, newargs,
- *rest, **kwargs
- )
+ # Original search
+ results = super(res_partner_bank, self).search(
+ cursor, uid, newargs, *rest, **kwargs)
return results
def read(
@@ -1369,7 +709,7 @@ class res_partner_bank(osv.osv):
'''
if fields and 'state' not in fields:
fields.append('state')
- records = self._founder.read(cr, uid, ids, fields, context, load)
+ records = self._founder.read(self, cr, uid, ids, fields, context, load)
is_list = True
if not isinstance(records, list):
records = [records,]
@@ -1429,6 +769,9 @@ class res_partner_bank(osv.osv):
Trigger to find IBAN. When found:
1. Reformat BBAN
2. Autocomplete bank
+
+ TODO: prevent unnecessary assignment of country_ids and
+ browsing of the country
'''
if not acc_number:
return {}
@@ -1488,6 +831,7 @@ class res_partner_bank(osv.osv):
if country_ids:
country = country_obj.browse(
cursor, uid, country_ids[0], context=context)
+ values['country_id'] = country_ids[0]
if country and country.code in sepa.IBAN.countries:
try:
info = sepa.online.account_info(country.code, acc_number)
@@ -1502,9 +846,8 @@ class res_partner_bank(osv.osv):
info.bic or iban_acc.BIC_searchkey,
name = info.bank
)
- values['country_id'] = country_id or \
- country_ids and country_ids[0] or \
- False
+ if country_id:
+ values['country_id'] = country_id
values['bank'] = bank_id or False
if info.bic:
values['bank_bic'] = info.bic
@@ -1513,8 +856,8 @@ class res_partner_bank(osv.osv):
if info is None:
result.update(warning(
_('Invalid data'),
- _('The account number appears to be invalid for %(country)s')
- % {'country': country.name}
+ _('The account number appears to be invalid for %s')
+ % country.name
))
except NotImplementedError:
if country.code in sepa.IBAN.countries:
@@ -1524,8 +867,8 @@ class res_partner_bank(osv.osv):
else:
result.update(warning(
_('Invalid format'),
- _('The account number has the wrong format for %(country)s')
- % {'country': country.name}
+ _('The account number has the wrong format for %s')
+ % country.name
))
return result
@@ -1558,15 +901,10 @@ class res_partner_bank(osv.osv):
_("The IBAN number doesn't seem to be correct")
)
- _constraints = [
- # Cannot have this as a constraint as it is rejecting valid numbers from GB and DE
- # It works much better without this constraint!
- #(check_iban, _("The IBAN number doesn't seem to be correct"), ["acc_number"])
- ]
-
res_partner_bank()
-class res_bank(osv.osv):
+
+class res_bank(orm.Model):
'''
Add a on_change trigger to automagically fill bank details from the
online SWIFT database. Allow hand filled names to overrule SWIFT names.
@@ -1609,7 +947,8 @@ class res_bank(osv.osv):
res_bank()
-class invoice(osv.osv):
+
+class invoice(orm.Model):
'''
Create other reference types as well.
@@ -1622,6 +961,9 @@ class invoice(osv.osv):
Don't forget to redefine the column "reference_type" as below or
your method will never be triggered.
+
+ TODO: move 'structured' part to account_banking_payment module
+ where it belongs
'''
_inherit = 'account.invoice'
@@ -1651,13 +993,16 @@ class invoice(osv.osv):
invoice()
-class account_move_line(osv.osv):
+
+class account_move_line(orm.Model):
_inherit = "account.move.line"
def get_balance(self, cr, uid, ids, context=None):
"""
Return the balance of any set of move lines.
- Surely this exists somewhere in account base, but I missed it.
+
+ Not to be confused with the 'balance' field on this model, which
+ returns the account balance that the move line applies to.
"""
total = 0.0
if not ids:
diff --git a/account_banking/account_banking_view.xml b/account_banking/account_banking_view.xml
index 4b26380a0..104f8d1c2 100644
--- a/account_banking/account_banking_view.xml
+++ b/account_banking/account_banking_view.xml
@@ -134,16 +134,7 @@
-
- account.banking.imported.line.search
- account.bank.imported.line
- search
-
-
-
-
-
-
+
Imported Bank Statements Filesir.actions.act_window
@@ -193,7 +184,12 @@
account.bank.statementtree
-
+
+
+
+
+
@@ -204,92 +200,52 @@
form
+
+
+
+
+
-
+
+ black:state == 'confirmed';darkmagenta:match_multi == True;crimson:duplicate == True;grey:state == 'draft';
-
-
-
-
-
-
-
-
-
-
- account.bank.statement.form.banking-2
-
- account.bank.statement
- form
-
-
-
-
-
-
-
- account.bank.statement.form.banking-3
-
- account.bank.statement
- form
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.bank.statement.tree.banking-2
-
- account.bank.statement
- tree
-
-
-
-
-
-
+
+ 1
+
-
-
- account.bank.statement.form.banking-4
-
- account.bank.statement
- form
-
-
-
-
-
-
+
+ 1
+
-
-
- account.bank.statement.form.banking-5
-
- account.bank.statement
- form
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
-
+
+
@@ -318,69 +276,7 @@
-
- account.bank.statement.form.banking-6
-
- account.bank.statement
- form
-
-
-
-
-
-
-
-
-
- account.payment.order.form.banking-1
-
- payment.order
- form
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.payment.order.tree.banking-1
-
- payment.order
- tree
-
-
-
-
-
-
-
res.partner.bank.form.banking-2res.partner.bank
@@ -399,53 +295,6 @@
-
-
-
- res.partner.form.banking-2
- res.partner
-
-
- form
-
-
-
- onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)
-
-
- onchange_domestic(acc_number_domestic, partner_id, country_id)
-
-
-
-
-
- res.partner.form.banking-3
- res.partner
-
-
- form
-
-
-
- onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)
-
-
- onchange_domestic(acc_number_domestic, partner_id, country_id)
-
-
-
-
-
res.bank.form.banking-1
@@ -459,54 +308,6 @@
-
-
- payment.mode.form.inherit
- payment.mode
-
- form
-
-
-
-
-
-
-
- payment.mode.tree.inherit
- payment.mode
-
- tree
-
-
-
-
-
-
-
-
-
- view.payment.mode.type.form
- payment.mode.type
- form
-
-
-
-
-
-
-
-
-
-
-
Bank statement line tree viewaccount.bank.statement.line
@@ -525,25 +326,25 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py
index aad6cc8a8..0e223b84f 100644
--- a/account_banking/banking_import_transaction.py
+++ b/account_banking/banking_import_transaction.py
@@ -1,45 +1,42 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV ().
-# Contributions by Kaspars Vilkens (KNdati):
-# lenghty discussions, bugreports and bugfixes
-# Refractoring (C) 2011 Therp BV ().
-# (C) 2011 Smile ().
+# (C) 2011 Therp BV ().
+# (C) 2011 Smile ().
+#
+# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
-from osv import osv, fields
-import netsvc
-import base64
import datetime
-from tools import config
-from tools.translate import _
-from parsers import models
-from parsers.convert import *
-# from account_banking.struct import struct
-from account_banking import sepa
-from wizard.banktools import *
-import decimal_precision as dp
+from openerp.osv import orm, fields
+from openerp import netsvc
+from openerp.tools.translate import _
+from openerp.addons.decimal_precision import decimal_precision as dp
+from openerp.addons.account_banking.parsers import models
+from openerp.addons.account_banking.parsers import convert
+from openerp.addons.account_banking import sepa
+from openerp.addons.account_banking.wizard import banktools
bt = models.mem_bank_transaction
-class banking_import_transaction(osv.osv):
+
+class banking_import_transaction(orm.Model):
""" orm representation of mem_bank_transaction() for interactive and posthoc
configuration of reconciliation in the bank statement view.
@@ -123,43 +120,6 @@ class banking_import_transaction(osv.osv):
# return move_lines to mix with the rest
return [x for x in invoice.move_id.line_id if x.account_id.reconcile]
- def _match_debit_order(
- self, cr, uid, trans, log, context=None):
-
- def is_zero(total):
- return self.pool.get('res.currency').is_zero(
- cr, uid, trans.statement_id.currency, total)
-
- payment_order_obj = self.pool.get('payment.order')
- order_ids = payment_order_obj.search(
- cr, uid, [('payment_order_type', '=', 'debit'),
- ('state', '=', 'sent'),
- ('date_sent', '<=', str2date(trans.execution_date,
- '%Y-%m-%d'))
- ],
- limit=0, context=context)
- orders = payment_order_obj.browse(cr, uid, order_ids, context)
- candidates = [x for x in orders if
- is_zero(x.total - trans.transferred_amount)]
- if len(candidates) > 0:
- # retrieve the common account_id, if any
- account_id = False
- for line in candidates[0].line_ids[0].debit_move_line_id.move_id.line_id:
- if line.account_id.type == 'other':
- account_id = line.account_id.id
- break
- return dict(
- move_line_ids = False,
- match_type = 'payment_order',
- payment_order_ids = [x.id for x in candidates],
- account_id = account_id,
- partner_id = False,
- partner_bank_id = False,
- reference = False,
- type='general',
- )
- return False
-
def _match_invoice(self, cr, uid, trans, move_lines,
partner_ids, bank_account_ids,
log, linked_invoices,
@@ -282,8 +242,8 @@ class banking_import_transaction(osv.osv):
candidates = [
x for x in move_lines
if x.partner_id.id in partner_ids and
- (str2date(x.date, '%Y-%m-%d') <=
- (str2date(trans.execution_date, '%Y-%m-%d') +
+ (convert.str2date(x.date, '%Y-%m-%d') <=
+ (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window))
and (not _cached(x) or _remaining(x))
]
@@ -304,8 +264,8 @@ class banking_import_transaction(osv.osv):
candidates = [
x for x in candidates or move_lines
if (x.invoice and has_id_match(x.invoice, ref, msg) and
- str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
- (str2date(trans.execution_date, '%Y-%m-%d') +
+ convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
+ (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window)
and (not _cached(x) or _remaining(x)))
]
@@ -317,8 +277,8 @@ class banking_import_transaction(osv.osv):
x for x in move_lines
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
trans.transferred_amount)
- and str2date(x.date, '%Y-%m-%d') <=
- (str2date(trans.execution_date, '%Y-%m-%d') +
+ and convert.str2date(x.date, '%Y-%m-%d') <=
+ (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window)
and (not _cached(x) or _remaining(x)))
]
@@ -333,8 +293,8 @@ class banking_import_transaction(osv.osv):
best = [x for x in candidates
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
trans.transferred_amount)
- and str2date(x.date, '%Y-%m-%d') <=
- (str2date(trans.execution_date, '%Y-%m-%d') +
+ and convert.str2date(x.date, '%Y-%m-%d') <=
+ (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window))
]
if len(best) == 1:
@@ -352,8 +312,8 @@ class banking_import_transaction(osv.osv):
# transfers first
paid = [x for x in move_lines
if x.invoice and has_id_match(x.invoice, ref, msg)
- and str2date(x.invoice.date_invoice, '%Y-%m-%d')
- <= str2date(trans.execution_date, '%Y-%m-%d')
+ and convert.str2date(x.invoice.date_invoice, '%Y-%m-%d')
+ <= convert.str2date(trans.execution_date, '%Y-%m-%d')
and (_cached(x) and not _remaining(x))
]
if paid:
@@ -443,7 +403,7 @@ class banking_import_transaction(osv.osv):
transaction = self.browse(cr, uid, transaction_id, context)
if not transaction.move_line_id:
if transaction.match_type == 'invoice':
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot link transaction %s with invoice") %
transaction.statement_line_id.name,
(transaction.invoice_ids and
@@ -453,7 +413,7 @@ class banking_import_transaction(osv.osv):
transaction.statement_line_id.name
)))
else:
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot link transaction %s with accounting entry") %
transaction.statement_line_id.name,
(transaction.move_line_ids and
@@ -512,7 +472,6 @@ class banking_import_transaction(osv.osv):
'partner_id': st_line.partner_id and st_line.partner_id.id or False,
'company_id': st_line.company_id.id,
'type':voucher_type,
- 'company_id': st_line.company_id.id,
'account_id': account_id,
'amount': abs(st_line.amount),
'writeoff_amount': writeoff,
@@ -542,101 +501,6 @@ class banking_import_transaction(osv.osv):
{'voucher_id': voucher_id}, context=context)
transaction.refresh()
- def _confirm_storno(
- self, cr, uid, transaction_id, context=None):
- """
- Creation of the reconciliation has been delegated to
- *a* direct debit module, to allow for various direct debit styles
- """
- payment_line_pool = self.pool.get('payment.line')
- statement_line_pool = self.pool.get('account.bank.statement.line')
- transaction = self.browse(cr, uid, transaction_id, context=context)
- if not transaction.payment_line_id:
- raise osv.except_osv(
- _("Cannot link with storno"),
- _("No direct debit order item"))
- reconcile_id = payment_line_pool.debit_storno(
- cr, uid,
- transaction.payment_line_id.id,
- transaction.statement_line_id.amount,
- transaction.statement_line_id.currency,
- transaction.storno_retry,
- context=context)
- statement_line_pool.write(
- cr, uid, transaction.statement_line_id.id,
- {'reconcile_id': reconcile_id}, context=context)
- transaction.refresh()
-
- def _confirm_payment_order(
- self, cr, uid, transaction_id, context=None):
- """
- Creation of the reconciliation has been delegated to
- *a* direct debit module, to allow for various direct debit styles
- """
- payment_order_obj = self.pool.get('payment.order')
- statement_line_pool = self.pool.get('account.bank.statement.line')
- transaction = self.browse(cr, uid, transaction_id, context=context)
- if not transaction.payment_order_id:
- raise osv.except_osv(
- _("Cannot reconcile"),
- _("Cannot reconcile: no direct debit order"))
- if transaction.payment_order_id.payment_order_type != 'debit':
- raise osv.except_osv(
- _("Cannot reconcile"),
- _("Reconcile payment order not implemented"))
- reconcile_id = payment_order_obj.debit_reconcile_transfer(
- cr, uid,
- transaction.payment_order_id.id,
- transaction.statement_line_id.amount,
- transaction.statement_line_id.currency,
- context=context)
- statement_line_pool.write(
- cr, uid, transaction.statement_line_id.id,
- {'reconcile_id': reconcile_id}, context=context)
-
- def _confirm_payment(
- self, cr, uid, transaction_id, context=None):
- """
- Do some housekeeping on the payment line
- then pass on to _reconcile_move
- """
- transaction = self.browse(cr, uid, transaction_id, context=context)
- payment_line_obj = self.pool.get('payment.line')
- payment_line_obj.write(
- cr, uid, transaction.payment_line_id.id, {
- 'export_state': 'done',
- 'date_done': transaction.statement_line_id.date,
- }
- )
- self._confirm_move(cr, uid, transaction_id, context=context)
-
- def _cancel_payment(
- self, cr, uid, transaction_id, context=None):
- raise osv.except_osv(
- _("Cannot unreconcile"),
- _("Cannot unreconcile: this operation is not yet supported for "
- "match type 'payment'"))
-
- def _cancel_payment_order(
- self, cr, uid, transaction_id, context=None):
- """
- """
- payment_order_obj = self.pool.get('payment.order')
- transaction = self.browse(cr, uid, transaction_id, context=context)
- if not transaction.payment_order_id:
- raise osv.except_osv(
- _("Cannot unreconcile"),
- _("Cannot unreconcile: no direct debit order"))
- if transaction.payment_order_id.payment_order_type != 'debit':
- raise osv.except_osv(
- _("Cannot unreconcile"),
- _("Unreconcile payment order not implemented"))
- return payment_order_obj.debit_unreconcile_transfer(
- cr, uid, transaction.payment_order_id.id,
- transaction.statement_line_id.reconcile_id.id,
- transaction.statement_line_id.amount,
- transaction.statement_line_id.currency)
-
def _legacy_do_move_unreconcile(self, cr, uid, move_line_ids, currency, context=None):
"""
Legacy method. Allow for canceling bank statement lines that
@@ -684,7 +548,7 @@ class banking_import_transaction(osv.osv):
def _legacy_clear_up_writeoff(self, cr, uid, transaction, context=None):
"""
Legacy method to support upgrades older installations of the
- interactive wizard branch. To be removed after 6.2
+ interactive wizard branch. To be removed after 7.0
clear up the writeoff move
"""
if transaction.writeoff_move_line_id:
@@ -768,70 +632,10 @@ class banking_import_transaction(osv.osv):
return True
- def _cancel_storno(
- self, cr, uid, transaction_id, context=None):
- """
- TODO: delegate unreconciliation to the direct debit module,
- to allow for various direct debit styles
- """
- payment_line_obj = self.pool.get('payment.line')
- reconcile_obj = self.pool.get('account.move.reconcile')
- transaction = self.browse(cr, uid, transaction_id, context=context)
-
- if not transaction.payment_line_id:
- raise osv.except_osv(
- _("Cannot cancel link with storno"),
- _("No direct debit order item"))
- if not transaction.payment_line_id.storno:
- raise osv.except_osv(
- _("Cannot cancel link with storno"),
- _("The direct debit order item is not marked for storno"))
-
- journal = transaction.statement_line_id.statement_id.journal_id
- if transaction.statement_line_id.amount >= 0:
- account_id = journal.default_credit_account_id.id
- else:
- account_id = journal.default_debit_account_id.id
- cancel_line = False
- move_lines = []
- for move in transaction.statement_line_id.move_ids:
- # There should usually be just one move, I think
- move_lines += move.line_id
- for line in move_lines:
- if line.account_id.id != account_id:
- cancel_line = line
- break
- if not cancel_line:
- raise osv.except_osv(
- _("Cannot cancel link with storno"),
- _("Line id not found"))
- reconcile = cancel_line.reconcile_id or cancel_line.reconcile_partial_id
- lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
- if len(lines_reconcile) < 3:
- # delete the full reconciliation
- reconcile_obj.unlink(cr, uid, reconcile.id, context)
- else:
- # we are left with a partial reconciliation
- reconcile_obj.write(
- cr, uid, reconcile.id,
- {'line_partial_ids':
- [(6, 0, [x.id for x in lines_reconcile if x.id != cancel_line.id])],
- 'line_id': [(6, 0, [])],
- }, context)
- # redo the original payment line reconciliation with the invoice
- payment_line_obj.write(
- cr, uid, transaction.payment_line_id.id,
- {'storno': False}, context)
- payment_line_obj.debit_reconcile(
- cr, uid, transaction.payment_line_id.id, context)
-
cancel_map = {
- 'storno': _cancel_storno,
'invoice': _cancel_voucher,
'manual': _cancel_voucher,
'move': _cancel_voucher,
- 'payment_order': _cancel_payment_order,
- 'payment': _cancel_payment,
}
def cancel(self, cr, uid, ids, context=None):
@@ -841,7 +645,7 @@ class banking_import_transaction(osv.osv):
if not transaction.match_type:
continue
if transaction.match_type not in self.cancel_map:
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot cancel type %s" % transaction.match_type),
_("No method found to cancel this type"))
self.cancel_map[transaction.match_type](
@@ -850,11 +654,8 @@ class banking_import_transaction(osv.osv):
return True
confirm_map = {
- 'storno': _confirm_storno,
'invoice': _confirm_move,
'manual': _confirm_move,
- 'payment_order': _confirm_payment_order,
- 'payment': _confirm_payment,
'move': _confirm_move,
}
@@ -865,7 +666,7 @@ class banking_import_transaction(osv.osv):
if not transaction.match_type:
continue
if transaction.match_type not in self.confirm_map:
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot reconcile"),
_("Cannot reconcile type %s. No method found to " +
"reconcile this type") %
@@ -873,7 +674,7 @@ class banking_import_transaction(osv.osv):
)
if (transaction.residual and transaction.writeoff_account_id):
if transaction.match_type not in ('invoice', 'move', 'manual'):
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot reconcile"),
_("Bank transaction %s: write off not implemented for " +
"this match type.") %
@@ -884,74 +685,8 @@ class banking_import_transaction(osv.osv):
self.confirm_map[transaction.match_type](
self, cr, uid, transaction.id, context)
- """
- account_ids = [
- x.id for x in bank_account_ids
- if x.partner_id.id == move_line.partner_id.id
- ][0]
- """
return True
- def _match_storno(
- self, cr, uid, trans, log, context=None):
- payment_line_obj = self.pool.get('payment.line')
- line_ids = payment_line_obj.search(
- cr, uid, [
- ('order_id.payment_order_type', '=', 'debit'),
- ('order_id.state', 'in', ['sent', 'done']),
- ('communication', '=', trans.reference)
- ], context=context)
- # stornos MUST have an exact match
- if len(line_ids) == 1:
- account_id = payment_line_obj.get_storno_account_id(
- cr, uid, line_ids[0], trans.transferred_amount,
- trans.statement_id.currency, context=None)
- if account_id:
- return dict(
- account_id = account_id,
- match_type = 'storno',
- payment_line_id = line_ids[0],
- move_line_ids=False,
- partner_id=False,
- partner_bank_id=False,
- reference=False,
- type='customer',
- )
- # TODO log the reason why there is no result for transfers marked
- # as storno
- return False
-
- def _match_payment(self, cr, uid, trans, payment_lines,
- partner_ids, bank_account_ids, log, linked_payments):
- '''
- Find the payment order belonging to this reference - if there is one
- This is the easiest part: when sending payments, the returned bank info
- should be identical to ours.
- This also means that we do not allow for multiple candidates.
- '''
- # TODO: Not sure what side effects are created when payments are done
- # for credited customer invoices, which will be matched later on too.
- digits = dp.get_precision('Account')(cr)[1]
- candidates = [x for x in payment_lines
- if x.communication == trans.reference
- and round(x.amount, digits) == -round(trans.transferred_amount, digits)
- and trans.remote_account in (x.bank_id.acc_number,
- x.bank_id.acc_number_domestic)
- ]
- if len(candidates) == 1:
- candidate = candidates[0]
- # Check cache to prevent multiple matching of a single payment
- if candidate.id not in linked_payments:
- linked_payments[candidate.id] = True
- move_info = self._get_move_info(cr, uid, [candidate.move_line_id.id])
- move_info.update({
- 'match_type': 'payment',
- 'payment_line_id': candidate.id,
- })
- return move_info
-
- return False
-
signal_duplicate_keys = [
# does not include float values
# such as transferred_amount
@@ -982,7 +717,7 @@ class banking_import_transaction(osv.osv):
me['transferred_amount'] - trans.transferred_amount):
dupes.append(trans.id)
if len(dupes) < 1:
- raise osv.except_osv(_('Cannot check for duplicate'),
+ raise orm.except_orm(_('Cannot check for duplicate'),
_("Cannot check for duplicate. "
"I can't find myself."))
if len(dupes) > 1:
@@ -1059,6 +794,22 @@ class banking_import_transaction(osv.osv):
retval['invoice_ids'] = [x.invoice.id for x in move_lines]
retval['type'] = type_map[move_lines[0].invoice.type]
return retval
+
+ def move_info2values(self, move_info):
+ vals = {}
+ vals['match_type'] = move_info['match_type']
+ vals['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]
+ vals['invoice_ids'] = [(6, 0, move_info.get('invoice_ids') or [])]
+ vals['move_line_id'] = (move_info.get('move_line_ids', False) and
+ len(move_info['move_line_ids']) == 1 and
+ move_info['move_line_ids'][0]
+ )
+ if move_info['match_type'] == 'invoice':
+ vals['invoice_id'] = (move_info.get('invoice_ids', False) and
+ len(move_info['invoice_ids']) == 1 and
+ move_info['invoice_ids'][0]
+ )
+ return vals
def match(self, cr, uid, ids, results=None, context=None):
if not ids:
@@ -1069,9 +820,9 @@ class banking_import_transaction(osv.osv):
journal_obj = self.pool.get('account.journal')
move_line_obj = self.pool.get('account.move.line')
payment_line_obj = self.pool.get('payment.line')
+ has_payment = bool(payment_line_obj)
statement_line_obj = self.pool.get('account.bank.statement.line')
statement_obj = self.pool.get('account.bank.statement')
- payment_order_obj = self.pool.get('payment.order')
imported_statement_ids = []
# Results
@@ -1098,14 +849,15 @@ class banking_import_transaction(osv.osv):
# communication. Most likely there are much less sent payments
# than reconciled and open/draft payments.
# Strangely, payment_orders still do not have company_id
- cr.execute("SELECT l.id FROM payment_order o, payment_line l "
- "WHERE l.order_id = o.id AND "
- "o.state = 'sent' AND "
- "l.date_done IS NULL"
- )
- payment_line_ids = [x[0] for x in cr.fetchall()]
- if payment_line_ids:
- payment_lines = payment_line_obj.browse(cr, uid, payment_line_ids)
+ if has_payment:
+ payment_line_ids = payment_line_obj.search(
+ cr, uid, [
+ ('order_id.state', '=', 'sent'),
+ ('date_done', '=', False)], context=context)
+ payment_lines = payment_line_obj.browse(
+ cr, uid, payment_line_ids)
+ else:
+ payment_lines = False
# Start the loop over the transactions requested to match
transactions = self.browse(cr, uid, ids, context)
@@ -1123,7 +875,7 @@ class banking_import_transaction(osv.osv):
if (transaction.statement_line_id and
transaction.statement_line_id.state == 'confirmed'):
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot perform match"),
_("Cannot perform match on a confirmed transction"))
@@ -1171,7 +923,7 @@ class banking_import_transaction(osv.osv):
account_info = info[transaction.local_account][currency_code]
else:
# Pull account info/currency
- account_info = get_company_bank_account(
+ account_info = banktools.get_company_bank_account(
self.pool, cr, uid, transaction.local_account,
transaction.local_currency, company, results['log']
)
@@ -1228,10 +980,9 @@ class banking_import_transaction(osv.osv):
continue
# Link accounting period
- period_id = get_period(
- self.pool, cr, uid,
- str2date(transaction.effective_date,'%Y-%m-%d'), company,
- results['log'])
+ period_id = banktools.get_period(
+ self.pool, cr, uid, transaction.effective_date,
+ company, results['log'])
if not period_id:
results['trans_skipped_cnt'] += 1
if not injected:
@@ -1270,10 +1021,10 @@ class banking_import_transaction(osv.osv):
# rebrowse the current record after writing
transaction = self.browse(cr, uid, transaction.id, context=context)
# Match full direct debit orders
- if transaction.type == bt.DIRECT_DEBIT:
+ if transaction.type == bt.DIRECT_DEBIT and has_payment:
move_info = self._match_debit_order(
cr, uid, transaction, results['log'], context)
- if transaction.type == bt.STORNO:
+ if transaction.type == bt.STORNO and has_payment:
move_info = self._match_storno(
cr, uid, transaction, results['log'], context)
# Allow inclusion of generated bank invoices
@@ -1290,7 +1041,7 @@ class banking_import_transaction(osv.osv):
partner_banks = []
else:
# Link remote partner, import account when needed
- partner_banks = get_bank_accounts(
+ partner_banks = banktools.get_bank_accounts(
self.pool, cr, uid, transaction.remote_account,
results['log'], fail=True
)
@@ -1309,14 +1060,17 @@ class banking_import_transaction(osv.osv):
country_code = company.partner_id.country.code
else:
country_code = None
- partner_id = get_or_create_partner(
+ partner_id = banktools.get_or_create_partner(
self.pool, cr, uid, transaction.remote_owner,
transaction.remote_owner_address,
transaction.remote_owner_postalcode,
transaction.remote_owner_city,
- country_code, results['log'], context=context)
+ country_code, results['log'],
+ customer=transaction.transferred_amount > 0,
+ supplier=transaction.transferred_amount < 0,
+ context=context)
if transaction.remote_account:
- partner_bank_id = create_bank_account(
+ partner_bank_id = banktools.create_bank_account(
self.pool, cr, uid, partner_id,
transaction.remote_account,
transaction.remote_owner,
@@ -1340,6 +1094,10 @@ class banking_import_transaction(osv.osv):
if (not move_info
and transaction.transferred_amount < 0 and payment_lines):
# Link open payment - if any
+ # Note that _match_payment is defined in the
+ # account_banking_payment module which should be installed
+ # automatically if account_payment is. And if account_payment
+ # is not installed, then payment_lines will be empty.
move_info = self._match_payment(
cr, uid, transaction,
payment_lines, partner_ids,
@@ -1385,28 +1143,12 @@ class banking_import_transaction(osv.osv):
self_values = {}
if move_info:
results['trans_matched_cnt'] += 1
- self_values['match_type'] = move_info['match_type']
- self_values['payment_line_id'] = move_info.get('payment_line_id', False)
- self_values['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]
- self_values['invoice_ids'] = [(6, 0, move_info.get('invoice_ids') or [])]
- self_values['payment_order_ids'] = [(6, 0, move_info.get('payment_order_ids') or [])]
- self_values['payment_order_id'] = (move_info.get('payment_order_ids', False) and
- len(move_info['payment_order_ids']) == 1 and
- move_info['payment_order_ids'][0]
- )
- self_values['move_line_id'] = (move_info.get('move_line_ids', False) and
- len(move_info['move_line_ids']) == 1 and
- move_info['move_line_ids'][0]
- )
- if move_info['match_type'] == 'invoice':
- self_values['invoice_id'] = (move_info.get('invoice_ids', False) and
- len(move_info['invoice_ids']) == 1 and
- move_info['invoice_ids'][0]
- )
+ self_values.update(
+ self.move_info2values(move_info))
+ # values['match_type'] = move_info['match_type']
values['partner_id'] = move_info['partner_id']
values['partner_bank_id'] = move_info['partner_bank_id']
values['type'] = move_info['type']
- # values['match_type'] = move_info['match_type']
else:
values['partner_id'] = values['partner_bank_id'] = False
if not values['partner_id'] and partner_ids and len(partner_ids) == 1:
@@ -1446,34 +1188,6 @@ class banking_import_transaction(osv.osv):
statement_obj.button_dummy(
cr, uid, imported_statement_ids, context=context)
- if payment_lines:
- # As payments lines are treated as individual transactions, the
- # batch as a whole is only marked as 'done' when all payment lines
- # have been reconciled.
- cr.execute(
- "SELECT DISTINCT o.id "
- "FROM payment_order o, payment_line l "
- "WHERE o.state = 'sent' "
- "AND o.id = l.order_id "
- "AND o.id NOT IN ("
- "SELECT DISTINCT order_id AS id "
- "FROM payment_line "
- "WHERE date_done IS NULL "
- "AND id IN (%s)"
- ")" % (','.join([str(x) for x in payment_line_ids]))
- )
- order_ids = [x[0] for x in cr.fetchall()]
- if order_ids:
- # Use workflow logics for the orders. Recode logic from
- # account_payment, in order to increase efficiency.
- payment_order_obj.set_done(cr, uid, order_ids,
- {'state': 'done'}
- )
- wf_service = netsvc.LocalService('workflow')
- for id in order_ids:
- wf_service.trg_validate(
- uid, 'payment.order', id, 'done', cr)
-
def _get_residual(self, cr, uid, ids, name, args, context=None):
"""
Calculate the residual against the candidate reconciliation.
@@ -1518,10 +1232,6 @@ class banking_import_transaction(osv.osv):
elif transaction.match_type == 'invoice':
if transaction.invoice_ids and not transaction.invoice_id:
res[transaction.id] = True
- elif transaction.match_type == 'payment_order':
- if (transaction.payment_order_ids and not
- transaction.payment_order_id):
- res[transaction.id] = True
return res
def clear_and_write(self, cr, uid, ids, vals=None, context=None):
@@ -1535,12 +1245,10 @@ class banking_import_transaction(osv.osv):
'invoice_id',
'manual_invoice_id',
'manual_move_line_id',
- 'payment_line_id',
]] +
[(x, [(6, 0, [])]) for x in [
'move_line_ids',
'invoice_ids',
- 'payment_order_ids',
]]))
write_vals.update(vals or {})
return self.write(cr, uid, ids, write_vals, context=context)
@@ -1639,29 +1347,22 @@ class banking_import_transaction(osv.osv):
'account.bank.statement.line', 'Statement line',
ondelete='CASCADE'),
'statement_id': fields.many2one(
- 'account.bank.statement', 'Statement'),
+ 'account.bank.statement', 'Statement',
+ ondelete='CASCADE'),
'parent_id': fields.many2one(
'banking.import.transaction', 'Split off from this transaction'),
# match fields
'match_type': fields.selection(
[('manual', 'Manual'), ('move','Move'), ('invoice', 'Invoice'),
- ('payment', 'Payment'), ('payment_order', 'Payment order'),
- ('storno', 'Storno')],
- 'Match type'),
+ ], 'Match type'),
'match_multi': fields.function(
_get_match_multi, method=True, string='Multi match',
type='boolean'),
- 'payment_order_ids': fields.many2many(
- 'payment.order', 'banking_transaction_payment_order_rel',
- 'order_id', 'transaction_id', 'Payment orders'),
- 'payment_order_id': fields.many2one(
- 'payment.order', 'Payment order to reconcile'),
'move_line_ids': fields.many2many(
'account.move.line', 'banking_transaction_move_line_rel',
'move_line_id', 'transaction_id', 'Matching entries'),
'move_line_id': fields.many2one(
'account.move.line', 'Entry to reconcile'),
- 'payment_line_id': fields.many2one('payment.line', 'Payment line'),
'invoice_ids': fields.many2many(
'account.invoice', 'banking_transaction_invoice_rel',
'invoice_id', 'transaction_id', 'Matching invoices'),
@@ -1685,7 +1386,7 @@ class banking_import_transaction(osv.osv):
"or reconcile it with the payment(s)"),
),
'writeoff_amount': fields.float('Difference Amount'),
- # Legacy field: to be removed after 6.2
+ # Legacy field: to be removed after 7.0
'writeoff_move_line_id': fields.many2one(
'account.move.line', 'Write off move line'),
'writeoff_analytic_id': fields.many2one(
@@ -1703,7 +1404,8 @@ class banking_import_transaction(osv.osv):
banking_import_transaction()
-class account_bank_statement_line(osv.osv):
+
+class account_bank_statement_line(orm.Model):
_inherit = 'account.bank.statement.line'
_columns = {
'import_transaction_id': fields.many2one(
@@ -1722,9 +1424,8 @@ class account_bank_statement_line(osv.osv):
'match_type': fields.related(
'import_transaction_id', 'match_type', type='selection',
selection=[('manual', 'Manual'), ('move','Move'),
- ('invoice', 'Invoice'), ('payment', 'Payment'),
- ('payment_order', 'Payment order'),
- ('storno', 'Storno')],
+ ('invoice', 'Invoice'),
+ ],
string='Match type', readonly=True,),
'state': fields.selection(
[('draft', 'Draft'), ('confirmed', 'Confirmed')], 'State',
@@ -1775,21 +1476,20 @@ class account_bank_statement_line(osv.osv):
"""
statement_pool = self.pool.get('account.bank.statement')
obj_seq = self.pool.get('ir.sequence')
- move_pool = self.pool.get('account.move')
import_transaction_obj = self.pool.get('banking.import.transaction')
for st_line in self.browse(cr, uid, ids, context):
if st_line.state != 'draft':
continue
if st_line.duplicate:
- raise osv.except_osv(
+ raise orm.except_orm(
_('Bank transfer flagged as duplicate'),
_("You cannot confirm a bank transfer marked as a "
"duplicate (%s.%s)") %
(st_line.statement_id.name, st_line.name,))
if st_line.analytic_account_id:
if not st_line.statement_id.journal_id.analytic_journal_id:
- raise osv.except_osv(
+ raise orm.except_orm(
_('No Analytic Journal !'),
_("You have to define an analytic journal on the '%s' "
"journal!") % (st_line.statement_id.journal_id.name,))
@@ -1833,7 +1533,6 @@ class account_bank_statement_line(osv.osv):
ids = [ids]
import_transaction_obj = self.pool.get('banking.import.transaction')
move_pool = self.pool.get('account.move')
- transaction_cancel_ids = []
set_draft_ids = []
move_unlink_ids = []
# harvest ids for various actions
@@ -1841,7 +1540,7 @@ class account_bank_statement_line(osv.osv):
if st_line.state != 'confirmed':
continue
if st_line.statement_id.state != 'draft':
- raise osv.except_osv(
+ raise orm.except_orm(
_("Cannot cancel bank transaction"),
_("The bank statement that this transaction belongs to has "
"already been confirmed"))
@@ -1876,10 +1575,10 @@ class account_bank_statement_line(osv.osv):
ids = [ids]
for line in self.browse(cr, uid, ids, context=context):
if line.state == 'confirmed':
- raise osv.except_osv(
+ raise orm.except_orm(
_('Confirmed Statement Line'),
_("You cannot delete a confirmed Statement Line"
- ": '%s'" % line.name))
+ ": '%s'") % line.name)
return super(account_bank_statement_line, self).unlink(
cr, uid, ids, context=context)
@@ -1921,7 +1620,8 @@ class account_bank_statement_line(osv.osv):
account_bank_statement_line()
-class account_bank_statement(osv.osv):
+
+class account_bank_statement(orm.Model):
_inherit = 'account.bank.statement'
def _end_balance(self, cursor, user, ids, name, attr, context=None):
@@ -1957,19 +1657,21 @@ class account_bank_statement(osv.osv):
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
- raise osv.except_osv(_('Configuration Error !'),
+ raise orm.except_orm(_('Configuration Error !'),
_('Please verify that an account is defined in the journal.'))
# protect against misguided manual changes
for line in st.move_line_ids:
if line.state != 'valid':
- raise osv.except_osv(_('Error !'),
+ raise orm.except_orm(_('Error !'),
_('The account entries lines are not in valid state.'))
line_obj.confirm(cr, uid, [line.id for line in st.line_ids], context)
st.refresh()
- self.log(cr, uid, st.id, _('Statement %s is confirmed, journal '
- 'items are created.') % (st.name,))
+ self.message_post(
+ cr, uid, [st.id],
+ body=_('Statement %s confirmed, journal items were created.')
+ % (st.name,), context=context)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
@@ -1988,8 +1690,12 @@ class account_bank_statement(osv.osv):
for st in self.browse(cr, uid, ids, context=context):
for line in st.line_ids:
if line.state == 'confirmed':
- raise osv.except_osv(_('Confirmed Statement Lines'), _("You cannot delete a Statement with confirmed Statement Lines: '%s'" % st.name))
- return super(account_bank_statement,self).unlink(cr, uid, ids, context=context)
+ raise orm.except_orm(
+ _('Confirmed Statement Lines'),
+ _("You cannot delete a Statement with confirmed "
+ "Statement Lines: '%s'") % st.name)
+ return super(account_bank_statement, self).unlink(
+ cr, uid, ids, context=context)
_columns = {
# override this field *only* to replace the
diff --git a/account_banking/data/account_banking_data.xml b/account_banking/data/account_banking_data.xml
index 6a662268d..3d47ad718 100644
--- a/account_banking/data/account_banking_data.xml
+++ b/account_banking/data/account_banking_data.xml
@@ -20,12 +20,5 @@
-
-
- Manual Bank Transfer
- BANKMAN
-
-
diff --git a/account_banking/migrations/0.1.81/post-set-statement-line-state.py b/account_banking/migrations/0.1.81/post-set-statement-line-state.py
index 93b0a4e55..59d65aa34 100644
--- a/account_banking/migrations/0.1.81/post-set-statement-line-state.py
+++ b/account_banking/migrations/0.1.81/post-set-statement-line-state.py
@@ -4,16 +4,16 @@
# Copyright (C) 2011 Therp BV ()
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/parsers/__init__.py b/account_banking/parsers/__init__.py
index c4e63f265..f79dea6c4 100644
--- a/account_banking/parsers/__init__.py
+++ b/account_banking/parsers/__init__.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/parsers/convert.py b/account_banking/parsers/convert.py
index 326fc8813..8287f4144 100644
--- a/account_banking/parsers/convert.py
+++ b/account_banking/parsers/convert.py
@@ -1,20 +1,20 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV ().
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/parsers/models.py b/account_banking/parsers/models.py
index febb959ab..a8a0c3014 100644
--- a/account_banking/parsers/models.py
+++ b/account_banking/parsers/models.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/record.py b/account_banking/record.py
index 50c863bae..18486c020 100644
--- a/account_banking/record.py
+++ b/account_banking/record.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/security/ir.model.access.csv b/account_banking/security/ir.model.access.csv
index 498785595..5e9d5f05b 100644
--- a/account_banking/security/ir.model.access.csv
+++ b/account_banking/security/ir.model.access.csv
@@ -2,6 +2,5 @@
"access_account_banking_settings","account.banking.account.settings","model_account_banking_account_settings","account.group_account_manager",1,1,1,1
"access_account_banking_settings_user","account.banking.account.settings user","model_account_banking_account_settings","account.group_account_user",1,0,0,0
"access_account_banking_import","account.bankimport","model_account_banking_imported_file","account.group_account_user",1,1,1,1
-"access_payment_mode_type","payment.mode.type","model_payment_mode_type","account_payment.group_account_payment",1,1,1,1
"access_banking_import_transaction","Banking addons - Bank import transaction","model_banking_import_transaction","account.group_account_user",1,1,1,1
"access_banking_transaction_wizard","Banking addons - Transaction wizard","model_banking_transaction_wizard","account.group_account_user",1,1,1,1
diff --git a/account_banking/sepa/__init__.py b/account_banking/sepa/__init__.py
index e2e843ef1..8106ea2ce 100644
--- a/account_banking/sepa/__init__.py
+++ b/account_banking/sepa/__init__.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/sepa/iban.py b/account_banking/sepa/iban.py
index 6ed5d06c5..7d16840d9 100644
--- a/account_banking/sepa/iban.py
+++ b/account_banking/sepa/iban.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/sepa/online.py b/account_banking/sepa/online.py
index 52bca9da9..6e61a5abf 100644
--- a/account_banking/sepa/online.py
+++ b/account_banking/sepa/online.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/sepa/postalcode.py b/account_banking/sepa/postalcode.py
index c97f08010..1220c4ea4 100644
--- a/account_banking/sepa/postalcode.py
+++ b/account_banking/sepa/postalcode.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/sepa/urlagent.py b/account_banking/sepa/urlagent.py
index 330636c5e..bf5bd1042 100644
--- a/account_banking/sepa/urlagent.py
+++ b/account_banking/sepa/urlagent.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/struct.py b/account_banking/struct.py
index cd10f2248..e47d5faf3 100644
--- a/account_banking/struct.py
+++ b/account_banking/struct.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
diff --git a/account_banking/wizard/__init__.py b/account_banking/wizard/__init__.py
index 242510630..7c98ca7b2 100644
--- a/account_banking/wizard/__init__.py
+++ b/account_banking/wizard/__init__.py
@@ -5,22 +5,20 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
import bank_import
-import bank_payment_manual
-import account_payment_order
import banking_transaction_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_banking/wizard/bank_import.py b/account_banking/wizard/bank_import.py
index 9dc222272..9687b7dfd 100644
--- a/account_banking/wizard/bank_import.py
+++ b/account_banking/wizard/bank_import.py
@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
@@ -28,19 +28,15 @@ This module contains the business logic of the wizard account_banking_import.
The parsing is done in the parser modules. Every parser module is required to
use parser.models as a mean of communication with the business logic.
'''
-from osv import osv, fields
-import time
-import netsvc
+from osv import orm, fields
import base64
import datetime
-from tools import config
-from tools.translate import _
-from account_banking.parsers import models
-from account_banking.parsers.convert import *
-from account_banking.struct import struct
-from account_banking import sepa
-from banktools import *
-import decimal_precision as dp
+from openerp.tools.translate import _
+from openerp.addons.account_banking.parsers import models
+from openerp.addons.account_banking.parsers import convert
+from openerp.addons.account_banking.struct import struct
+from openerp.addons.account_banking.wizard import banktools
+from openerp.addons.decimal_precision import decimal_precision as dp
bt = models.mem_bank_transaction
@@ -54,7 +50,8 @@ def parser_types(*args, **kwargs):
'''
return models.parser_type.get_parser_types()
-class banking_import_line(osv.osv_memory):
+
+class banking_import_line(orm.TransientModel):
_name = 'banking.import.line'
_description = 'Bank import lines'
_columns = {
@@ -85,23 +82,19 @@ class banking_import_line(osv.osv_memory):
'invoice_ids': fields.many2many(
'account.invoice', 'banking_import_line_invoice_rel',
'line_id', 'invoice_id'),
- 'payment_order_id': fields.many2one('payment.order', 'Payment order'),
'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account'),
'transaction_type': fields.selection([
# TODO: payment terminal etc...
('invoice', 'Invoice payment'),
- ('payment_order_line', 'Payment from a payment order'),
- ('payment_order', 'Aggregate payment order'),
('storno', 'Canceled debit order'),
('bank_costs', 'Bank costs'),
('unknown', 'Unknown'),
], 'Transaction type'),
'duplicate': fields.boolean('Duplicate'),
}
-banking_import_line()
-class banking_import(osv.osv_memory):
+class banking_import(orm.TransientModel):
_name = 'account.banking.bank.import'
def import_statements_file(self, cursor, uid, ids, context):
@@ -124,7 +117,7 @@ class banking_import(osv.osv_memory):
parser_code = banking_import.parser
parser = models.create_parser(parser_code)
if not parser:
- raise osv.except_osv(
+ raise orm.except_orm(
_('ERROR!'),
_('Unable to import parser %(parser)s. Parser class not found.') %
{'parser': parser_code}
@@ -138,7 +131,7 @@ class banking_import(osv.osv_memory):
statements = parser.parse(cursor, data)
if any([x for x in statements if not x.is_valid()]):
- raise osv.except_osv(
+ raise orm.except_orm(
_('ERROR!'),
_('The imported statements appear to be invalid! Check your file.')
)
@@ -190,7 +183,7 @@ class banking_import(osv.osv_memory):
else:
# Pull account info/currency
- account_info = get_company_bank_account(
+ account_info = banktools.get_company_bank_account(
self.pool, cursor, uid, statement.local_account,
statement.local_currency, company, results.log
)
@@ -247,7 +240,7 @@ class banking_import(osv.osv_memory):
# matching procedure
statement_ids = statement_obj.search(cursor, uid, [
('name', '=', statement.id),
- ('date', '=', date2str(statement.date)),
+ ('date', '=', convert.date2str(statement.date)),
])
if statement_ids:
results.log.append(
@@ -258,11 +251,14 @@ class banking_import(osv.osv_memory):
continue
# Get the period for the statement (as bank statement object checks this)
- period_ids = period_obj.search(cursor, uid, [('company_id','=',company.id),
- ('date_start','<=',statement.date),
- ('date_stop','>=',statement.date),
- ('special', '=', False)])
-
+ period_ids = period_obj.search(
+ cursor, uid, [
+ ('company_id', '=', company.id),
+ ('date_start', '<=', statement.date),
+ ('date_stop', '>=', statement.date),
+ ('special', '=', False),
+ ], context=context)
+
if not period_ids:
results.log.append(
_('No period found covering statement date %(date)s, '
@@ -277,7 +273,7 @@ class banking_import(osv.osv_memory):
statement_id = statement_obj.create(cursor, uid, dict(
name = statement.id,
journal_id = account_info.journal_id.id,
- date = date2str(statement.date),
+ date = convert.date2str(statement.date),
balance_start = statement.start_balance,
balance_end_real = statement.end_balance,
balance_end = statement.end_balance,
@@ -305,11 +301,9 @@ class banking_import(osv.osv_memory):
values['local_account'] = statement.local_account
values['local_currency'] = statement.local_currency
- transaction_id = import_transaction_obj.create(cursor, uid, values, context=context)
- if transaction_id:
- transaction_ids.append(transaction_id)
- else:
- osv.except_osv('Failed to create an import transaction resource','')
+ transaction_id = import_transaction_obj.create(
+ cursor, uid, values, context=context)
+ transaction_ids.append(transaction_id)
results.stat_loaded_cnt += 1
@@ -425,7 +419,6 @@ class banking_import(osv.osv_memory):
'State', readonly=True),
'import_id': fields.many2one(
'account.banking.imported.file', 'Import File'),
- # osv_memory does not seem to support one2many
'statement_ids': fields.many2many(
'account.bank.statement', 'rel_wiz_statements', 'wizard_id',
'statement_id', 'Imported Bank Statements'),
@@ -445,7 +438,3 @@ class banking_import(osv.osv_memory):
cr, uid, 'bank.import.transaction', context=c),
'parser': _default_parser_type,
}
-
-banking_import()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_banking/wizard/bank_payment_manual.py b/account_banking/wizard/bank_payment_manual.py
deleted file mode 100644
index 99178bf00..000000000
--- a/account_banking/wizard/bank_payment_manual.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2009 EduSense BV ().
-# All Rights Reserved
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-'''
-This module contains a single "wizard" for including a 'sent' state for manual
-bank transfers.
-'''
-
-import wizard
-import pooler
-
-class payment_manual(wizard.interface):
- def _action_set_state_sent(self, cursor, uid, data, context):
- '''
- Set the payment order in state 'sent' to reflect money in transfer.
- '''
- payment_order_obj = pooler.get_pool(cursor.dbname)\
- .get('payment.order')
- payment_order_obj.action_sent(cursor, uid, [data['id']], context)
- return {}
-
- states= {
- 'init' : {
- 'actions': [],
- 'result': {
- 'type':'action',
- 'action': _action_set_state_sent,
- 'state': 'end'
- }
- }
- }
-
-payment_manual('account_banking.payment_manual')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_banking/wizard/banking_transaction_wizard.py b/account_banking/wizard/banking_transaction_wizard.py
index 53d2158d3..5e85b9b11 100644
--- a/account_banking/wizard/banking_transaction_wizard.py
+++ b/account_banking/wizard/banking_transaction_wizard.py
@@ -2,25 +2,26 @@
##############################################################################
#
# Copyright (C) 2009 EduSense BV ().
-# (C) 2011 Therp BV ().
+# (C) 2011 - 2013 Therp BV ().
# (C) 2011 Smile ().
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# 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 General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
-from osv import osv, fields
+
+from osv import orm, fields
from openerp.tools.translate import _
"""
@@ -31,7 +32,8 @@ multiple matches or select a manual match.
"""
-class banking_transaction_wizard(osv.osv_memory):
+
+class banking_transaction_wizard(orm.TransientModel):
_name = 'banking.transaction.wizard'
_description = 'Match transaction'
@@ -78,7 +80,7 @@ class banking_transaction_wizard(osv.osv_memory):
cr, uid, ids[0], ['import_transaction_id'],
context=context)['import_transaction_id'][0] # many2one tuple
import_transaction_obj.match(cr, uid, [trans_id], context=context)
- return True
+ return self.create_act_window(cr, uid, ids, context=None)
def write(self, cr, uid, ids, vals, context=None):
"""
@@ -162,7 +164,7 @@ class banking_transaction_wizard(osv.osv_memory):
# transaction_obj.write(
# cr, uid, wiz.import_transaction_id.id,
# { 'invoice_id': False, }, context=context)
- osv.except_osv(
+ orm.except_orm(
_("No entry found for the selected invoice"),
_("No entry found for the selected invoice. " +
"Try manual reconciliation."))
@@ -184,7 +186,7 @@ class banking_transaction_wizard(osv.osv_memory):
move_line_id = line.id
break
if not move_line_id:
- osv.except_osv(
+ orm.except_orm(
_("Cannot select for reconcilion"),
_("No entry found for the selected invoice. "))
else:
@@ -222,7 +224,7 @@ class banking_transaction_wizard(osv.osv_memory):
"""
Just a button that triggers a write.
"""
- return True
+ return self.create_act_window(cr, uid, ids, context=None)
def disable_match(self, cr, uid, ids, context=None):
"""
@@ -255,7 +257,7 @@ class banking_transaction_wizard(osv.osv_memory):
if x['import_transaction_id']]
self.pool.get('banking.import.transaction').clear_and_write(
cr, uid, trans_ids, context=context)
- return True
+ return self.create_act_window(cr, uid, ids, context=None)
def reverse_duplicate(self, cr, uid, ids, context=None):
if isinstance(ids, (int, float)):
@@ -267,7 +269,7 @@ class banking_transaction_wizard(osv.osv_memory):
transaction_obj.write(
cr, uid, wiz['import_transaction_id'][0],
{'duplicate': not wiz['duplicate']}, context=context)
- return True
+ return self.create_act_window(cr, uid, ids, context=None)
def _get_default_match_type(self, cr, uid, context=None):
"""
@@ -320,15 +322,6 @@ class banking_transaction_wizard(osv.osv_memory):
'import_transaction_id', 'writeoff_journal_id',
type='many2one', relation='account.journal',
string='Write-off journal'),
- 'payment_line_id': fields.related(
- 'import_transaction_id', 'payment_line_id', string="Matching payment or storno",
- type='many2one', relation='payment.line', readonly=True),
- 'payment_order_ids': fields.related(
- 'import_transaction_id', 'payment_order_ids', string="Matching payment orders",
- type='many2many', relation='payment.order'),
- 'payment_order_id': fields.related(
- 'import_transaction_id', 'payment_order_id', string="Payment order to reconcile",
- type='many2one', relation='payment.order'),
'invoice_ids': fields.related(
'import_transaction_id', 'invoice_ids', string="Matching invoices",
type='many2many', relation='account.invoice'),
diff --git a/account_banking/wizard/banking_transaction_wizard.xml b/account_banking/wizard/banking_transaction_wizard.xml
index 1d76fd29c..47aa7bab0 100644
--- a/account_banking/wizard/banking_transaction_wizard.xml
+++ b/account_banking/wizard/banking_transaction_wizard.xml
@@ -8,7 +8,6 @@