mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] coding style
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
'category': 'Banking addons',
|
||||
'depends': [
|
||||
'account',
|
||||
],
|
||||
],
|
||||
'data': [
|
||||
'view/account_bank_statement.xml',
|
||||
],
|
||||
|
||||
@@ -93,7 +93,7 @@ class AccountBankStatement(orm.Model):
|
||||
'account_id': (
|
||||
tax.get('account_collected_id',
|
||||
defaults['account_id'])),
|
||||
})
|
||||
})
|
||||
|
||||
return move_lines, update_move_line
|
||||
|
||||
|
||||
@@ -30,5 +30,5 @@ class AccountBankStatementLine(orm.Model):
|
||||
'account.tax', 'Tax',
|
||||
domain=[('price_include', '=', True)],
|
||||
help="Apply an (inclusive) tax from the bank statement line",
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
'category': 'Banking addons',
|
||||
'depends': [
|
||||
'account_voucher',
|
||||
],
|
||||
],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'data/account_banking_data.xml',
|
||||
|
||||
@@ -209,7 +209,7 @@ class account_banking_account_settings(orm.Model):
|
||||
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 = {
|
||||
@@ -350,7 +350,7 @@ class account_bank_statement(orm.Model):
|
||||
(_check_company_id,
|
||||
'The journal and period chosen have to belong to the same company.',
|
||||
['journal_id', 'period_id']),
|
||||
]
|
||||
]
|
||||
|
||||
def _get_period(self, cr, uid, date=False, context=None):
|
||||
"""
|
||||
|
||||
@@ -71,14 +71,16 @@ class banking_import_transaction(orm.Model):
|
||||
|
||||
# search supplier invoice
|
||||
invoice_obj = self.pool.get('account.invoice')
|
||||
invoice_ids = invoice_obj.search(cr, uid, [
|
||||
'&',
|
||||
('type', '=', 'in_invoice'),
|
||||
('partner_id', 'child_of', account_info.bank_partner_id.id),
|
||||
('company_id', '=', account_info.company_id.id),
|
||||
('date_invoice', '=', trans.execution_date),
|
||||
('reference', '=', reference),
|
||||
('amount_total', '=', amount),
|
||||
invoice_ids = invoice_obj.search(
|
||||
cr, uid,
|
||||
[
|
||||
'&',
|
||||
('type', '=', 'in_invoice'),
|
||||
('partner_id', 'child_of', account_info.bank_partner_id.id),
|
||||
('company_id', '=', account_info.company_id.id),
|
||||
('date_invoice', '=', trans.execution_date),
|
||||
('reference', '=', reference),
|
||||
('amount_total', '=', amount),
|
||||
]
|
||||
)
|
||||
if invoice_ids and len(invoice_ids) == 1:
|
||||
@@ -257,7 +259,7 @@ class banking_import_transaction(orm.Model):
|
||||
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
|
||||
self.payment_window))
|
||||
and (not _cached(x) or _remaining(x))
|
||||
]
|
||||
]
|
||||
else:
|
||||
candidates = []
|
||||
|
||||
@@ -281,7 +283,7 @@ class banking_import_transaction(orm.Model):
|
||||
and (not _cached(x) or _remaining(x))
|
||||
and (not partner_ids
|
||||
or x.invoice.partner_id.id in partner_ids))
|
||||
]
|
||||
]
|
||||
|
||||
# Match on amount expected. Limit this kind of search to known
|
||||
# partners.
|
||||
@@ -295,7 +297,7 @@ class banking_import_transaction(orm.Model):
|
||||
self.payment_window)
|
||||
and (not _cached(x) or _remaining(x))
|
||||
and x.partner_id.id in partner_ids)
|
||||
]
|
||||
]
|
||||
|
||||
move_line = False
|
||||
|
||||
@@ -493,7 +495,7 @@ class banking_import_transaction(orm.Model):
|
||||
'amount': line_amount,
|
||||
'account_id': transaction.move_line_id.account_id.id,
|
||||
'type': transaction.move_line_id.credit and 'dr' or 'cr',
|
||||
}
|
||||
}
|
||||
voucher['line_ids'] = [(0, 0, vch_line)]
|
||||
voucher_id = self.pool.get('account.voucher').create(
|
||||
cr, uid, voucher, context=context)
|
||||
@@ -590,7 +592,7 @@ class banking_import_transaction(orm.Model):
|
||||
transaction.move_line_id.reconcile_id.id or
|
||||
transaction.move_line_id.reconcile_partial_id and
|
||||
transaction.move_line_id.reconcile_partial_id.id
|
||||
)
|
||||
)
|
||||
move_lines = []
|
||||
for move in transaction.statement_line_id.move_ids:
|
||||
move_lines += move.line_id
|
||||
@@ -644,7 +646,7 @@ class banking_import_transaction(orm.Model):
|
||||
'invoice': _cancel_voucher,
|
||||
'manual': _cancel_voucher,
|
||||
'move': _cancel_voucher,
|
||||
}
|
||||
}
|
||||
|
||||
def cancel(self, cr, uid, ids, context=None):
|
||||
if ids and isinstance(ids, (int, float)):
|
||||
@@ -667,7 +669,7 @@ class banking_import_transaction(orm.Model):
|
||||
'invoice': _confirm_move,
|
||||
'manual': _confirm_move,
|
||||
'move': _confirm_move,
|
||||
}
|
||||
}
|
||||
|
||||
def confirm(self, cr, uid, ids, context=None):
|
||||
if ids and isinstance(ids, (int, float)):
|
||||
@@ -681,7 +683,7 @@ class banking_import_transaction(orm.Model):
|
||||
_("Cannot reconcile type %s. No method found to " +
|
||||
"reconcile this type") %
|
||||
transaction.match_type
|
||||
)
|
||||
)
|
||||
if (transaction.residual and transaction.writeoff_account_id):
|
||||
if transaction.match_type not in ('invoice', 'move', 'manual'):
|
||||
raise orm.except_orm(
|
||||
@@ -689,7 +691,7 @@ class banking_import_transaction(orm.Model):
|
||||
_("Bank transaction %s: write off not implemented for "
|
||||
"this match type.") %
|
||||
transaction.statement_line_id.name
|
||||
)
|
||||
)
|
||||
# Generalize this bit and move to the confirmation
|
||||
# methods that actually do create a voucher?
|
||||
self.confirm_map[transaction.match_type](
|
||||
@@ -702,7 +704,7 @@ class banking_import_transaction(orm.Model):
|
||||
# such as transferred_amount
|
||||
'execution_date', 'local_account', 'remote_account',
|
||||
'remote_owner', 'reference', 'message',
|
||||
]
|
||||
]
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
"""
|
||||
@@ -1009,7 +1011,7 @@ class banking_import_transaction(orm.Model):
|
||||
transaction.transferred_amount < 0 and
|
||||
account_info.default_credit_account_id.id or
|
||||
account_info.default_debit_account_id.id),
|
||||
}
|
||||
}
|
||||
statement_line_id = statement_line_obj.create(
|
||||
cr, uid, values, context
|
||||
)
|
||||
@@ -1026,12 +1028,12 @@ class banking_import_transaction(orm.Model):
|
||||
results['log'].append(
|
||||
_('transaction %(statement_id)s.%(transaction_id)s for '
|
||||
'account %(bank_account)s uses different currency than '
|
||||
'the defined bank journal.'
|
||||
) % {
|
||||
'bank_account': transactions.local_account,
|
||||
'statement_id': transaction.statement,
|
||||
'transaction_id': transaction.transaction,
|
||||
}
|
||||
'the defined bank journal.') %
|
||||
{
|
||||
'bank_account': transactions.local_account,
|
||||
'statement_id': transaction.statement,
|
||||
'transaction_id': transaction.transaction,
|
||||
}
|
||||
)
|
||||
error_accounts[transaction.local_account] = True
|
||||
results['error_cnt'] += 1
|
||||
@@ -1052,7 +1054,8 @@ class banking_import_transaction(orm.Model):
|
||||
remote_currency=transaction.provision_costs_currency,
|
||||
message=transaction.provision_costs_description,
|
||||
parent_id=transaction.id,
|
||||
), context)
|
||||
),
|
||||
context)
|
||||
|
||||
injected.append(self.browse(cr, uid, cost_id, context))
|
||||
|
||||
@@ -1069,7 +1072,8 @@ class banking_import_transaction(orm.Model):
|
||||
provision_costs=False,
|
||||
provision_costs_currency=False,
|
||||
provision_costs_description=False,
|
||||
), context=context)
|
||||
),
|
||||
context=context)
|
||||
# rebrowse the current record after writing
|
||||
transaction = self.browse(
|
||||
cr, uid, transaction.id, context=context
|
||||
@@ -1086,7 +1090,7 @@ class banking_import_transaction(orm.Model):
|
||||
lines = self._match_costs(
|
||||
cr, uid, transaction, period_id, account_info,
|
||||
results['log']
|
||||
)
|
||||
)
|
||||
results['bank_costs_invoice_cnt'] += bool(lines)
|
||||
for line in lines:
|
||||
if not [x for x in move_lines if x.id == line.id]:
|
||||
@@ -1097,7 +1101,7 @@ class banking_import_transaction(orm.Model):
|
||||
partner_banks = banktools.get_bank_accounts(
|
||||
self.pool, cr, uid, transaction.remote_account,
|
||||
results['log'], fail=True
|
||||
)
|
||||
)
|
||||
if partner_banks:
|
||||
partner_ids = [x.partner_id.id for x in partner_banks]
|
||||
elif transaction.remote_owner:
|
||||
@@ -1137,7 +1141,7 @@ class banking_import_transaction(orm.Model):
|
||||
cr, uid, transaction,
|
||||
payment_lines, partner_ids,
|
||||
partner_banks, results['log'], linked_payments,
|
||||
)
|
||||
)
|
||||
|
||||
# Second guess, invoice -> may split transaction, so beware
|
||||
if not move_info:
|
||||
@@ -1231,7 +1235,7 @@ class banking_import_transaction(orm.Model):
|
||||
res[transaction.id] = (
|
||||
transaction.move_currency_amount -
|
||||
transaction.statement_line_id.amount
|
||||
)
|
||||
)
|
||||
return res
|
||||
|
||||
def _get_match_multi(self, cr, uid, ids, name, args, context=None):
|
||||
@@ -1256,22 +1260,22 @@ class banking_import_transaction(orm.Model):
|
||||
Write values in argument 'vals', but clear all match
|
||||
related values first
|
||||
"""
|
||||
write_vals = (
|
||||
dict([
|
||||
write_vals = dict(
|
||||
[
|
||||
(x, False)
|
||||
for x in [
|
||||
'match_type',
|
||||
'move_line_id',
|
||||
'invoice_id',
|
||||
]
|
||||
] + [
|
||||
] +
|
||||
[
|
||||
(x, [(6, 0, [])])
|
||||
for x in [
|
||||
'move_line_ids',
|
||||
'invoice_ids',
|
||||
]
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
write_vals.update(vals or {})
|
||||
return self.write(cr, uid, ids, write_vals, context=context)
|
||||
@@ -1299,12 +1303,12 @@ class banking_import_transaction(orm.Model):
|
||||
statement.journal_id.currency
|
||||
and statement.journal_id.currency.id
|
||||
or statement.company_id.currency_id.id
|
||||
)
|
||||
)
|
||||
from_curr_id = (
|
||||
transaction.move_line_id.currency_id
|
||||
and transaction.move_line_id.currency_id.id
|
||||
or statement.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,
|
||||
@@ -1346,7 +1350,7 @@ class banking_import_transaction(orm.Model):
|
||||
# used in bank_import.py, converting non-osv transactions
|
||||
'statement_id': 'statement',
|
||||
'id': 'transaction'
|
||||
}
|
||||
}
|
||||
|
||||
_columns = {
|
||||
# start mem_bank_transaction atributes
|
||||
@@ -1454,7 +1458,7 @@ class banking_import_transaction(orm.Model):
|
||||
"sum of allocated amounts. You can either choose to keep "
|
||||
"open this difference on the partner's account, "
|
||||
"or reconcile it with the payment(s)"),
|
||||
),
|
||||
),
|
||||
'writeoff_amount': fields.float('Difference Amount'),
|
||||
# Legacy field: to be removed after 7.0
|
||||
'writeoff_move_line_id': fields.many2one(
|
||||
@@ -1474,7 +1478,7 @@ class banking_import_transaction(orm.Model):
|
||||
s.pool.get('res.company')._company_default_get(
|
||||
cr, uid, 'bank.import.transaction', context=c),
|
||||
'payment_option': 'without_writeoff',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class account_bank_statement_line(orm.Model):
|
||||
@@ -1506,7 +1510,7 @@ class account_bank_statement_line(orm.Model):
|
||||
'residual': fields.related(
|
||||
'import_transaction_id', 'residual', type='float',
|
||||
string='Residual', readonly=True,
|
||||
),
|
||||
),
|
||||
'duplicate': fields.related(
|
||||
'import_transaction_id', 'duplicate', type='boolean',
|
||||
string='Possible duplicate import', readonly=True),
|
||||
@@ -1533,11 +1537,11 @@ class account_bank_statement_line(orm.Model):
|
||||
'link_partner_ok': fields.function(
|
||||
_get_link_partner_ok, type='boolean',
|
||||
string='Can link partner'),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': 'draft',
|
||||
}
|
||||
}
|
||||
|
||||
def match_wizard(self, cr, uid, ids, context=None):
|
||||
res = False
|
||||
@@ -1664,10 +1668,11 @@ class account_bank_statement_line(orm.Model):
|
||||
continue
|
||||
if not st_line.period_id:
|
||||
self.write(
|
||||
cr, uid, [st_line.id], {
|
||||
cr, uid, [st_line.id],
|
||||
{
|
||||
'period_id': self._get_period(
|
||||
cr, uid, date=st_line.date, context=context)
|
||||
})
|
||||
})
|
||||
st_line.refresh()
|
||||
# Generate the statement number, if it is not already done
|
||||
st = st_line.statement_id
|
||||
@@ -1791,14 +1796,17 @@ class account_bank_statement_line(orm.Model):
|
||||
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, {
|
||||
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},
|
||||
cr, uid, line.id,
|
||||
{
|
||||
'import_transaction_id': res
|
||||
},
|
||||
context=context)
|
||||
|
||||
def split_off(self, cr, uid, ids, amount, context=None):
|
||||
@@ -1838,9 +1846,11 @@ class account_bank_statement_line(orm.Model):
|
||||
|
||||
child_statement_ids.append(statement_line_id)
|
||||
transaction_pool.write(
|
||||
cr, uid, transaction_id, {
|
||||
cr, uid, transaction_id,
|
||||
{
|
||||
'statement_line_id': statement_line_id,
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
this.write({'amount': this.amount - amount})
|
||||
|
||||
return child_statement_ids
|
||||
@@ -1939,4 +1949,4 @@ class account_bank_statement(orm.Model):
|
||||
|
||||
'balance_end': fields.function(
|
||||
_end_balance, method=True, store=True, string='Balance'),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class BBANFormat(object):
|
||||
result = ''
|
||||
j = len(self._iban)
|
||||
while i < j and self._iban[i] == spec:
|
||||
result += value[i+4]
|
||||
result += value[i + 4]
|
||||
i += 1
|
||||
return self._nolz and result.lstrip('0') or result
|
||||
|
||||
@@ -337,7 +337,7 @@ class IBAN(str):
|
||||
'''
|
||||
parts = []
|
||||
for i in range(0, len(self), 4):
|
||||
parts.append(self[i:i+4])
|
||||
parts.append(self[i:i + 4])
|
||||
return ' '.join(parts)
|
||||
|
||||
def __unicode__(self):
|
||||
@@ -477,7 +477,7 @@ class BBAN(object):
|
||||
return
|
||||
elif parm in 'ABCDPSTVWXZ':
|
||||
_len = self._get_length(self._fmt, parm)
|
||||
addon = bban[j:j+_len]
|
||||
addon = bban[j:j + _len]
|
||||
if len(addon) != _len:
|
||||
# Note that many accounts in the IBAN standard
|
||||
# are allowed to have leading zeros, so zfill
|
||||
|
||||
@@ -67,11 +67,13 @@ class banking_import_line(orm.TransientModel):
|
||||
'statement_line_id': fields.many2one(
|
||||
'account.bank.statement.line',
|
||||
'Resulting statement line', readonly=True),
|
||||
'type': fields.selection([
|
||||
('supplier', 'Supplier'),
|
||||
('customer', 'Customer'),
|
||||
('general', 'General')
|
||||
], 'Type', required=True),
|
||||
'type': fields.selection(
|
||||
[
|
||||
('supplier', 'Supplier'),
|
||||
('customer', 'Customer'),
|
||||
('general', 'General')
|
||||
],
|
||||
'Type', required=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'statement_id': fields.many2one(
|
||||
'account.bank.statement',
|
||||
@@ -105,7 +107,7 @@ class banking_import_line(orm.TransientModel):
|
||||
'Transaction type',
|
||||
),
|
||||
'duplicate': fields.boolean('Duplicate'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class banking_import(orm.TransientModel):
|
||||
@@ -209,9 +211,10 @@ class banking_import(orm.TransientModel):
|
||||
if not account_info:
|
||||
results.log.append(
|
||||
_('Statements found for unknown account '
|
||||
'%(bank_account)s') % {
|
||||
'bank_account': statement.local_account
|
||||
}
|
||||
'%(bank_account)s') %
|
||||
{
|
||||
'bank_account': statement.local_account
|
||||
}
|
||||
)
|
||||
error_accounts[statement.local_account] = True
|
||||
results.error_cnt += 1
|
||||
@@ -219,8 +222,8 @@ class banking_import(orm.TransientModel):
|
||||
if 'journal_id' not in account_info.keys():
|
||||
results.log.append(
|
||||
_('Statements found for account %(bank_account)s, '
|
||||
'but no default journal was defined.'
|
||||
) % {'bank_account': statement.local_account}
|
||||
'but no default journal was defined.') %
|
||||
{'bank_account': statement.local_account}
|
||||
)
|
||||
error_accounts[statement.local_account] = True
|
||||
results.error_cnt += 1
|
||||
@@ -243,11 +246,12 @@ class banking_import(orm.TransientModel):
|
||||
# TODO: convert currencies?
|
||||
results.log.append(
|
||||
_('Statement %(statement_id)s for account %(bank_account)s'
|
||||
' uses different currency than the defined bank journal.'
|
||||
) % {
|
||||
'bank_account': statement.local_account,
|
||||
'statement_id': statement.id
|
||||
}
|
||||
' uses different currency than the defined bank '
|
||||
'journal.') %
|
||||
{
|
||||
'bank_account': statement.local_account,
|
||||
'statement_id': statement.id
|
||||
}
|
||||
)
|
||||
error_accounts[statement.local_account] = True
|
||||
results.error_cnt += 1
|
||||
@@ -279,7 +283,7 @@ class banking_import(orm.TransientModel):
|
||||
('date_start', '<=', statement.date),
|
||||
('date_stop', '>=', statement.date),
|
||||
('special', '=', False),
|
||||
], context=context)
|
||||
], context=context)
|
||||
|
||||
if not period_ids:
|
||||
results.log.append(
|
||||
@@ -396,8 +400,8 @@ class banking_import(orm.TransientModel):
|
||||
states={
|
||||
'ready': [('readonly', True)],
|
||||
'error': [('readonly', True)],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
'file_name': fields.char('File name', size=256),
|
||||
'file': fields.binary(
|
||||
'Statements File',
|
||||
@@ -412,21 +416,22 @@ class banking_import(orm.TransientModel):
|
||||
states={
|
||||
'ready': [('readonly', True)],
|
||||
'error': [('readonly', True)],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
'parser': fields.selection(
|
||||
parser_types, 'File Format', required=True,
|
||||
states={
|
||||
'ready': [('readonly', True)],
|
||||
'error': [('readonly', True)],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
'log': fields.text('Log', readonly=True),
|
||||
'state': fields.selection(
|
||||
[('init', 'init'),
|
||||
('ready', 'ready'),
|
||||
('error', 'error')
|
||||
],
|
||||
[
|
||||
('init', 'init'),
|
||||
('ready', 'ready'),
|
||||
('error', 'error')
|
||||
],
|
||||
'State', readonly=True),
|
||||
'import_id': fields.many2one(
|
||||
'account.banking.imported.file', 'Import File'),
|
||||
@@ -435,8 +440,8 @@ class banking_import(orm.TransientModel):
|
||||
'statement_id', 'Imported Bank Statements'),
|
||||
'line_ids': fields.one2many(
|
||||
'banking.import.line', 'banking_import_id', 'Transactions',
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
def _default_parser_type(self, cr, uid, context=None):
|
||||
types = models.parser_type.get_parser_types()
|
||||
@@ -448,4 +453,4 @@ class banking_import(orm.TransientModel):
|
||||
s.pool.get('res.company')._company_default_get(
|
||||
cr, uid, 'bank.import.transaction', context=c),
|
||||
'parser': _default_parser_type,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
'target': 'new',
|
||||
'res_id': ids[0],
|
||||
'nodestroy': nodestroy,
|
||||
}
|
||||
}
|
||||
|
||||
def trigger_match(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
@@ -224,7 +224,7 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
(6, 0, [todo_entry[0]] if todo_entry[0] else [])
|
||||
],
|
||||
'match_type': 'manual',
|
||||
}
|
||||
}
|
||||
|
||||
transaction_obj.clear_and_write(
|
||||
cr, uid, transaction_id, vals, context=context)
|
||||
@@ -233,12 +233,12 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
'account_id': move_line_obj.read(
|
||||
cr, uid, todo_entry[1],
|
||||
['account_id'], context=context)['account_id'][0],
|
||||
}
|
||||
}
|
||||
|
||||
if todo_entry[0]:
|
||||
st_line_vals['partner_id'] = invoice_obj.browse(
|
||||
cr, uid, todo_entry[0], context=context
|
||||
).partner_id.commercial_partner_id.id
|
||||
).partner_id.commercial_partner_id.id
|
||||
|
||||
statement_line_obj.write(
|
||||
cr, uid, statement_line_id,
|
||||
@@ -338,8 +338,7 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64),
|
||||
'statement_line_id': fields.many2one(
|
||||
'account.bank.statement.line', 'Statement line',
|
||||
),
|
||||
'account.bank.statement.line', 'Statement line'),
|
||||
'amount': fields.related(
|
||||
'statement_line_id', 'amount', type='float',
|
||||
string="Amount", readonly=True),
|
||||
|
||||
@@ -96,10 +96,12 @@ def get_partner(pool, cr, uid, name, address, postal_code, city,
|
||||
'''
|
||||
partner_obj = pool.get('res.partner')
|
||||
partner_ids = partner_obj.search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
'|', ('is_company', '=', True), ('parent_id', '=', False),
|
||||
('name', 'ilike', name),
|
||||
], context=context)
|
||||
],
|
||||
context=context)
|
||||
if not partner_ids:
|
||||
# Try brute search on address and then match reverse
|
||||
criteria = []
|
||||
|
||||
@@ -36,9 +36,12 @@ class link_partner(orm.TransientModel):
|
||||
'customer': fields.boolean('Customer'),
|
||||
'partner_id': fields.many2one(
|
||||
'res.partner', 'or link existing partner',
|
||||
domain=['|', ('is_company', '=', True),
|
||||
('parent_id', '=', False)],
|
||||
),
|
||||
domain=[
|
||||
'|',
|
||||
('is_company', '=', True),
|
||||
('parent_id', '=', False)
|
||||
],
|
||||
),
|
||||
'statement_line_id': fields.many2one(
|
||||
'account.bank.statement.line',
|
||||
'Statement line', required=True),
|
||||
@@ -66,11 +69,11 @@ class link_partner(orm.TransientModel):
|
||||
'fax': fields.char('Fax', size=64),
|
||||
'mobile': fields.char('Mobile', size=64),
|
||||
'is_company': fields.boolean('Is a Company'),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'is_company': True,
|
||||
}
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
"""
|
||||
@@ -205,4 +208,4 @@ class link_partner(orm.TransientModel):
|
||||
'target': 'new',
|
||||
'res_id': ids[0],
|
||||
'nodestroy': nodestroy,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ CAMT Format parser
|
||||
self.get_unique_account_identifier(
|
||||
cr, statement.local_account),
|
||||
identifier)
|
||||
)
|
||||
)
|
||||
|
||||
# Assuming If there is no Ccy tag then it belongs to defaut currency
|
||||
if not self.xpath(node, './ns:Acct/ns:Ccy'):
|
||||
@@ -193,7 +193,7 @@ CAMT Format parser
|
||||
'value_date': self.xpath(node, './ns:ValDt/ns:Dt')[0].text,
|
||||
'transfer_type': self.get_transfer_type(node),
|
||||
'transferred_amount': self.parse_amount(node)
|
||||
}
|
||||
}
|
||||
TxDtls = self.xpath(node, './ns:NtryDtls/ns:TxDtls')
|
||||
if len(TxDtls) == 1:
|
||||
vals = self.parse_TxDtls(TxDtls[0], entry_details)
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
'depends': ['account_direct_debit'],
|
||||
'external_dependencies': {
|
||||
'python': ['unidecode'],
|
||||
},
|
||||
},
|
||||
'data': [
|
||||
'account_banking_lcr_view.xml',
|
||||
'wizard/export_lcr_view.xml',
|
||||
'data/payment_type_lcr.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
],
|
||||
'demo': ['lcr_demo.xml'],
|
||||
'description': '''
|
||||
French Letter of Change
|
||||
|
||||
@@ -59,10 +59,12 @@ class banking_export_lcr(orm.Model):
|
||||
'filename': fields.function(
|
||||
_generate_filename, type='char', size=256,
|
||||
string='Filename', readonly=True, store=True),
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft'),
|
||||
('sent', 'Sent'),
|
||||
], 'State', readonly=True),
|
||||
'state': fields.selection(
|
||||
[
|
||||
('draft', 'Draft'),
|
||||
('sent', 'Sent'),
|
||||
],
|
||||
'State', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
||||
@@ -36,10 +36,12 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
_description = 'Export French LCR File'
|
||||
|
||||
_columns = {
|
||||
'state': fields.selection([
|
||||
('create', 'Create'),
|
||||
('finish', 'Finish'),
|
||||
], 'State', readonly=True),
|
||||
'state': fields.selection(
|
||||
[
|
||||
('create', 'Create'),
|
||||
('finish', 'Finish'),
|
||||
],
|
||||
'State', readonly=True),
|
||||
'nb_transactions': fields.related(
|
||||
'file_id', 'nb_transactions', type='integer',
|
||||
string='Number of Transactions', readonly=True),
|
||||
@@ -56,11 +58,11 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
'payment_order_ids': fields.many2many(
|
||||
'payment.order', 'wiz_lcr_payorders_rel', 'wizard_id',
|
||||
'payment_order_id', 'Payment Orders', readonly=True),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': 'create',
|
||||
}
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
payment_order_ids = context.get('active_ids', [])
|
||||
@@ -96,7 +98,7 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
unallowed_ascii_chars = [
|
||||
'"', '#', '$', '%', '&', ';', '<', '>', '=', '@',
|
||||
'[', ']', '^', '_', '`', '{', '}', '|', '~', '\\', '!',
|
||||
]
|
||||
]
|
||||
for unallowed_ascii_char in unallowed_ascii_chars:
|
||||
value = value.replace(unallowed_ascii_char, '-')
|
||||
except:
|
||||
@@ -150,7 +152,7 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
'code_guichet': iban[9:14],
|
||||
'numero_compte': iban[14:25],
|
||||
'cle_rib': iban[25:27],
|
||||
}
|
||||
}
|
||||
|
||||
def _prepare_first_cfonb_line(
|
||||
self, cr, uid, lcr_export, context=None):
|
||||
@@ -200,7 +202,7 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
# "remise à l'escompte" and we do
|
||||
# "Encaissement, crédit forfaitaire après l’échéance"
|
||||
ref_remise,
|
||||
])
|
||||
])
|
||||
assert len(cfonb_line) == 160, 'LCR CFONB line must have 160 chars'
|
||||
cfonb_line += '\r\n'
|
||||
return cfonb_line
|
||||
@@ -253,7 +255,7 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
date_creation,
|
||||
' ' * (4 + 1 + 3 + 3 + 9),
|
||||
reference_tireur,
|
||||
])
|
||||
])
|
||||
assert len(cfonb_line) == 160, 'LCR CFONB line must have 160 chars'
|
||||
cfonb_line += '\r\n'
|
||||
return cfonb_line
|
||||
@@ -273,7 +275,7 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
' ' * (6 + 12 + 24 + 24 + 1 + 2 + 5 + 5 + 11),
|
||||
zero_montant_total_centimes,
|
||||
' ' * (4 + 6 + 10 + 15 + 5 + 6),
|
||||
])
|
||||
])
|
||||
assert len(cfonb_line) == 160, 'LCR CFONB line must have 160 chars'
|
||||
return cfonb_line
|
||||
|
||||
@@ -332,7 +334,7 @@ class banking_export_lcr_wizard(orm.TransientModel):
|
||||
'res_model': self._name,
|
||||
'res_id': ids[0],
|
||||
'target': 'new',
|
||||
}
|
||||
}
|
||||
|
||||
return action
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
'depends': [
|
||||
'account_banking',
|
||||
'account_iban_preserve_domestic',
|
||||
],
|
||||
],
|
||||
'data': [
|
||||
'view/res_bank.xml',
|
||||
'view/res_partner_bank.xml',
|
||||
],
|
||||
],
|
||||
'external_dependencies': {
|
||||
'python': ['BeautifulSoup'],
|
||||
},
|
||||
|
||||
@@ -117,12 +117,12 @@ class res_partner_bank(orm.Model):
|
||||
return self.onchange_iban(
|
||||
cr, uid, ids, acc_number, acc_number_domestic,
|
||||
state, partner_id, country_id, context=None
|
||||
)
|
||||
)
|
||||
else:
|
||||
return self.onchange_domestic(
|
||||
cr, uid, ids, acc_number,
|
||||
partner_id, country_id, context=None
|
||||
)
|
||||
)
|
||||
|
||||
def onchange_domestic(
|
||||
self, cr, uid, ids, acc_number,
|
||||
@@ -250,7 +250,7 @@ class res_partner_bank(orm.Model):
|
||||
bank_id, country_id = get_or_create_bank(
|
||||
self.pool, cr, uid, iban_acc.BIC_searchkey,
|
||||
code=iban_acc.BIC_searchkey
|
||||
)
|
||||
)
|
||||
return {
|
||||
'value': dict(
|
||||
acc_number_domestic=iban_acc.localized_BBAN,
|
||||
|
||||
@@ -267,7 +267,7 @@ class transaction(models.mem_bank_transaction):
|
||||
'SEPA BATCH': 'PAYB',
|
||||
'SEPA BATCH SALARIS': 'PAYB',
|
||||
'SEPA TERUGBOEKING': 'RETR',
|
||||
}.get(sepa_type.upper(), 'SEPA')
|
||||
}.get(sepa_type.upper(), 'SEPA')
|
||||
self.remote_account = sepa_dict.get('IBAN', False)
|
||||
self.remote_bank_bic = sepa_dict.get('BIC', False)
|
||||
self.remote_owner = sepa_dict.get('NAME', False)
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'depends': [
|
||||
'account_banking_payment',
|
||||
'account_iban_preserve_domestic',
|
||||
],
|
||||
],
|
||||
'data': [
|
||||
'account_banking_nl_clieop.xml',
|
||||
'wizard/export_clieop_view.xml',
|
||||
|
||||
@@ -54,11 +54,13 @@ class clieop_export(orm.Model):
|
||||
'identification':
|
||||
fields.char('Identification', size=6, readonly=True, select=True),
|
||||
'filetype':
|
||||
fields.selection([
|
||||
('CREDBET', 'Payment Batch'),
|
||||
('SALARIS', 'Salary Payment Batch'),
|
||||
('INCASSO', 'Direct Debit Batch'),
|
||||
], 'File Type', size=7, readonly=True, select=True),
|
||||
fields.selection(
|
||||
[
|
||||
('CREDBET', 'Payment Batch'),
|
||||
('SALARIS', 'Salary Payment Batch'),
|
||||
('INCASSO', 'Direct Debit Batch'),
|
||||
],
|
||||
'File Type', size=7, readonly=True, select=True),
|
||||
'date_generated':
|
||||
fields.date('Generation Date', readonly=True, select=True),
|
||||
'file':
|
||||
|
||||
@@ -52,7 +52,7 @@ def eleven_test(s):
|
||||
r = 0
|
||||
l = len(s)
|
||||
for i, c in enumerate(s):
|
||||
r += (l-i) * int(c)
|
||||
r += (l - i) * int(c)
|
||||
return (r % 11) == 0
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
[
|
||||
('create', 'Create'),
|
||||
('finish', 'Finish')
|
||||
],
|
||||
],
|
||||
'State',
|
||||
readonly=True,
|
||||
),
|
||||
@@ -57,14 +57,14 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
help=('The bank will use this reference in feedback communication '
|
||||
'to refer to this run. Only five characters are available.'
|
||||
),
|
||||
),
|
||||
),
|
||||
'batchtype': fields.selection(
|
||||
[
|
||||
('CLIEOPPAY', 'Payments'),
|
||||
('CLIEOPSAL', 'Salary Payments'),
|
||||
('CLIEOPINC', 'Direct Debits'),
|
||||
], 'Type', readonly=True,
|
||||
),
|
||||
),
|
||||
'execution_date': fields.date(
|
||||
'Execution Date',
|
||||
help=('This is the date the file should be processed by the bank. '
|
||||
@@ -73,86 +73,86 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
'Please keep in mind that banks only execute on working '
|
||||
'days and typically use a delay of two days between '
|
||||
'execution date and effective transfer date.'),
|
||||
),
|
||||
),
|
||||
'test': fields.boolean(
|
||||
'Test Run',
|
||||
help=('Select this if you want your bank to run a test process '
|
||||
'rather then execute your orders for real.'
|
||||
),
|
||||
),
|
||||
),
|
||||
'fixed_message': fields.char(
|
||||
'Fixed Message', size=32,
|
||||
help=('A fixed message to apply to all transactions in addition '
|
||||
'to the individual messages.'),
|
||||
),
|
||||
),
|
||||
# file fields
|
||||
'file_id': fields.many2one(
|
||||
'banking.export.clieop',
|
||||
'ClieOp File',
|
||||
readonly=True
|
||||
),
|
||||
),
|
||||
# fields.related does not seem to support
|
||||
# fields of type selection
|
||||
'testcode': fields.selection(
|
||||
[('T', _('Yes')), ('P', _('No'))],
|
||||
'Test Run', readonly=True,
|
||||
),
|
||||
),
|
||||
'filetype': fields.selection(
|
||||
[
|
||||
('CREDBET', 'Payment Batch'),
|
||||
('SALARIS', 'Salary Payment Batch'),
|
||||
('INCASSO', 'Direct Debit Batch'),
|
||||
],
|
||||
],
|
||||
'File Type',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'prefered_date': fields.related(
|
||||
'file_id', 'prefered_date',
|
||||
type='date',
|
||||
string='Prefered Processing Date',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'no_transactions': fields.related(
|
||||
'file_id', 'no_transactions',
|
||||
type ='integer',
|
||||
string='Number of Transactions',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'check_no_accounts': fields.related(
|
||||
'file_id', 'check_no_accounts',
|
||||
type='char', size=5,
|
||||
string='Check Number Accounts',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'total_amount': fields.related(
|
||||
'file_id', 'total_amount',
|
||||
type='float',
|
||||
string='Total Amount',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'identification': fields.related(
|
||||
'file_id', 'identification',
|
||||
type='char', size=6,
|
||||
string='Identification',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'file': fields.related(
|
||||
'file_id', 'file', type='binary',
|
||||
readonly=True,
|
||||
string='File',
|
||||
),
|
||||
),
|
||||
'filename': fields.related(
|
||||
'file_id', 'filename',
|
||||
type='char', size=32,
|
||||
readonly=True,
|
||||
string='Filename',
|
||||
),
|
||||
),
|
||||
'payment_order_ids': fields.many2many(
|
||||
'payment.order', 'rel_wiz_payorders', 'wizard_id',
|
||||
'payment_order_id', 'Payment Orders',
|
||||
readonly=True,
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
'''
|
||||
@@ -233,7 +233,7 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
'reference': runs[type][0].reference[-5:],
|
||||
'payment_order_ids': [[6, 0, payment_order_ids]],
|
||||
'state': 'create',
|
||||
})
|
||||
})
|
||||
|
||||
def create_clieop(self, cr, uid, ids, context):
|
||||
'''
|
||||
@@ -255,7 +255,7 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
if not our_account_nr:
|
||||
our_account_nr = sepa.IBAN(
|
||||
payment_order.mode.bank_id.acc_number
|
||||
).localized_BBAN
|
||||
).localized_BBAN
|
||||
else:
|
||||
our_account_nr = payment_order.mode.bank_id.acc_number
|
||||
if not our_account_nr:
|
||||
@@ -317,7 +317,7 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
line.bank_id.state == 'iban' and
|
||||
line.bank_id.acc_number_domestic or
|
||||
line.bank_id.acc_number
|
||||
)
|
||||
)
|
||||
iban = sepa.IBAN(other_account_nr)
|
||||
# Is this an IBAN account?
|
||||
if iban.valid:
|
||||
@@ -339,7 +339,8 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
# Generate the specifics of this clieopfile
|
||||
order = clieopfile.order
|
||||
file_id = self.pool.get('banking.export.clieop').create(
|
||||
cr, uid, dict(
|
||||
cr, uid,
|
||||
dict(
|
||||
filetype=order.name_transactioncode,
|
||||
identification=order.identification,
|
||||
prefered_date=strfdate(order.preferred_execution_date),
|
||||
@@ -353,7 +354,8 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
payment_order_ids=[
|
||||
[6, 0, [x.id
|
||||
for x in clieop_export['payment_order_ids']]]],
|
||||
), context)
|
||||
),
|
||||
context)
|
||||
self.write(cr, uid, [ids[0]], dict(
|
||||
filetype=order.name_transactioncode,
|
||||
testcode=order.testcode,
|
||||
@@ -392,7 +394,7 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
clieop_obj = self.pool.get('banking.export.clieop')
|
||||
clieop_obj.write(
|
||||
cr, uid, clieop_export['file_id'].id, {'state': 'sent'}
|
||||
)
|
||||
)
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for order in clieop_export['payment_order_ids']:
|
||||
wf_service.trg_validate(
|
||||
|
||||
@@ -213,7 +213,7 @@ class transaction(models.mem_bank_transaction):
|
||||
line
|
||||
'''
|
||||
msg, message = message.rstrip(), None
|
||||
parts = [msg[i:i+32].rstrip() for i in range(0, len(msg), 32)]
|
||||
parts = [msg[i:i + 32].rstrip() for i in range(0, len(msg), 32)]
|
||||
return '\n'.join(parts)
|
||||
|
||||
def parse_message(self):
|
||||
@@ -231,7 +231,7 @@ class transaction(models.mem_bank_transaction):
|
||||
# Title of action is in remote_owner, message contains additional
|
||||
# info
|
||||
self.reference = self.remote_owner.rstrip()
|
||||
parts = [self.message[i:i+32].rstrip()
|
||||
parts = [self.message[i:i + 32].rstrip()
|
||||
for i in range(0, len(self.message), 32)
|
||||
]
|
||||
if len(parts) > 3:
|
||||
@@ -262,7 +262,7 @@ class transaction(models.mem_bank_transaction):
|
||||
# first part of the message.
|
||||
# Sometimes this misfires, as with the tax office collecting road
|
||||
# taxes, but then a once-only manual correction is sufficient.
|
||||
parts = [self.message[i:i+32].rstrip()
|
||||
parts = [self.message[i:i + 32].rstrip()
|
||||
for i in range(0, len(self.message), 32)
|
||||
]
|
||||
self.reference = self.remote_owner
|
||||
|
||||
@@ -113,7 +113,7 @@ class transaction(models.mem_bank_transaction):
|
||||
'ST': bt.BANK_TERMINAL, # Storting (eigen rekening of derde)
|
||||
'VZ': bt.ORDER, # Verzamelbetaling
|
||||
'NO': bt.STORNO, # Storno
|
||||
}
|
||||
}
|
||||
|
||||
# global expression for matching storno references
|
||||
ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)')
|
||||
@@ -188,7 +188,7 @@ class transaction(models.mem_bank_transaction):
|
||||
self.reference = kn[4:]
|
||||
self.message = 'Acceptgiro %s' % (navr or '')
|
||||
if after:
|
||||
parts = [after[i:i+33] for i in range(0, len(after), 33)]
|
||||
parts = [after[i:i + 33] for i in range(0, len(after), 33)]
|
||||
if parts and not self.remote_owner:
|
||||
self.remote_owner = parts.pop(0).strip()
|
||||
if parts:
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
'depends': ['account_banking_payment_export'],
|
||||
'external_dependencies': {
|
||||
'python': ['unidecode', 'lxml'],
|
||||
},
|
||||
},
|
||||
'data': [
|
||||
'payment_line_view.xml',
|
||||
'payment_mode_view.xml',
|
||||
|
||||
@@ -163,7 +163,7 @@ class banking_export_pain(orm.AbstractModel):
|
||||
'res_model': self._name,
|
||||
'res_id': ids[0],
|
||||
'target': 'new',
|
||||
}
|
||||
}
|
||||
return action
|
||||
|
||||
def generate_group_header_block(
|
||||
|
||||
@@ -30,10 +30,12 @@ class payment_line(orm.Model):
|
||||
return [('ISO', 'ISO')]
|
||||
|
||||
_columns = {
|
||||
'priority': fields.selection([
|
||||
('NORM', 'Normal'),
|
||||
('HIGH', 'High'),
|
||||
], 'Priority',
|
||||
'priority': fields.selection(
|
||||
[
|
||||
('NORM', 'Normal'),
|
||||
('HIGH', 'High'),
|
||||
],
|
||||
'Priority',
|
||||
help="This field will be used as the 'Instruction Priority' in "
|
||||
"the generated PAIN file."),
|
||||
# Update size from 64 to 140, because PAIN allows 140 caracters
|
||||
|
||||
@@ -43,7 +43,7 @@ class ResPartner(orm.Model):
|
||||
'debits from this partner. Overrides the default debit '
|
||||
'account.'),
|
||||
domain=[('type', '!=', 'view')]),
|
||||
}
|
||||
}
|
||||
|
||||
def def_journal_account_bank_decr(
|
||||
self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
'depends': [
|
||||
'account_banking',
|
||||
'account_banking_payment_export',
|
||||
],
|
||||
],
|
||||
'data': [
|
||||
'view/account_payment.xml',
|
||||
'view/banking_transaction_wizard.xml',
|
||||
|
||||
@@ -61,14 +61,16 @@ class payment_order(orm.Model):
|
||||
},
|
||||
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
|
||||
'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',
|
||||
@@ -88,11 +90,13 @@ class payment_order(orm.Model):
|
||||
'done': [('readonly', True)]
|
||||
},
|
||||
),
|
||||
'date_prefered': fields.selection([
|
||||
('now', 'Directly'),
|
||||
('due', 'Due date'),
|
||||
('fixed', 'Fixed date')
|
||||
], "Preferred date", change_default=True, required=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)],
|
||||
@@ -101,9 +105,8 @@ class payment_order(orm.Model):
|
||||
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."
|
||||
)
|
||||
),
|
||||
"execution.")
|
||||
),
|
||||
'date_sent': fields.date('Send date', readonly=True),
|
||||
}
|
||||
|
||||
@@ -234,7 +237,7 @@ class payment_order(orm.Model):
|
||||
line.move_line_id
|
||||
and line.move_line_id.move_id.name
|
||||
or line.communication),
|
||||
}
|
||||
}
|
||||
return vals
|
||||
|
||||
def _prepare_move_line_transfer_account(
|
||||
@@ -255,7 +258,7 @@ class payment_order(orm.Model):
|
||||
and line.amount or 0.0),
|
||||
'date': fields.date.context_today(
|
||||
self, cr, uid, context=context),
|
||||
}
|
||||
}
|
||||
return vals
|
||||
|
||||
def _update_move_line_partner_account(
|
||||
@@ -272,7 +275,7 @@ class payment_order(orm.Model):
|
||||
and line.amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'payment'
|
||||
and line.amount or 0.0),
|
||||
})
|
||||
})
|
||||
return vals
|
||||
|
||||
def action_sent_no_move_line_hook(self, cr, uid, pay_line, context=None):
|
||||
@@ -291,7 +294,7 @@ class payment_order(orm.Model):
|
||||
labels = {
|
||||
'payment': _('Payment order'),
|
||||
'debit': _('Direct debit order'),
|
||||
}
|
||||
}
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
if not order.mode.transfer_journal_id \
|
||||
or not order.mode.transfer_account_id:
|
||||
@@ -338,9 +341,12 @@ class payment_order(orm.Model):
|
||||
account_move_obj.post(cr, uid, [move_id], context=context)
|
||||
|
||||
# State field is written by act_sent_wait
|
||||
self.write(cr, uid, ids, {
|
||||
'date_sent': fields.date.context_today(
|
||||
self, cr, uid, context=context),
|
||||
}, context=context)
|
||||
self.write(
|
||||
cr, uid, ids,
|
||||
{
|
||||
'date_sent': fields.date.context_today(
|
||||
self, cr, uid, context=context),
|
||||
},
|
||||
context=context)
|
||||
|
||||
return True
|
||||
|
||||
@@ -84,11 +84,13 @@ class banking_import_transaction(orm.Model):
|
||||
self, cr, uid, trans, log, context=None):
|
||||
payment_line_obj = self.pool.get('payment.line')
|
||||
line_ids = payment_line_obj.search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
('order_id.payment_order_type', '=', 'debit'),
|
||||
('order_id.state', 'in', ['sent', 'done']),
|
||||
('communication', '=', trans.reference)
|
||||
], context=context)
|
||||
],
|
||||
context=context)
|
||||
# stornos MUST have an exact match
|
||||
if len(line_ids) == 1:
|
||||
account_id = payment_line_obj.get_storno_account_id(
|
||||
@@ -139,7 +141,7 @@ class banking_import_transaction(orm.Model):
|
||||
and round(line.amount, digits) == -round(
|
||||
trans.statement_line_id.amount, digits)
|
||||
and bank_match(trans.remote_account, line.bank_id))
|
||||
]
|
||||
]
|
||||
if len(candidates) == 1:
|
||||
candidate = candidates[0]
|
||||
# Check cache to prevent multiple matching of a single payment
|
||||
@@ -212,18 +214,21 @@ class banking_import_transaction(orm.Model):
|
||||
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, {
|
||||
cr, uid, transaction.payment_line_id.id,
|
||||
{
|
||||
'date_done': transaction.statement_line_id.date,
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
self._confirm_move(cr, uid, transaction_id, context=context)
|
||||
# Check if the payment order is 'done'
|
||||
order_id = transaction.payment_line_id.order_id.id
|
||||
other_lines = payment_line_obj.search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
('order_id', '=', order_id),
|
||||
('date_done', '=', False),
|
||||
], context=context)
|
||||
],
|
||||
context=context)
|
||||
if not other_lines:
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
wf_service.trg_validate(
|
||||
@@ -327,7 +332,7 @@ class banking_import_transaction(orm.Model):
|
||||
'payment_order_id': fields.many2one(
|
||||
'payment.order', 'Payment order to reconcile'),
|
||||
'payment_line_id': fields.many2one('payment.line', 'Payment line'),
|
||||
}
|
||||
}
|
||||
|
||||
def _get_match_multi(self, cr, uid, ids, name, args, context=None):
|
||||
if not ids:
|
||||
@@ -346,7 +351,7 @@ class banking_import_transaction(orm.Model):
|
||||
'payment_line_id': False,
|
||||
'payment_order_id': False,
|
||||
'payment_order_ids': [(6, 0, [])],
|
||||
}
|
||||
}
|
||||
write_vals.update(vals or {})
|
||||
return super(banking_import_transaction, self).clear_and_write(
|
||||
cr, uid, ids, vals=vals, context=context)
|
||||
@@ -361,7 +366,7 @@ class banking_import_transaction(orm.Model):
|
||||
move_info.get('payment_order_ids', False) and
|
||||
len(move_info['payment_order_ids']) == 1 and
|
||||
move_info['payment_order_ids'][0]
|
||||
)
|
||||
)
|
||||
return vals
|
||||
|
||||
def hook_match_payment(self, cr, uid, transaction, log, context=None):
|
||||
|
||||
@@ -46,12 +46,12 @@ class payment_line(orm.Model):
|
||||
'account.move.line', 'Debit move line',
|
||||
readonly=True,
|
||||
help="Move line through which the debit order pays the invoice",
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'msg': '',
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
Hooks for processing direct debit orders, such as implemented in
|
||||
@@ -123,7 +123,7 @@ class payment_line(orm.Model):
|
||||
_('Error'),
|
||||
_('Move line %s has already been reconciled') %
|
||||
torec_move_line.name
|
||||
)
|
||||
)
|
||||
if (transit_move_line.reconcile_id
|
||||
or transit_move_line.reconcile_partial_id):
|
||||
raise orm.except_orm(
|
||||
@@ -141,7 +141,7 @@ class payment_line(orm.Model):
|
||||
line_ids = [
|
||||
x.id for x in
|
||||
torec_move_line.reconcile_partial_id.line_partial_ids
|
||||
] + [transit_move_line.id]
|
||||
] + [transit_move_line.id]
|
||||
|
||||
total = move_line_obj.get_balance(cr, uid, line_ids)
|
||||
vals = {
|
||||
@@ -150,7 +150,7 @@ class payment_line(orm.Model):
|
||||
'line_partial_ids': (is_zero(total)
|
||||
and [(6, 0, [])]
|
||||
or [(6, 0, line_ids)]),
|
||||
}
|
||||
}
|
||||
|
||||
if torec_move_line.reconcile_partial_id:
|
||||
reconcile_obj.write(
|
||||
|
||||
@@ -37,16 +37,16 @@ class payment_mode(orm.Model):
|
||||
help=('Pay off lines in sent orders with a move on this '
|
||||
'account. You can only select accounts of type regular '
|
||||
'that are marked for reconciliation'),
|
||||
),
|
||||
),
|
||||
'transfer_journal_id': fields.many2one(
|
||||
'account.journal', 'Transfer journal',
|
||||
help=('Journal to write payment entries when confirming '
|
||||
'a debit order of this mode'),
|
||||
),
|
||||
),
|
||||
'payment_term_ids': fields.many2many(
|
||||
'account.payment.term', 'account_payment_order_terms_rel',
|
||||
'mode_id', 'term_id', 'Payment terms',
|
||||
help=('Limit selected invoices to invoices with these payment '
|
||||
'terms')
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ class payment_order_create(orm.TransientModel):
|
||||
# apply payment term filter
|
||||
if payment_order.mode.payment_term_ids:
|
||||
domain += [
|
||||
('invoice.payment_term', 'in',
|
||||
[term.id for term in payment_order.mode.payment_term_ids]
|
||||
)
|
||||
]
|
||||
(
|
||||
'invoice.payment_term', 'in',
|
||||
[term.id for term in payment_order.mode.payment_term_ids]
|
||||
)
|
||||
]
|
||||
return True
|
||||
|
||||
@@ -60,12 +60,14 @@ class banking_export_sepa(orm.Model):
|
||||
"line for all the wire transfers of the SEPA XML file ; "
|
||||
"if false, the bank statement will display one debit line "
|
||||
"per wire transfer of the SEPA XML file."),
|
||||
'charge_bearer': fields.selection([
|
||||
('SLEV', 'Following Service Level'),
|
||||
('SHAR', 'Shared'),
|
||||
('CRED', 'Borne by Creditor'),
|
||||
('DEBT', 'Borne by Debtor'),
|
||||
], 'Charge Bearer', readonly=True,
|
||||
'charge_bearer': fields.selection(
|
||||
[
|
||||
('SLEV', 'Following Service Level'),
|
||||
('SHAR', 'Shared'),
|
||||
('CRED', 'Borne by Creditor'),
|
||||
('DEBT', 'Borne by Debtor'),
|
||||
],
|
||||
'Charge Bearer', readonly=True,
|
||||
help="Following service level : transaction charges are to be "
|
||||
"applied following the rules agreed in the service level and/or "
|
||||
"scheme (SEPA Core messages must use this). Shared : "
|
||||
@@ -79,10 +81,12 @@ class banking_export_sepa(orm.Model):
|
||||
'filename': fields.function(
|
||||
_generate_filename, type='char', size=256, string='Filename',
|
||||
readonly=True),
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft'),
|
||||
('sent', 'Sent'),
|
||||
], 'State', readonly=True),
|
||||
'state': fields.selection(
|
||||
[
|
||||
('draft', 'Draft'),
|
||||
('sent', 'Sent'),
|
||||
],
|
||||
'State', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
||||
@@ -33,22 +33,26 @@ class banking_export_sepa_wizard(orm.TransientModel):
|
||||
_description = 'Export SEPA Credit Transfer File'
|
||||
|
||||
_columns = {
|
||||
'state': fields.selection([
|
||||
('create', 'Create'),
|
||||
('finish', 'Finish'),
|
||||
], 'State', readonly=True),
|
||||
'state': fields.selection(
|
||||
[
|
||||
('create', 'Create'),
|
||||
('finish', 'Finish'),
|
||||
],
|
||||
'State', readonly=True),
|
||||
'batch_booking': fields.boolean(
|
||||
'Batch Booking',
|
||||
help="If true, the bank statement will display only one debit "
|
||||
"line for all the wire transfers of the SEPA XML file ; if "
|
||||
"false, the bank statement will display one debit line per wire "
|
||||
"transfer of the SEPA XML file."),
|
||||
'charge_bearer': fields.selection([
|
||||
('SLEV', 'Following Service Level'),
|
||||
('SHAR', 'Shared'),
|
||||
('CRED', 'Borne by Creditor'),
|
||||
('DEBT', 'Borne by Debtor'),
|
||||
], 'Charge Bearer', required=True,
|
||||
'charge_bearer': fields.selection(
|
||||
[
|
||||
('SLEV', 'Following Service Level'),
|
||||
('SHAR', 'Shared'),
|
||||
('CRED', 'Borne by Creditor'),
|
||||
('DEBT', 'Borne by Debtor'),
|
||||
],
|
||||
'Charge Bearer', required=True,
|
||||
help="Following service level : transaction charges are to be "
|
||||
"applied following the rules agreed in the service level and/or "
|
||||
"scheme (SEPA Core messages must use this). Shared : transaction "
|
||||
@@ -73,12 +77,12 @@ class banking_export_sepa_wizard(orm.TransientModel):
|
||||
'payment_order_ids': fields.many2many(
|
||||
'payment.order', 'wiz_sepa_payorders_rel', 'wizard_id',
|
||||
'payment_order_id', 'Payment Orders', readonly=True),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'charge_bearer': 'SLEV',
|
||||
'state': 'create',
|
||||
}
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
payment_order_ids = context.get('active_ids', [])
|
||||
@@ -148,7 +152,7 @@ class banking_export_sepa_wizard(orm.TransientModel):
|
||||
pain_ns = {
|
||||
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
None: 'urn:iso:std:iso:20022:tech:xsd:%s' % pain_flavor,
|
||||
}
|
||||
}
|
||||
|
||||
xml_root = etree.Element('Document', nsmap=pain_ns)
|
||||
pain_root = etree.SubElement(xml_root, root_xml_tag)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
'account_accountant',
|
||||
'account_banking_payment',
|
||||
'account_banking_sepa_credit_transfer',
|
||||
],
|
||||
],
|
||||
'description': '''
|
||||
This addon adds unit tests for the Banking addons. Installing this
|
||||
module will not give you any benefit other than having the tests'
|
||||
|
||||
@@ -55,34 +55,37 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
self.currency_id = data_model.get_object_reference(
|
||||
cr, uid, 'base', 'EUR')[1]
|
||||
self.bank_id = reg('res.bank').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'name': 'ING Bank',
|
||||
'bic': 'INGBNL2A',
|
||||
'country': self.country_id,
|
||||
})
|
||||
})
|
||||
self.company_id = reg('res.company').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'name': '_banking_addons_test_company',
|
||||
'currency_id': self.currency_id,
|
||||
'country_id': self.country_id,
|
||||
})
|
||||
})
|
||||
self.partner_id = reg('res.company').read(
|
||||
cr, uid, self.company_id, ['partner_id'])['partner_id'][0]
|
||||
self.partner_bank_id = reg('res.partner.bank').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'state': 'iban',
|
||||
'acc_number': 'NL08INGB0000000555',
|
||||
'bank': self.bank_id,
|
||||
'bank_bic': 'INGBNL2A',
|
||||
'partner_id': self.partner_id,
|
||||
'company_id': self.company_id,
|
||||
})
|
||||
})
|
||||
reg('res.users').write(
|
||||
cr, uid, [uid], {
|
||||
'company_ids': [(4, self.company_id)]})
|
||||
cr, uid, [uid],
|
||||
{'company_ids': [(4, self.company_id)]})
|
||||
reg('res.users').write(
|
||||
cr, uid, [uid], {
|
||||
'company_id': self.company_id})
|
||||
cr, uid, [uid],
|
||||
{'company_id': self.company_id})
|
||||
|
||||
def setup_chart(self, reg, cr, uid):
|
||||
"""
|
||||
@@ -95,7 +98,8 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
chart_values = {
|
||||
'company_id': self.company_id,
|
||||
'currency_id': self.currency_id,
|
||||
'chart_template_id': chart_template_id}
|
||||
'chart_template_id': chart_template_id
|
||||
}
|
||||
chart_values.update(
|
||||
chart_setup_model.onchange_chart_template_id(
|
||||
cr, uid, [], 1)['value'])
|
||||
@@ -105,13 +109,14 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
cr, uid, [chart_setup_id])
|
||||
year = datetime.now().strftime('%Y')
|
||||
fiscalyear_id = reg('account.fiscalyear').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'name': year,
|
||||
'code': year,
|
||||
'company_id': self.company_id,
|
||||
'date_start': '%s-01-01' % year,
|
||||
'date_stop': '%s-12-31' % year,
|
||||
})
|
||||
})
|
||||
reg('account.fiscalyear').create_period(
|
||||
cr, uid, [fiscalyear_id])
|
||||
|
||||
@@ -163,21 +168,27 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
'partner_id': supplier1,
|
||||
'account_id': self.payable_id,
|
||||
'invoice_line': [
|
||||
(0, False, {
|
||||
'name': 'Purchase 1',
|
||||
'price_unit': 100.0,
|
||||
'quantity': 1,
|
||||
'account_id': expense_id,
|
||||
})
|
||||
(
|
||||
0,
|
||||
False,
|
||||
{
|
||||
'name': 'Purchase 1',
|
||||
'price_unit': 100.0,
|
||||
'quantity': 1,
|
||||
'account_id': expense_id,
|
||||
}
|
||||
)
|
||||
],
|
||||
'reference_type': 'none',
|
||||
'supplier_invoice_number': 'INV1',
|
||||
}
|
||||
self.invoice_ids = [
|
||||
invoice_model.create(
|
||||
cr, uid, values, context={
|
||||
cr, uid, values,
|
||||
context={
|
||||
'type': 'in_invoice',
|
||||
})]
|
||||
})
|
||||
]
|
||||
values.update({
|
||||
'partner_id': supplier2,
|
||||
'name': 'Purchase 2',
|
||||
@@ -201,13 +212,16 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
in transit and configure a payment mode with them.
|
||||
"""
|
||||
account_parent_id = reg('account.account').search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
('company_id', '=', self.company_id),
|
||||
('parent_id', '=', False)])[0]
|
||||
('parent_id', '=', False)
|
||||
])[0]
|
||||
user_type = reg('ir.model.data').get_object_reference(
|
||||
cr, uid, 'account', 'data_account_type_liability')[1]
|
||||
transfer_account_id = reg('account.account').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'company_id': self.company_id,
|
||||
'parent_id': account_parent_id,
|
||||
'code': 'TRANS',
|
||||
@@ -215,20 +229,23 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
'type': 'other',
|
||||
'user_type': user_type,
|
||||
'reconcile': True,
|
||||
})
|
||||
})
|
||||
transfer_journal_id = reg('account.journal').search(
|
||||
cr, uid, [
|
||||
('company_id', '=', self.company_id),
|
||||
('code', '=', 'MISC')])[0]
|
||||
('code', '=', 'MISC')
|
||||
])[0]
|
||||
self.bank_journal_id = reg('account.journal').search(
|
||||
cr, uid, [
|
||||
('company_id', '=', self.company_id),
|
||||
('type', '=', 'bank')])[0]
|
||||
('type', '=', 'bank')
|
||||
])[0]
|
||||
payment_mode_type_id = reg('ir.model.data').get_object_reference(
|
||||
cr, uid, 'account_banking_sepa_credit_transfer',
|
||||
'export_sepa_sct_001_001_03')[1]
|
||||
self.payment_mode_id = reg('payment.mode').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'name': 'SEPA Mode',
|
||||
'bank_id': self.partner_bank_id,
|
||||
'journal': self.bank_journal_id,
|
||||
@@ -236,7 +253,7 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
'transfer_account_id': transfer_account_id,
|
||||
'transfer_journal_id': transfer_journal_id,
|
||||
'type': payment_mode_type_id,
|
||||
})
|
||||
})
|
||||
|
||||
def setup_payment(self, reg, cr, uid):
|
||||
"""
|
||||
@@ -244,40 +261,48 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
Check that the payment order can be confirmed.
|
||||
"""
|
||||
self.payment_order_id = reg('payment.order').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'reference': 'PAY001',
|
||||
'mode': self.payment_mode_id,
|
||||
})
|
||||
})
|
||||
context = {'active_id': self.payment_order_id}
|
||||
entries = reg('account.move.line').search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
('company_id', '=', self.company_id),
|
||||
('account_id', '=', self.payable_id),
|
||||
])
|
||||
])
|
||||
self.payment_order_create_id = reg('payment.order.create').create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'entries': [(6, 0, entries)],
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
reg('payment.order.create').create_payment(
|
||||
cr, uid, [self.payment_order_create_id], context=context)
|
||||
|
||||
# Check if payment lines are created with the correct reference
|
||||
self.assertTrue(
|
||||
reg('payment.line').search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
('move_line_id.invoice', '=', self.invoice_ids[0]),
|
||||
('communication', '=', 'INV1'),
|
||||
('state', '=', 'normal'),
|
||||
], context=context),
|
||||
],
|
||||
context=context),
|
||||
'No payment line created from invoice 1 or with the wrong '
|
||||
'communication')
|
||||
self.assertTrue(
|
||||
reg('payment.line').search(
|
||||
cr, uid, [
|
||||
cr, uid,
|
||||
[
|
||||
('move_line_id.invoice', '=', self.invoice_ids[1]),
|
||||
('communication', '=', 'STR2'),
|
||||
('state', '=', 'structured'),
|
||||
], context=context),
|
||||
],
|
||||
context=context),
|
||||
'No payment line created from invoice 2 or with the wrong '
|
||||
'communication')
|
||||
|
||||
@@ -294,8 +319,10 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
"""
|
||||
export_model = reg('banking.export.sepa.wizard')
|
||||
export_id = export_model.create(
|
||||
cr, uid, {
|
||||
'msg_identification': 'EXP001'},
|
||||
cr, uid,
|
||||
{
|
||||
'msg_identification': 'EXP001'
|
||||
},
|
||||
context={'active_ids': [self.payment_order_id]})
|
||||
export_model.create_sepa(
|
||||
cr, uid, [export_id])
|
||||
@@ -314,19 +341,21 @@ class TestPaymentRoundtrip(SingleTransactionCase):
|
||||
line_model = reg('account.bank.statement.line')
|
||||
wizard_model = reg('banking.transaction.wizard')
|
||||
statement_id = statement_model.create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'name': 'Statement',
|
||||
'journal_id': self.bank_journal_id,
|
||||
'balance_end_real': -200.0,
|
||||
'period_id': reg('account.period').find(cr, uid)[0]
|
||||
})
|
||||
})
|
||||
line_id = line_model.create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'name': 'Statement line',
|
||||
'statement_id': statement_id,
|
||||
'amount': -200.0,
|
||||
'account_id': self.payable_id,
|
||||
})
|
||||
})
|
||||
wizard_id = wizard_model.create(
|
||||
cr, uid, {'statement_line_id': line_id})
|
||||
wizard_model.write(
|
||||
|
||||
@@ -132,7 +132,7 @@ class statement(models.mem_bank_statement):
|
||||
'62F': _closing_balance,
|
||||
'61': _transaction_new,
|
||||
'86': _transaction_info,
|
||||
}
|
||||
}
|
||||
|
||||
rectypes.get(record['recordid'], _not_used)()
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class HSBCParser(object):
|
||||
matchdict[field] = datetime.strptime(datestring, '%y%m%d')
|
||||
if post_check and matchdict[field] > matchdict["valuedate"]:
|
||||
matchdict[field] = matchdict[field].replace(
|
||||
year=matchdict[field].year-1
|
||||
year=matchdict[field].year - 1
|
||||
)
|
||||
except ValueError:
|
||||
matchdict[field] = None
|
||||
|
||||
@@ -61,7 +61,7 @@ class banking_export_hsbc_wizard(orm.TransientModel):
|
||||
help=('The bank will use this reference in feedback communication '
|
||||
'to refer to this run. 35 characters are available.'
|
||||
),
|
||||
),
|
||||
),
|
||||
'execution_date_create': fields.date(
|
||||
'Execution Date',
|
||||
help=('This is the date the file should be processed by the bank. '
|
||||
@@ -71,38 +71,38 @@ class banking_export_hsbc_wizard(orm.TransientModel):
|
||||
'days and typically use a delay of two days between '
|
||||
'execution date and effective transfer date.'
|
||||
),
|
||||
),
|
||||
),
|
||||
'file_id': fields.many2one(
|
||||
'banking.export.hsbc',
|
||||
'hsbc File',
|
||||
readonly=True
|
||||
),
|
||||
),
|
||||
'file': fields.related(
|
||||
'file_id', 'file', type='binary',
|
||||
readonly=True,
|
||||
string='File',
|
||||
),
|
||||
),
|
||||
'execution_date_finish': fields.related(
|
||||
'file_id', 'execution_date', type='date',
|
||||
readonly=True,
|
||||
string='Execution Date',
|
||||
),
|
||||
),
|
||||
'total_amount': fields.related(
|
||||
'file_id', 'total_amount',
|
||||
type='float',
|
||||
string='Total Amount',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'no_transactions': fields.integer(
|
||||
'Number of Transactions',
|
||||
readonly=True,
|
||||
),
|
||||
),
|
||||
'payment_order_ids': fields.many2many(
|
||||
'payment.order', 'rel_wiz_payorders', 'wizard_id',
|
||||
'payment_order_id', 'Payment Orders',
|
||||
readonly=True,
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
logger = logging.getLogger('export_hsbc')
|
||||
|
||||
|
||||
@@ -508,7 +508,7 @@ class Batch(LogicalSection):
|
||||
# Need a debit-credit format for Priority Payments
|
||||
segments.append([
|
||||
['LIN'],
|
||||
[index+1],
|
||||
[index + 1],
|
||||
])
|
||||
segments.append([
|
||||
['DTM'],
|
||||
|
||||
@@ -35,5 +35,4 @@ def migrate(cr, version):
|
||||
"""
|
||||
ALTER TABLE "payment_line"
|
||||
DROP COLUMN "banking_addons_61_debit_move_line_id"
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -124,4 +124,4 @@ class account_move_line(orm.Model):
|
||||
amount_to_receive, method=True,
|
||||
type='float', string='Amount to receive',
|
||||
fnct_search=_to_receive_search),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,47 +49,59 @@ class payment_line(orm.Model):
|
||||
if len(transit_move_line.reconcile_id.line_partial_ids) == 2:
|
||||
# reuse the simple reconcile for the storno transfer
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
cr, uid, reconcile_id,
|
||||
{
|
||||
'line_id': [(6, 0, transit_move_line.id)],
|
||||
'line_partial_ids': [(6, 0, [])],
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
else:
|
||||
# split up the original reconcile in a partial one
|
||||
# and a new one for reconciling the storno transfer
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
cr, uid, reconcile_id,
|
||||
{
|
||||
'line_partial_ids': [(3, transit_move_line.id)],
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
reconcile_id = reconcile_obj.create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'type': 'auto',
|
||||
'line_id': [(6, 0, transit_move_line.id)],
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
elif transit_move_line.reconcile_id:
|
||||
reconcile_id = transit_move_line.reconcile_id.id
|
||||
if len(transit_move_line.reconcile_id.line_id) == 2:
|
||||
# reuse the simple reconcile for the storno transfer
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
cr, uid, reconcile_id,
|
||||
{
|
||||
'line_id': [(6, 0, [transit_move_line.id])]
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
else:
|
||||
# split up the original reconcile in a partial one
|
||||
# and a new one for reconciling the storno transfer
|
||||
partial_ids = [
|
||||
x.id for x in transit_move_line.reconcile_id.line_id
|
||||
if x.id != transit_move_line.id
|
||||
]
|
||||
]
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
cr, uid, reconcile_id,
|
||||
{
|
||||
'line_partial_ids': [(6, 0, partial_ids)],
|
||||
'line_id': [(6, 0, [])],
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
reconcile_id = reconcile_obj.create(
|
||||
cr, uid, {
|
||||
cr, uid,
|
||||
{
|
||||
'type': 'auto',
|
||||
'line_id': [(6, 0, transit_move_line.id)],
|
||||
}, context=context)
|
||||
},
|
||||
context=context)
|
||||
# mark the payment line for storno processed
|
||||
if reconcile_id:
|
||||
self.write(cr, uid, [payment_line_id],
|
||||
@@ -149,4 +161,4 @@ class payment_line(orm.Model):
|
||||
readonly=True,
|
||||
help=("If this is true, the debit order has been canceled "
|
||||
"by the bank or by the customer")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ class payment_order_create(orm.TransientModel):
|
||||
('account_id.type', '=', 'receivable'),
|
||||
('invoice.state', '!=', 'debit_denied'),
|
||||
('amount_to_receive', '>', 0),
|
||||
]
|
||||
]
|
||||
return True
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
'depends': [
|
||||
'base_iban',
|
||||
'account',
|
||||
],
|
||||
],
|
||||
'data': [
|
||||
'res_partner_bank_view.xml'
|
||||
],
|
||||
],
|
||||
'description': '''
|
||||
This module is compatible with OpenERP 7.0.
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ class res_partner_bank(orm.Model):
|
||||
_columns = {
|
||||
'acc_number_domestic': fields.char(
|
||||
'Domestic Account Number', size=64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class account_invoice(orm.Model):
|
||||
_columns = {
|
||||
'payment_mode_id': fields.many2one(
|
||||
'payment.mode', 'Payment Mode'),
|
||||
}
|
||||
}
|
||||
|
||||
def onchange_partner_id(
|
||||
self, cr, uid, ids, type, partner_id, date_invoice=False,
|
||||
@@ -50,7 +50,7 @@ class account_invoice(orm.Model):
|
||||
'partner_bank_id':
|
||||
partner.customer_payment_mode and
|
||||
partner.customer_payment_mode.bank_id.id or False,
|
||||
})
|
||||
})
|
||||
else:
|
||||
res['value']['payment_mode_id'] = False
|
||||
return res
|
||||
|
||||
@@ -35,7 +35,7 @@ class res_partner(orm.Model):
|
||||
'payment.mode', type='many2one', relation='payment.mode',
|
||||
string='Customer Payment Mode', view_load=True,
|
||||
help="Select the default payment mode for this customer."),
|
||||
}
|
||||
}
|
||||
|
||||
def _commercial_fields(self, cr, uid, context=None):
|
||||
res = super(res_partner, self)._commercial_fields(
|
||||
|
||||
@@ -35,5 +35,5 @@ class payment_order_create(orm.TransientModel):
|
||||
('invoice', '=', False),
|
||||
('invoice.payment_mode_id', '=', False),
|
||||
('invoice.payment_mode_id', '=', payment_order.mode.id)
|
||||
]
|
||||
]
|
||||
return True
|
||||
|
||||
@@ -34,7 +34,7 @@ class purchase_order(orm.Model):
|
||||
"from the partner and will be copied to the supplier invoice."),
|
||||
'payment_mode_id': fields.many2one(
|
||||
'payment.mode', 'Payment Mode'),
|
||||
}
|
||||
}
|
||||
|
||||
def _get_default_supplier_partner_bank(
|
||||
self, cr, uid, partner, context=None):
|
||||
@@ -56,12 +56,12 @@ class purchase_order(orm.Model):
|
||||
cr, uid, partner),
|
||||
'payment_mode_id':
|
||||
partner.supplier_payment_mode.id or False,
|
||||
})
|
||||
})
|
||||
else:
|
||||
res['value'].update({
|
||||
'supplier_partner_bank_id': False,
|
||||
'payment_mode_id': False,
|
||||
})
|
||||
})
|
||||
return res
|
||||
|
||||
def action_invoice_create(self, cr, uid, ids, context=None):
|
||||
@@ -73,10 +73,12 @@ class purchase_order(orm.Model):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for invoice in order.invoice_ids:
|
||||
if invoice.state == 'draft':
|
||||
invoice.write({
|
||||
'partner_bank_id':
|
||||
order.supplier_partner_bank_id.id or False,
|
||||
'payment_mode_id':
|
||||
order.payment_mode_id.id or False,
|
||||
}, context=context)
|
||||
invoice.write(
|
||||
{
|
||||
'partner_bank_id':
|
||||
order.supplier_partner_bank_id.id or False,
|
||||
'payment_mode_id':
|
||||
order.payment_mode_id.id or False,
|
||||
},
|
||||
context=context)
|
||||
return res
|
||||
|
||||
@@ -38,5 +38,5 @@ class stock_picking(orm.Model):
|
||||
picking.purchase_id.supplier_partner_bank_id.id or False,
|
||||
'payment_mode_id':
|
||||
picking.purchase_id.payment_mode_id.id or False,
|
||||
})
|
||||
})
|
||||
return invoice_vals
|
||||
|
||||
@@ -29,7 +29,7 @@ class sale_order(orm.Model):
|
||||
_columns = {
|
||||
'payment_mode_id': fields.many2one(
|
||||
'payment.mode', 'Payment Mode'),
|
||||
}
|
||||
}
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
res = super(sale_order, self).onchange_partner_id(
|
||||
@@ -51,5 +51,5 @@ class sale_order(orm.Model):
|
||||
'payment_mode_id': order.payment_mode_id.id or False,
|
||||
'partner_bank_id': order.payment_mode_id and
|
||||
order.payment_mode_id.bank_id.id or False,
|
||||
})
|
||||
})
|
||||
return invoice_vals
|
||||
|
||||
@@ -39,5 +39,5 @@ class stock_picking(orm.Model):
|
||||
picking.sale_id.payment_mode_id.bank_id.id or False,
|
||||
'payment_mode_id':
|
||||
picking.sale_id.payment_mode_id.id or False,
|
||||
})
|
||||
})
|
||||
return invoice_vals
|
||||
|
||||
@@ -47,5 +47,5 @@ class account_bank_statement_line(orm.Model):
|
||||
'target': 'new',
|
||||
'res_id': False,
|
||||
'nodestroy': False,
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
@@ -107,7 +107,7 @@ class instant_voucher(orm.TransientModel):
|
||||
})],
|
||||
'amount': line.amount and abs(line.amount) or False,
|
||||
'journal_id': journal_ids[0],
|
||||
}
|
||||
}
|
||||
if vals['date']:
|
||||
period_ids = period_pool.find(
|
||||
cr, uid, vals['date'], context=context
|
||||
@@ -135,7 +135,7 @@ class instant_voucher(orm.TransientModel):
|
||||
'target': 'new',
|
||||
'res_id': ids[0],
|
||||
'nodestroy': False,
|
||||
}
|
||||
}
|
||||
|
||||
def dummy(self, cr, uid, ids, context=None):
|
||||
return {
|
||||
@@ -149,7 +149,7 @@ class instant_voucher(orm.TransientModel):
|
||||
'target': 'new',
|
||||
'res_id': ids[0],
|
||||
'nodestroy': False,
|
||||
}
|
||||
}
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
"""
|
||||
@@ -272,7 +272,7 @@ class instant_voucher(orm.TransientModel):
|
||||
'match_type': 'move',
|
||||
'invoice_id': False,
|
||||
'invoice_ids': [(6, 0, [])],
|
||||
},
|
||||
},
|
||||
context=context
|
||||
)
|
||||
|
||||
@@ -314,6 +314,6 @@ class instant_voucher(orm.TransientModel):
|
||||
[('sale', 'Sale'),
|
||||
('purchase', 'Purchase')],
|
||||
'Voucher type'),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {'state': 'init'}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
'category': 'Banking addons',
|
||||
'depends': [
|
||||
'base_iban',
|
||||
],
|
||||
],
|
||||
'description': '''
|
||||
The account_iban module in OpenERP mandates the presence of a BIC
|
||||
code on an IBAN account number through a constraint. However, as of
|
||||
@@ -42,6 +42,6 @@ See also https://bugs.launchpad.net/openobject-addons/+bug/933472
|
||||
''',
|
||||
'data': [
|
||||
'data/res_partner_bank_type_field.xml',
|
||||
],
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user