diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py
index ed1b1e495..7f68b1cca 100644
--- a/account_banking/account_banking.py
+++ b/account_banking/account_banking.py
@@ -81,6 +81,10 @@ class account_banking_account_settings(osv.osv):
select=True, required=True),
'journal_id': fields.many2one('account.journal', 'Journal',
required=True),
+ 'partner_id': fields.related(
+ 'company_id', 'partner_id',
+ type='many2one', relation='res.partner',
+ string='Partner'),
'default_credit_account_id': fields.many2one(
'account.account', 'Default credit account', select=True,
help=('The account to use when an unexpected payment was signaled. '
@@ -127,44 +131,59 @@ class account_banking_account_settings(osv.osv):
#),
}
- def _default_company(self, cursor, uid, context=None):
- user = self.pool.get('res.users').browse(cursor, uid, uid, context=context)
- if user.company_id:
- return user.company_id.id
- company_ids = self.pool.get('res.company').search(
- cursor, uid, [('parent_id', '=', False)])
- return len(company_ids) == 1 and company_ids[0] or False
-
- def _default_journal(self, cr, uid, context=None):
- domain = [('type', '=', 'bank')]
+ def _default_company(self, cr, uid, context=None):
+ """
+ Return the user's company or the first company found
+ in the database
+ """
user = self.pool.get('res.users').read(
cr, uid, uid, ['company_id'], context=context)
if user['company_id']:
- domain.append(('company_id', '=', user['company_id'][0]))
+ return user['company_id'][0]
+ return self.pool.get('res.company').search(
+ cr, uid, [('parent_id', '=', False)])[0]
+
+ def _default_partner_id(self, cr, uid, context=None, company_id=False):
+ if not company_id:
+ company_id = self._default_company(cr, uid, context=context)
+ return self.pool.get('res.company').read(
+ cr, uid, company_id, ['partner_id'],
+ context=context)['partner_id'][0]
+
+ def _default_journal(self, cr, uid, context=None, company_id=False):
+ if not company_id:
+ company_id = self._default_company(cr, uid, context=context)
journal_ids = self.pool.get('account.journal').search(
- cr, uid, domain)
- return len(journal_ids) == 1 and journal_ids[0] or False
+ cr, uid, [('type', '=', 'bank'), ('company_id', '=', company_id)])
+ return journal_ids and journal_ids[0] or False
- def _default_partner_bank_id(self, cr, uid, context=None):
- user = self.pool.get('res.users').read(
- cr, uid, uid, ['company_id'], context=context)
- if user['company_id']:
- bank_ids = self.pool.get('res.partner.bank').search(
- cr, uid, [('company_id', '=', user['company_id'][0])])
- if len(bank_ids) == 1:
- return bank_ids[0]
- return False
+ def _default_partner_bank_id(
+ self, cr, uid, context=None, company_id=False):
+ 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]
+ 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
- def _default_debit_account_id(self, cr, uid, context=None):
+ def _default_debit_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))
account_def = self.pool.get('ir.property').get(
cr, uid, 'property_account_receivable',
- 'res.partner', context=context)
+ 'res.partner', context=localcontext)
return account_def and account_def.id or False
- def _default_credit_account_id(self, cr, uid, context=None):
+ 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))
account_def = self.pool.get('ir.property').get(
cr, uid, 'property_account_payable',
- 'res.partner', context=context)
+ 'res.partner', context=localcontext)
return account_def and account_def.id or False
def find(self, cr, uid, journal_id, partner_bank_id=False, context=None):
@@ -173,8 +192,35 @@ class account_banking_account_settings(osv.osv):
domain.append(('partner_bank_id','=',partner_bank_id))
return self.search(cr, uid, domain, context=context)
+ def onchange_partner_bank_id(
+ self, cr, uid, ids, partner_bank_id, context=None):
+ values = {}
+ if partner_bank_id:
+ bank = self.pool.get('res.partner.bank').read(
+ cr, uid, partner_bank_id, ['journal_id'], context=context)
+ if bank['journal_id']:
+ values['journal_id'] = bank['journal_id'][0]
+ return {'value': values}
+
+ def onchange_company_id (
+ self, cr, uid, ids, company_id=False, context=None):
+ if not company_id:
+ return {}
+ result = {
+ 'partner_id': self._default_partner_id(
+ cr, uid, company_id=company_id, context=context),
+ 'journal_id': self._default_journal(
+ cr, uid, company_id=company_id, context=context),
+ 'default_debit_account_id': self._default_debit_account_id(
+ cr, uid, company_id=company_id, context=context),
+ 'default_credit_account_id': self._default_credit_account_id(
+ cr, uid, company_id=company_id, context=context),
+ }
+ return {'value': result}
+
_defaults = {
'company_id': _default_company,
+ 'partner_id': _default_partner_id,
'journal_id': _default_journal,
'default_debit_account_id': _default_debit_account_id,
'default_credit_account_id': _default_credit_account_id,
@@ -410,13 +456,19 @@ class account_bank_statement(osv.osv):
'account.bank.statement.line')
st_line = account_bank_statement_line_obj.browse(
cr, uid, st_line_id, context=context)
+ 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
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}, context=context)
+ cr, uid, [st_line.voucher_id.id], {
+ 'number': st_line_number,
+ 'date': st_line.date,
+ 'period_id': period_id, # AB
+ }, context=context)
if st_line.voucher_id.state == 'cancel':
voucher_pool.action_cancel_draft(
cr, uid, [st_line.voucher_id.id], context=context)
@@ -443,8 +495,6 @@ class account_bank_statement(osv.osv):
context.update({'date': st_line.date})
ctxt = context.copy() # AB
ctxt['company_id'] = st_line.company_id.id # AB
- period_id = self._get_period(
- cr, uid, st_line.date, context=ctxt) # AB
move_id = account_move_obj.create(cr, uid, {
'journal_id': st.journal_id.id,
@@ -1470,16 +1520,13 @@ class res_partner_bank(osv.osv):
if country.code in sepa.IBAN.countries:
acc_number_fmt = sepa.BBAN(acc_number, country.code)
if acc_number_fmt.valid:
- values['acc_number'] = str(acc_number_fmt)
+ values['acc_number_domestic'] = str(acc_number_fmt)
else:
- values['acc_number'] = acc_number
result.update(warning(
_('Invalid format'),
_('The account number has the wrong format for %(country)s')
% {'country': country.name}
))
- else:
- values['acc_number'] = acc_number
return result
def onchange_iban(
diff --git a/account_banking/account_banking_view.xml b/account_banking/account_banking_view.xml
index 5d3dfda68..e43a16802 100644
--- a/account_banking/account_banking_view.xml
+++ b/account_banking/account_banking_view.xml
@@ -39,17 +39,31 @@
form
@@ -60,8 +74,8 @@
-
-
+
+
@@ -328,12 +342,8 @@
-
+ position="attributes">
+ {'invisible':[('state','!=','draft')]}
diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py
index 330a0710d..50fa9294a 100644
--- a/account_banking/banking_import_transaction.py
+++ b/account_banking/banking_import_transaction.py
@@ -25,7 +25,6 @@
##############################################################################
from osv import osv, fields
-import time
import netsvc
import base64
import datetime
@@ -141,7 +140,8 @@ class banking_import_transaction(osv.osv):
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)]
+ is_zero(x.total - trans.transferred_amount) and
+ x.line_ids and x.line_ids[0].debit_move_line_id]
if len(candidates) > 0:
# retrieve the common account_id, if any
account_id = False
@@ -222,7 +222,7 @@ class banking_import_transaction(osv.osv):
Match on ID of invoice (reference, name or number, whatever
available and sensible)
'''
- if invoice.reference:
+ if invoice.reference and len(invoice.reference) > 2:
# Reference always comes first, as it is manually set for a
# reason.
iref = invoice.reference.upper()
@@ -230,7 +230,7 @@ class banking_import_transaction(osv.osv):
return True
if invoice.type.startswith('in_'):
# Internal numbering, no likely match on number
- if invoice.name:
+ if invoice.name and len(invoice.name) > 2:
iname = invoice.name.upper()
if iname in ref or iname in msg:
return True
@@ -375,7 +375,7 @@ class banking_import_transaction(osv.osv):
move_line = False
partial = False
- elif len(candidates) == 1:
+ elif len(candidates) == 1 and candidates[0].invoice:
# Mismatch in amounts
move_line = candidates[0]
invoice = move_line.invoice
@@ -423,10 +423,10 @@ class banking_import_transaction(osv.osv):
if x.partner_id.id == move_line.partner_id.id
]
- return (trans, self._get_move_info(
- cr, uid, [move_line.id],
- account_ids and account_ids[0] or False),
- trans2)
+ return (trans, self._get_move_info(
+ cr, uid, [move_line.id],
+ account_ids and account_ids[0] or False),
+ trans2)
return trans, False, False
@@ -494,7 +494,7 @@ class banking_import_transaction(osv.osv):
if from_curr_id != to_curr_id:
amount_currency = statement_line_pool._convert_currency(
cr, uid, from_curr_id, to_curr_id, move_line_amount,
- round=True, date=time.strftime('%Y-%m-%d'),
+ round=True, date=transaction.move_line_id.date,
context=context)
else:
amount_currency = move_line_amount
@@ -606,7 +606,7 @@ class banking_import_transaction(osv.osv):
payment_line_obj.write(
cr, uid, transaction.payment_line_id.id, {
'export_state': 'done',
- 'date_done': transaction.effective_date,
+ 'date_done': transaction.statement_line_id.date,
}
)
self._confirm_move(cr, uid, transaction_id, context=context)
@@ -961,9 +961,14 @@ class banking_import_transaction(osv.osv):
]
def create(self, cr, uid, vals, context=None):
+ """
+ Search for duplicates of the newly created transaction
+ and mark them as such unless a context key
+ 'transaction_no_duplicate_search' is defined and true.
+ """
res = super(banking_import_transaction, self).create(
cr, uid, vals, context)
- if res:
+ if res and not context.get('transaction_no_duplicate_search'):
me = self.browse(cr, uid, res, context)
search_vals = [(key, '=', me[key])
for key in self.signal_duplicate_keys]
@@ -1052,7 +1057,7 @@ class banking_import_transaction(osv.osv):
if move_lines and len(move_lines) == 1:
retval['reference'] = move_lines[0].ref
if retval['match_type'] == 'invoice':
- retval['invoice_ids'] = [x.invoice.id for x in move_lines]
+ retval['invoice_ids'] = list(set([x.invoice.id for x in move_lines]))
retval['type'] = type_map[move_lines[0].invoice.type]
return retval
@@ -1310,8 +1315,7 @@ class banking_import_transaction(osv.osv):
transaction.remote_owner_address,
transaction.remote_owner_postalcode,
transaction.remote_owner_city,
- country_code, results['log']
- )
+ country_code, results['log'], context=context)
if transaction.remote_account:
partner_bank_id = create_bank_account(
self.pool, cr, uid, partner_id,
@@ -1319,7 +1323,8 @@ class banking_import_transaction(osv.osv):
transaction.remote_owner,
transaction.remote_owner_address,
transaction.remote_owner_city,
- country_code, results['log']
+ country_code, results['log'],
+ bic=transaction.remote_bank_bic
)
partner_banks = partner_bank_obj.browse(
cr, uid, [partner_bank_id]
@@ -1556,11 +1561,19 @@ class banking_import_transaction(osv.osv):
if transaction.move_line_id:
move_line_amount = transaction.move_line_id.amount_residual_currency
- to_curr_id = transaction.statement_id.journal_id.currency and transaction.statement_id.journal_id.currency.id or transaction.statement_line_id.statement_id.company_id.currency_id.id
- from_curr_id = transaction.move_line_id.currency_id and transaction.move_line_id.currency_id.id or transaction.statement_id.company_id.currency_id.id
+ to_curr_id = (
+ transaction.statement_line_id.statement_id.journal_id.currency
+ and transaction.statement_line_id.statement_id.journal_id.currency.id
+ or transaction.statement_line_id.statement_id.company_id.currency_id.id
+ )
+ from_curr_id = (
+ transaction.move_line_id.currency_id
+ and transaction.move_line_id.currency_id.id
+ or transaction.statement_line_id.statement_id.company_id.currency_id.id
+ )
if from_curr_id != to_curr_id:
amount_currency = stline_pool._convert_currency(cr, uid, from_curr_id, to_curr_id, move_line_amount, round=True,
- date=time.strftime('%Y-%m-%d'), context=context)
+ date=transaction.statement_line_id.date, context=context)
else:
amount_currency = move_line_amount
sign = 1
@@ -1871,6 +1884,42 @@ class account_bank_statement_line(osv.osv):
return super(account_bank_statement_line, self).unlink(
cr, uid, ids, context=context)
+ def create_instant_transaction(
+ self, cr, uid, ids, context=None):
+ """
+ Check for existance of import transaction on the
+ bank statement lines. Create instant items if appropriate.
+
+ This way, the matching wizard works on manually
+ encoded statements.
+
+ The transaction is only filled with the most basic
+ information. The use of the transaction at this point
+ is rather to store matching data rather than to
+ provide data about the transaction which have all been
+ transferred to the bank statement line.
+ """
+ import_transaction_pool = self.pool.get('banking.import.transaction')
+ if ids and isinstance(ids, (int, long)):
+ ids = [ids]
+ if context is None:
+ context = {}
+ localcontext = context.copy()
+ localcontext['transaction_no_duplicate_search'] = True
+ for line in self.browse(
+ cr, uid, ids, context=context):
+ if line.state != 'confirmed' and not line.import_transaction_id:
+ res = import_transaction_pool.create(
+ cr, uid, {
+ 'company_id': line.statement_id.company_id.id,
+ 'statement_line_id': line.id,
+ },
+ context=localcontext)
+ self.write(
+ cr, uid, line.id, {
+ 'import_transaction_id': res},
+ context=context)
+
account_bank_statement_line()
class account_bank_statement(osv.osv):
@@ -1919,6 +1968,7 @@ class account_bank_statement(osv.osv):
_('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,))
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
diff --git a/account_banking/wizard/account_payment_order.py b/account_banking/wizard/account_payment_order.py
index 686c8bdfe..f4bbfebfd 100644
--- a/account_banking/wizard/account_payment_order.py
+++ b/account_banking/wizard/account_payment_order.py
@@ -85,12 +85,20 @@ class payment_order_create(osv.osv_memory):
state = communication2 = False
communication = line.ref or '/'
if line.invoice:
- if line.invoice.reference_type == 'structured':
- state = 'structured'
- communication = line.invoice.reference
+ if line.invoice.type in ('in_invoice', 'in_refund'):
+ if line.invoice.reference_type == 'structured':
+ state = 'structured'
+ communication = line.invoice.reference
+ else:
+ state = 'normal'
+ communication2 = line.invoice.reference
else:
- state = 'normal'
- communication2 = line.invoice.reference
+ # Make sure that the communication includes the
+ # customer invoice number (in the case of debit order)
+ communication = line.invoice.number.replace('/', '')
+ state = 'structured'
+ if communication != line.ref:
+ communication2 = line.ref
# support debit orders when enabled
if (payment.payment_order_type == 'debit' and
'amount_to_receive' in line):
@@ -112,7 +120,7 @@ class payment_order_create(osv.osv_memory):
'state': state,
### end account banking
'date': date_to_pay,
- 'currency': line.invoice and line.invoice.currency_id.id or False,
+ 'currency': line.invoice and line.invoice.currency_id.id or line.journal_id.currency.id or line.journal_id.company_id.currency_id.id,
}, context=context)
return {'type': 'ir.actions.act_window_close'}
diff --git a/account_banking/wizard/bank_import.py b/account_banking/wizard/bank_import.py
index af8b8e284..9dc222272 100644
--- a/account_banking/wizard/bank_import.py
+++ b/account_banking/wizard/bank_import.py
@@ -260,7 +260,18 @@ class banking_import(osv.osv_memory):
# 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)])
+ ('date_stop','>=',statement.date),
+ ('special', '=', False)])
+
+ if not period_ids:
+ results.log.append(
+ _('No period found covering statement date %(date)s, '
+ 'statement %(id)s skipped') % {
+ 'date': statement.date,
+ 'id': statement.id,
+ }
+ )
+ continue
# Create the bank statement record
statement_id = statement_obj.create(cursor, uid, dict(
diff --git a/account_banking/wizard/banking_transaction_wizard.py b/account_banking/wizard/banking_transaction_wizard.py
index 8171cb776..53d2158d3 100644
--- a/account_banking/wizard/banking_transaction_wizard.py
+++ b/account_banking/wizard/banking_transaction_wizard.py
@@ -35,6 +35,18 @@ class banking_transaction_wizard(osv.osv_memory):
_name = 'banking.transaction.wizard'
_description = 'Match transaction'
+ def create(self, cr, uid, vals, context=None):
+ """
+ Make sure that the statement line has an import transaction
+ """
+ res = super(banking_transaction_wizard, self).create(
+ cr, uid, vals, context=context)
+ if res and vals.get('statement_line_id'):
+ line_pool = self.pool.get('account.bank.statement.line')
+ line_pool.create_instant_transaction(
+ cr, uid, vals['statement_line_id'], context=context)
+ return res
+
def create_act_window(self, cr, uid, ids, nodestroy=True, context=None):
"""
Return a popup window for this model
diff --git a/account_banking/wizard/banking_transaction_wizard.xml b/account_banking/wizard/banking_transaction_wizard.xml
index 59a697570..1d76fd29c 100644
--- a/account_banking/wizard/banking_transaction_wizard.xml
+++ b/account_banking/wizard/banking_transaction_wizard.xml
@@ -93,7 +93,21 @@
-
+
+
+
diff --git a/account_banking_nl_girotel/girotel.py b/account_banking_nl_girotel/girotel.py
index d78bf115b..0c81f7ddc 100644
--- a/account_banking_nl_girotel/girotel.py
+++ b/account_banking_nl_girotel/girotel.py
@@ -194,7 +194,7 @@ class transaction(models.mem_bank_transaction):
'''
if self.transfer_type == 'VZ':
# Credit bank costs (interest) gets a special treatment.
- if self.remote_owner.starswith('RC AFREK. REK. '):
+ if self.remote_owner.startswith('RC AFREK. REK. '):
self.transfer_type = 'DV'
if self.transfer_type == 'DV':
diff --git a/account_banking_nl_ing/__openerp__.py b/account_banking_nl_ing/__openerp__.py
index 3a9c58346..11108f8f3 100644
--- a/account_banking_nl_ing/__openerp__.py
+++ b/account_banking_nl_ing/__openerp__.py
@@ -31,9 +31,9 @@
##############################################################################
{
'name': 'ING (NL) Bank Statements Import',
- 'version': '0.1.105',
+ 'version': '0.1.140',
'license': 'GPL-3',
- 'author': 'Smile / Therp BV / EduSense BV',
+ 'author': ['Smile', 'Therp BV', 'EduSense BV'],
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['account_banking'],
@@ -43,7 +43,7 @@
'demo_xml': [],
'description': '''
Module to import Dutch ING bank format transaction files. The format covered
-is the CSV format with 'ddmmyy' date syntax.
+is the CSV format with either 'dd-mm-yyyy' or 'yyyymmdd' date syntax.
As the ING bank does not provide detailed specification concerning possible
values and their meaning for the fields in the CSV file format, the statements
diff --git a/account_banking_nl_ing/i18n/nl.po b/account_banking_nl_ing/i18n/nl.po
index 899e86b2d..b42e3dca0 100644
--- a/account_banking_nl_ing/i18n/nl.po
+++ b/account_banking_nl_ing/i18n/nl.po
@@ -24,7 +24,7 @@ msgstr "ING (NL) Bankafschriften importeren "
#: model:ir.module.module,description:account_banking_nl_ing.module_meta_information
msgid "Module to import Dutch ING bank format transaction files. The format covered is the CSV format with 'ddmmyy' date syntax.As the ING bank does not provide detailed specification concerning possiblevalues and their meaning for the fields in the CSV file format, the statementsare parsed according to an educated guess based on incomplete information.You can contact the banking-addons developers through their launchpad page andhelp improve the performance of this import filter onhttps://launchpad.net/banking-addons.Note that imported bank transfers are organized in statements covering periodsof one week, even if the imported files cover a different period.This modules contains no logic, just an import filter for account_banking. "
msgstr "Module voor het importeren van bankafschriften van de Nederlandse ING bank.\n"
-"Bestanden in het CSV-formaat met datumindeling 'ddmmjj' kunnen worden verwerkt.\n\n"
+"Bestanden in het CSV-formaat met datumindeling 'dd-mm-jjjj' of 'jjjjmmdd' kunnen worden verwerkt.\n\n"
"Gezien het feit dat de ING geen enkele vorm van specificaties\n"
"beschikbaar stelt, is de importroutine samengesteld op basis van \n"
"voorbeeldbestanden, en kan volledige dekking niet worden gegarandeerd. U\n"
diff --git a/account_banking_nl_ing/ing.py b/account_banking_nl_ing/ing.py
index 4e6f110b7..1b159f9aa 100644
--- a/account_banking_nl_ing/ing.py
+++ b/account_banking_nl_ing/ing.py
@@ -67,7 +67,10 @@ class transaction_message(object):
re.sub(',', '.', self.transferred_amount))
if self.debcred == 'Af':
self.transferred_amount = -self.transferred_amount
- self.execution_date = self.effective_date = str2date(self.date, '%Y%m%d')
+ try:
+ self.execution_date = self.effective_date = str2date(self.date, '%Y%m%d')
+ except ValueError:
+ self.execution_date = self.effective_date = str2date(self.date, '%d-%m-%Y')
self.statement_id = '' #self.effective_date.strftime('%Yw%W')
self.id = str(subno).zfill(4)
self.reference = ''
@@ -178,7 +181,10 @@ class statement(models.mem_bank_statement):
super(statement, self).__init__(*args, **kwargs)
self.id = msg.statement_id
self.local_account = msg.local_account
- self.date = str2date(msg.date, '%Y%m%d')
+ try:
+ self.date = str2date(msg.date, '%Y%m%d')
+ except ValueError:
+ self.date = str2date(msg.date, '%d-%m-%Y')
self.start_balance = self.end_balance = 0 # msg.start_balance
self.import_transaction(msg)
diff --git a/account_direct_debit/i18n/nl.po b/account_direct_debit/i18n/nl.po
index f17539556..6fedca692 100644
--- a/account_direct_debit/i18n/nl.po
+++ b/account_direct_debit/i18n/nl.po
@@ -58,7 +58,7 @@ msgstr "Incasso geweigerd"
#. module: account_direct_debit
#: help:payment.mode,transfer_account_id:0
msgid "Pay off lines in sent orders with a move on this account. For debit type modes only. You can only select accounts of type regular that are marked for reconciliation"
-msgstr "Betaal op het moment van versturen de openstaande posten met een boeking op deze rekening. Alleen van toepassing op een incassomodus. Alleen rekeningen van type 'normaal' kunnen hier worden geselecteerd, die ook voorzien zijn van kemnerk 'afletteren'.
+msgstr "Betaal op het moment van versturen de openstaande posten met een boeking op deze rekening. Alleen van toepassing op een incassomodus. Alleen rekeningen van type 'normaal' kunnen hier worden geselecteerd, die ook voorzien zijn van kenmerk 'afletteren'.
#. module: account_direct_debit
#: field:account.move.line,invoice_state:0
diff --git a/account_direct_debit/model/account_move_line.py b/account_direct_debit/model/account_move_line.py
index ce4225d4d..9a00955b1 100644
--- a/account_direct_debit/model/account_move_line.py
+++ b/account_direct_debit/model/account_move_line.py
@@ -89,7 +89,7 @@ class account_move_line(osv.osv):
def _dummy(self, cr, user, ids, name, arg, context=None):
res = {}
if ids:
- res = dict([(x.id, False) for x in ids])
+ res = dict([(x, False) for x in ids])
return res
def _invoice_payment_term_id_search(
diff --git a/account_direct_debit/model/account_payment.py b/account_direct_debit/model/account_payment.py
index da896cf65..fe4cb6d7b 100644
--- a/account_direct_debit/model/account_payment.py
+++ b/account_direct_debit/model/account_payment.py
@@ -447,6 +447,7 @@ class payment_order_create(osv.osv_memory):
('account_id.type', '=', 'payable'),
('amount_to_pay', '>', 0)
]
+ domain.append(('company_id', '=', payment.mode.company_id.id))
# apply payment term filter
if payment.mode.payment_term_ids:
domain = domain + [
diff --git a/account_direct_debit/view/account_payment.xml b/account_direct_debit/view/account_payment.xml
index 1b559616a..1570cca36 100644
--- a/account_direct_debit/view/account_payment.xml
+++ b/account_direct_debit/view/account_payment.xml
@@ -63,8 +63,14 @@
form
-
-
+
+
diff --git a/account_direct_debit/workflow/account_payment.xml b/account_direct_debit/workflow/account_payment.xml
index 6c529a490..7ea27c523 100644
--- a/account_direct_debit/workflow/account_payment.xml
+++ b/account_direct_debit/workflow/account_payment.xml
@@ -12,7 +12,7 @@
another state, 'sent_wait' between sent and done.
-->
- False
+
diff --git a/bank_statement_instant_voucher/__init__.py b/bank_statement_instant_voucher/__init__.py
new file mode 100644
index 000000000..16e8b082f
--- /dev/null
+++ b/bank_statement_instant_voucher/__init__.py
@@ -0,0 +1 @@
+import model
diff --git a/bank_statement_instant_voucher/__openerp__.py b/bank_statement_instant_voucher/__openerp__.py
new file mode 100644
index 000000000..5a811d541
--- /dev/null
+++ b/bank_statement_instant_voucher/__openerp__.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2012 Therp BV ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{
+ "name": "Bank statement instant voucher",
+ "version": "1.0r028",
+ "author": "Therp BV",
+ "category": 'Base',
+ 'complexity': "normal",
+ "description": """
+This module adds a new button on the bank statement line that allows the
+accountant to instantly create a sales or purchase voucher based on the
+values of the bank statement line.
+
+This module does not depend on account_banking, but if this module is
+installed, the bank statement line will be reconciled automatically
+in the confirmation step of the wizard.
+
+If account_banking is not installed, the accountant will still have to
+reconcile the associated move line with the move line from the bank
+statement line manually.
+
+If the wizard is cancelled,the created voucher will be deleted again.
+
+Known limitations:
+
+Currency conversion and payment difference writeoff are not yet
+supported.
+ """,
+ 'website': 'http://therp.nl',
+ 'images': [],
+ 'depends': ['account_voucher'],
+ 'data': [
+ 'view/account_voucher_instant.xml',
+ 'view/account_bank_statement_line.xml',
+ ],
+ "license": 'AGPL-3',
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/bank_statement_instant_voucher/i18n/nl.po b/bank_statement_instant_voucher/i18n/nl.po
new file mode 100644
index 000000000..d6cfa507e
--- /dev/null
+++ b/bank_statement_instant_voucher/i18n/nl.po
@@ -0,0 +1,158 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * bank_statement_instant_voucher
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-11-12 10:42+0000\n"
+"PO-Revision-Date: 2012-11-12 10:42+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: bank_statement_instant_voucher
+#: view:account.voucher.instant:0
+msgid "Confirm"
+msgstr "Bevestig"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:71
+#, python-format
+msgid "Voucher for statement line %s.%s"
+msgstr "Journaalbon voor bankafschrift %s.%s"
+
+#. module: bank_statement_instant_voucher
+#: field:account.voucher.instant,state:0
+msgid "State"
+msgstr "Status"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:201
+#, python-format
+msgid "The voucher could not be posted."
+msgstr "De journaalbon kon niet worden bevestigd."
+
+#. module: bank_statement_instant_voucher
+#: selection:account.voucher.instant,state:0
+msgid "ready"
+msgstr "ready"
+
+#. module: bank_statement_instant_voucher
+#: model:ir.model,name:bank_statement_instant_voucher.model_account_voucher_instant
+msgid "Instant Voucher"
+msgstr "Instant journaalbon"
+
+#. module: bank_statement_instant_voucher
+#: selection:account.voucher.instant,state:0
+msgid "confirm"
+msgstr "confirm"
+
+#. module: bank_statement_instant_voucher
+#: view:account.bank.statement:0
+#: model:ir.actions.act_window,name:bank_statement_instant_voucher.act_instant_voucher
+msgid "Create matching voucher"
+msgstr "Bijpassende journaalbon aanmaken"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:137
+#, python-format
+msgid "Cannot determine statement line"
+msgstr "Kan de bankafschriftregel niet afleiden"
+
+#. module: bank_statement_instant_voucher
+#: selection:account.voucher.instant,state:0
+msgid "init"
+msgstr "init"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:209
+#, python-format
+msgid "The voucher's move line could not be posted."
+msgstr "De journaalposten van de journaalbon konden niet geboekt worden"
+
+#. module: bank_statement_instant_voucher
+#: model:ir.model,name:bank_statement_instant_voucher.model_account_bank_statement_line
+msgid "Bank Statement Line"
+msgstr "Bankafschriftregel"
+
+#. module: bank_statement_instant_voucher
+#: view:account.voucher.instant:0
+msgid "Create voucher"
+msgstr "Journaalbon aanmaken"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:214
+#, python-format
+msgid "The amount on the bank statement line needs to be the same as on the voucher. Write-off is not yet supported."
+msgstr "Het bedrag op het bankafschrift dient gelijk te zijn aan het bedrag op de journaalbon. Afschrijven is nog niet ondersteund."
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:59
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:136
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:190
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:200
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:208
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:213
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:224
+#, python-format
+msgid "Error"
+msgstr "Fout"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:60
+#, python-format
+msgid "No %s journal defined"
+msgstr "Geen %s-dagboek ingesteld"
+
+#. module: bank_statement_instant_voucher
+#: constraint:account.bank.statement.line:0
+msgid "The amount of the voucher must be the same amount as the one on the statement line"
+msgstr "Het bedrag op de bon moet hetzelfde bedrag zijn dat vermeld staat op de afschriftregel"
+
+#. module: bank_statement_instant_voucher
+#: field:account.voucher.instant,balance:0
+msgid "Balance"
+msgstr "Balans"
+
+#. module: bank_statement_instant_voucher
+#: field:account.voucher.instant,statement_line_id:0
+msgid "Bank statement line"
+msgstr "Bankafschriftregel"
+
+#. module: bank_statement_instant_voucher
+#: field:account.voucher.instant,ref:0
+msgid "Reference"
+msgstr "Referentie"
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:191
+#, python-format
+msgid "Currency on the bank statement line needs to be the same as on the voucher. Currency conversion is not yet supported."
+msgstr "De valuta van de bankafschriftregel dient gelijk te zijn aan die op de journaalbon. Omrekenen tussen valuta is nog niet ondersteund."
+
+#. module: bank_statement_instant_voucher
+#: code:addons/bank_statement_instant_voucher/model/account_voucher_instant.py:225
+#, python-format
+msgid "Cannot match a confirmed statement line"
+msgstr "Kan een bevestigde bankafschriftregel niet afletteren"
+
+#. module: bank_statement_instant_voucher
+#: field:account.voucher.instant,voucher_id:0
+msgid "Voucher"
+msgstr "Journaalbon"
+
+#. module: bank_statement_instant_voucher
+#: view:account.voucher.instant:0
+msgid "Cancel"
+msgstr "Annuleer"
+
+#. module: bank_statement_instant_voucher
+#: field:account.voucher.instant,partner_id:0
+msgid "Partner"
+msgstr "Relatie"
+
diff --git a/bank_statement_instant_voucher/model/__init__.py b/bank_statement_instant_voucher/model/__init__.py
new file mode 100644
index 000000000..bb3faa358
--- /dev/null
+++ b/bank_statement_instant_voucher/model/__init__.py
@@ -0,0 +1,2 @@
+import account_voucher_instant
+import account_bank_statement_line
diff --git a/bank_statement_instant_voucher/model/account_bank_statement_line.py b/bank_statement_instant_voucher/model/account_bank_statement_line.py
new file mode 100644
index 000000000..cf8beb9c3
--- /dev/null
+++ b/bank_statement_instant_voucher/model/account_bank_statement_line.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2012 Therp BV ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class account_bank_statement_line(osv.Model):
+ _inherit = 'account.bank.statement.line'
+ def create_instant_voucher(self, cr, uid, ids, context=None):
+ res = False
+ if ids:
+ if isinstance(ids, (int, float)):
+ ids = [ids]
+ if context is None:
+ context = {}
+ local_context = context.copy()
+ local_context['active_id'] = ids[0]
+ wizard_obj = self.pool.get('account.voucher.instant')
+ res = {
+ 'name': wizard_obj._description,
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': wizard_obj._name,
+ 'domain': [],
+ 'context': local_context,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'res_id': False,
+ 'nodestroy': False,
+ }
+ return res
diff --git a/bank_statement_instant_voucher/model/account_voucher_instant.py b/bank_statement_instant_voucher/model/account_voucher_instant.py
new file mode 100644
index 000000000..7ca3727ba
--- /dev/null
+++ b/bank_statement_instant_voucher/model/account_voucher_instant.py
@@ -0,0 +1,306 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2012 Therp BV ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+from openerp.tools.translate import _
+from openerp.addons.decimal_precision import decimal_precision as dp
+
+
+class instant_voucher(osv.TransientModel):
+ _name = 'account.voucher.instant'
+ _description = 'Instant Voucher'
+
+ def cancel(self, cr, uid, ids, context=None):
+ """
+ Delete the voucher and close window
+ """
+ assert len(ids) == 1, "Will only take one resource id"
+ instant = self.browse(cr, uid, ids[0], context=context)
+ if instant.voucher_id:
+ self.pool.get('account.voucher').cancel_voucher(
+ cr, uid, [instant.voucher_id.id], context=context)
+ self.pool.get('account.voucher').unlink(
+ cr, uid, [instant.voucher_id.id], context=context)
+ return {'type': 'ir.actions.act_window_close'}
+
+ def get_voucher_defaults(
+ self, cr, uid, vals, context=None):
+ """
+ Gather conditional defaults based on given key, value pairs
+
+ :param vals: dictionary of key, value pairs
+ :returns: dictionary of default values for fields not in vals
+ """
+ values_pool = self.pool.get('ir.values')
+ voucher_pool = self.pool.get('account.voucher')
+ res = {}
+ for (key, val) in vals.iteritems():
+ if val and voucher_pool._all_columns[key].column.change_default:
+ for default in values_pool.get_defaults(
+ cr, uid, 'account.voucher', '%s=%s' % (key, val)):
+ if default[1] not in vals:
+ res[default[1]] = default[2]
+ return res
+
+ def create_voucher(self, cr, uid, ids, context=None):
+ """
+ Create a fully fledged voucher counterpart for the
+ statement line. User only needs to process taxes and may
+ adapt cost/income account.
+ """
+ assert len(ids) == 1, "Will only take one resource id"
+ voucher_pool = self.pool.get('account.voucher')
+ period_pool = self.pool.get('account.period')
+ instant = self.browse(cr, uid, ids[0], context=context)
+ line = instant.statement_line_id
+ voucher_type = line.amount < 0 and 'purchase' or 'sale'
+ journal_ids = self.pool.get('account.journal').search(
+ cr, uid, [('company_id', '=', line.company_id.id),
+ ('type', '=', voucher_type)])
+ if not journal_ids:
+ osv.exept_osv(
+ _('Error'),
+ _('No %s journal defined') % voucher_type)
+
+ journal = self.pool.get('account.journal').browse(
+ cr, uid, journal_ids[0], context=context)
+ if journal.type in ('sale', 'sale_refund'):
+ line_account_id = (journal.default_credit_account_id and
+ journal.default_credit_account_id.id or False)
+ elif journal.type in ('purchase', 'expense', 'purchase_refund'):
+ line_account_id = (journal.default_debit_account_id and
+ journal.default_debit_account_id.id or False)
+ vals = {
+ 'name': _('Voucher for statement line %s.%s') % (line.statement_id.name, line.name),
+ 'reference': line.ref or False,
+ 'company_id': line.company_id.id,
+ 'partner_id': instant.partner_id.id,
+ 'date': line.date or res.get('line.date', False),
+ 'account_id': line.account_id.id,
+ 'type': voucher_type,
+ 'line_ids': [(0, 0, {'amount': abs(line.amount),
+ 'account_id': line_account_id,
+ 'type': line.amount < 0 and 'dr' or 'cr',
+ 'name': line.ref or False,
+ })],
+ 'amount': line.amount and abs(line.amount) or res.get('amount', False),
+ 'journal_id': journal_ids[0],
+ }
+ if vals['date']:
+ period_ids = period_pool.find(cr, uid, vals['date'], context=context)
+ if period_ids:
+ vals['period_id'] = period_ids[0]
+ vals.update(self.get_voucher_defaults(cr, uid, vals, context=context))
+
+ voucher_id = voucher_pool.create(
+ cr, uid, vals, context=context)
+ self.write(
+ cr, uid, ids[0],
+ {'voucher_id': voucher_id,
+ 'state': 'ready',
+ 'type': voucher_type,
+ }, context=context)
+ return {
+ 'name': self._description,
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': self._name,
+ 'domain': [],
+ 'context': context,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'res_id': ids[0],
+ 'nodestroy': False,
+ }
+
+ def dummy(self, cr, uid, ids, context=None):
+ return {
+ 'name': self._description,
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': self._name,
+ 'domain': [],
+ 'context': context,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'res_id': ids[0],
+ 'nodestroy': False,
+ }
+
+ def default_get(self, cr, uid, fields_list, context=None):
+ """
+ Gather sane default values from the originating statement line
+ """
+ res = super(instant_voucher, self).default_get(
+ cr, uid, fields_list, context=context)
+ if 'statement_line_id' in fields_list:
+ res['statement_line_id'] = (
+ context.get('active_id') or
+ context.get('active_ids') and context.get('active_ids')[0])
+ if not res['statement_line_id']:
+ raise osv.except_osv(
+ _('Error'),
+ _('Cannot determine statement line'))
+ line = self.pool.get('account.bank.statement.line').browse(
+ cr, uid, res['statement_line_id'], context=context)
+ if 'balance' in fields_list:
+ res['balance'] = line.amount
+ if 'ref' in fields_list:
+ res['ref'] = line.ref
+ if 'partner_id' in fields_list:
+ if line.partner_id:
+ res['partner_id'] = line.partner_id.id
+ return res
+
+ def _get_balance(self, cr, uid, ids, field_name, args, context=None):
+ """
+ Compute the expected residual
+ TODO: currency conversion
+ """
+ res = {}
+ for instant in self.browse(cr, uid, ids, context=context):
+ if instant.voucher_id and instant.voucher_id.state == 'posted':
+ amount = instant.statement_line_id.amount
+ counteramount = 0.0
+ for line in instant.voucher_id.move_ids:
+ if line.account_id.id == instant.statement_line_id.account_id.id:
+ counteramount = line.debit - line.credit
+ for line in instant.voucher_id.move_ids:
+ if line.account_id.id == instant.statement_line_id.account_id.id:
+ counteramount = line.debit - line.credit
+ else:
+ amount = abs(instant.statement_line_id.amount)
+ counteramount = abs(instant.voucher_id and instant.voucher_id.amount or 0.0)
+ res[instant.id] = amount - counteramount
+ return res
+
+ def confirm(self, cr, uid, ids, context=None):
+ """
+ Post the voucher if necessary
+ Post the voucher's move lines if necessary
+ Sanity checks on currency and residual = 0.0
+
+ If the account_banking module is installed, perform matching
+ and reconciliation. If not, the user is left to manual
+ reconciliation of OpenERP.
+ """
+ assert len(ids) == 1, "Will only take one resource id"
+ statement_line_obj = self.pool.get('account.bank.statement.line')
+ voucher_obj = self.pool.get('account.voucher')
+ move_obj = self.pool.get('account.move')
+ instant = self.browse(cr, uid, ids[0], context=context)
+ voucher_currency = (instant.voucher_id.currency_id and
+ instant.voucher_id.currency_id or
+ instant.voucher_id.company_id.currency_id)
+ if (instant.statement_line_id.statement_id.currency.id !=
+ voucher_currency.id):
+ raise osv.except_osv(
+ _("Error"),
+ _("Currency on the bank statement line needs to be the "
+ "same as on the voucher. Currency conversion is not yet "
+ "supported."))
+ if instant.voucher_id.state != 'posted':
+ voucher_obj.proforma_voucher(
+ cr, uid, [instant.voucher_id.id], context=context)
+ instant.refresh()
+ if instant.voucher_id.state != 'posted':
+ raise osv.except_osv(
+ _("Error"),
+ _("The voucher could not be posted."))
+ if instant.voucher_id.move_id.state != 'posted':
+ move_obj.post(
+ cr, uid, [instant.voucher_id.move_id.id], context=context)
+ instant.refresh()
+ if instant.voucher_id.move_id.state != 'posted':
+ raise osv.except_osv(
+ _("Error"),
+ _("The voucher's move line could not be posted."))
+ if not self.pool.get('res.currency').is_zero(
+ cr, uid, voucher_currency, instant.balance):
+ raise osv.except_osv(
+ _("Error"),
+ _("The amount on the bank statement line needs to be the "
+ "same as on the voucher. Write-off is not yet "
+ "supported."))
+ # Banking Addons integration:
+ # Gather the info needed to match the bank statement line
+ # and trigger its posting and reconciliation.
+ if 'import_transaction_id' in statement_line_obj._columns:
+ if instant.statement_line_id.state == 'confirmed':
+ raise osv.except_osv(
+ _("Error"),
+ _("Cannot match a confirmed statement line"))
+ if not instant.statement_line_id.import_transaction_id:
+ statement_line_obj.create_instant_transaction(
+ cr, uid, instant.statement_line_id.id, context=context)
+ instant.statement_line_id.refresh()
+ for line in instant.voucher_id.move_ids:
+ if line.account_id.id == instant.statement_line_id.account_id.id:
+ self.pool.get('banking.import.transaction').write(
+ cr, uid, instant.statement_line_id.import_transaction_id.id,
+ {
+ 'move_line_id': line.id,
+ 'move_line_ids': [(6, 0, [line.id])],
+ 'match_type': 'move',
+ 'invoice_id': False,
+ 'invoice_ids': [(6, 0, [])],
+ }, context=context)
+
+ statement_line_obj.confirm(
+ cr, uid, [instant.statement_line_id.id], context=context)
+ break
+ return {'type': 'ir.actions.act_window_close'}
+
+ _columns = {
+ 'balance': fields.function(
+ _get_balance,
+ type='float',
+ digits_compute=dp.get_precision('Account'),
+ string="Balance",),
+ 'partner_id': fields.many2one(
+ 'res.partner',
+ 'Partner',
+ required=True),
+ 'statement_line_id': fields.many2one(
+ 'account.bank.statement.line',
+ 'Bank statement line',
+ readonly=True),
+ 'ref': fields.related(
+ 'statement_line_id', 'ref',
+ type="char", size="48",
+ readonly=True,
+ string="Reference"),
+ 'voucher_id': fields.many2one(
+ 'account.voucher',
+ 'Voucher',
+ readonly=True),
+ 'state': fields.selection(
+ [('init', 'init'),
+ ('ready', 'ready'),
+ ('confirm', 'confirm')],
+ 'State'),
+ 'type': fields.selection(
+ [('sale', 'Sale'),
+ ('purchase', 'Purchase')],
+ 'Voucher type'),
+ }
+
+ _defaults = {'state': 'init'}
diff --git a/bank_statement_instant_voucher/view/account_bank_statement_line.xml b/bank_statement_instant_voucher/view/account_bank_statement_line.xml
new file mode 100644
index 000000000..1ca7ea52b
--- /dev/null
+++ b/bank_statement_instant_voucher/view/account_bank_statement_line.xml
@@ -0,0 +1,21 @@
+
+
+
+
+ Add instant voucher button to bank statement line on statement form
+
+ account.bank.statement
+ form
+
+
+
+
+
+
+
+
+
diff --git a/bank_statement_instant_voucher/view/account_voucher_instant.xml b/bank_statement_instant_voucher/view/account_voucher_instant.xml
new file mode 100644
index 000000000..cccf06fb8
--- /dev/null
+++ b/bank_statement_instant_voucher/view/account_voucher_instant.xml
@@ -0,0 +1,52 @@
+
+
+
+
+ Instant voucher form view
+ account.voucher.instant
+ form
+
+
+
+
+
+
+