mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] PEP8
This commit is contained in:
@@ -50,8 +50,8 @@ class AccountBankStatement(orm.Model):
|
||||
|
||||
fiscal_position = (
|
||||
st_line.partner_id.property_account_position
|
||||
if st_line.partner_id
|
||||
and st_line.partner_id.property_account_position
|
||||
if (st_line.partner_id and
|
||||
st_line.partner_id.property_account_position)
|
||||
else False)
|
||||
tax_ids = self.pool.get('account.fiscal.position').map_tax(
|
||||
cr, uid, fiscal_position, [st_line.tax_id])
|
||||
@@ -77,8 +77,8 @@ class AccountBankStatement(orm.Model):
|
||||
move_lines.append({
|
||||
'move_id': defaults['move_id'],
|
||||
'name': (
|
||||
defaults.get('name', '')
|
||||
+ ' ' + ustr(tax['name'] or '')),
|
||||
defaults.get('name', '') + ' ' +
|
||||
ustr(tax['name'] or '')),
|
||||
'date': defaults.get('date', False),
|
||||
'partner_id': defaults.get('partner_id', False),
|
||||
'ref': defaults.get('ref', False),
|
||||
|
||||
@@ -446,9 +446,9 @@ class account_bank_statement(orm.Model):
|
||||
('account_id', '=', st_line.account_id.id)],
|
||||
context=context)
|
||||
account_move_line_obj.write(cr, uid, torec, {
|
||||
(st_line.reconcile_id.line_partial_ids
|
||||
and 'reconcile_partial_id'
|
||||
or 'reconcile_id'): st_line.reconcile_id.id
|
||||
(st_line.reconcile_id.line_partial_ids and
|
||||
'reconcile_partial_id' or
|
||||
'reconcile_id'): st_line.reconcile_id.id
|
||||
}, context=context)
|
||||
for move_line in (st_line.reconcile_id.line_id or []) + (
|
||||
st_line.reconcile_id.line_partial_ids or []):
|
||||
|
||||
@@ -204,8 +204,8 @@ class banking_import_transaction(orm.Model):
|
||||
iname = invoice.name.upper()
|
||||
if iname in ref or iname in msg:
|
||||
return True
|
||||
if (invoice.supplier_invoice_number
|
||||
and len(invoice.supplier_invoice_number) > 2):
|
||||
if (invoice.supplier_invoice_number and
|
||||
len(invoice.supplier_invoice_number) > 2):
|
||||
supp_ref = invoice.supplier_invoice_number.upper()
|
||||
if supp_ref in ref or supp_ref in msg:
|
||||
return True
|
||||
@@ -257,8 +257,8 @@ class banking_import_transaction(orm.Model):
|
||||
if x.partner_id.id in partner_ids and
|
||||
(convert.str2date(x.date, '%Y-%m-%d') <=
|
||||
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
|
||||
self.payment_window))
|
||||
and (not _cached(x) or _remaining(x))
|
||||
self.payment_window)) and
|
||||
(not _cached(x) or _remaining(x))
|
||||
]
|
||||
else:
|
||||
candidates = []
|
||||
@@ -279,10 +279,10 @@ class banking_import_transaction(orm.Model):
|
||||
if (x.invoice and has_id_match(x.invoice, ref, msg) and
|
||||
convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
|
||||
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
|
||||
self.payment_window)
|
||||
and (not _cached(x) or _remaining(x))
|
||||
and (not partner_ids
|
||||
or x.invoice.partner_id.id in partner_ids))
|
||||
self.payment_window) 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
|
||||
@@ -291,12 +291,12 @@ class banking_import_transaction(orm.Model):
|
||||
candidates = [
|
||||
x for x in move_lines
|
||||
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
|
||||
trans.statement_line_id.amount)
|
||||
and convert.str2date(x.date, '%Y-%m-%d') <=
|
||||
trans.statement_line_id.amount) and
|
||||
convert.str2date(x.date, '%Y-%m-%d') <=
|
||||
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
|
||||
self.payment_window)
|
||||
and (not _cached(x) or _remaining(x))
|
||||
and x.partner_id.id in partner_ids)
|
||||
self.payment_window) and
|
||||
(not _cached(x) or _remaining(x)) and
|
||||
x.partner_id.id in partner_ids)
|
||||
]
|
||||
|
||||
move_line = False
|
||||
@@ -309,8 +309,8 @@ class banking_import_transaction(orm.Model):
|
||||
best = [
|
||||
x for x in candidates
|
||||
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
|
||||
trans.statement_line_id.amount)
|
||||
and convert.str2date(x.date, '%Y-%m-%d') <=
|
||||
trans.statement_line_id.amount) and
|
||||
convert.str2date(x.date, '%Y-%m-%d') <=
|
||||
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
|
||||
self.payment_window))
|
||||
]
|
||||
@@ -329,10 +329,10 @@ class banking_import_transaction(orm.Model):
|
||||
# transfers first
|
||||
paid = [
|
||||
x for x in move_lines
|
||||
if x.invoice and has_id_match(x.invoice, ref, msg)
|
||||
and convert.str2date(x.invoice.date_invoice, '%Y-%m-%d')
|
||||
<= convert.str2date(trans.execution_date, '%Y-%m-%d')
|
||||
and (_cached(x) and not _remaining(x))
|
||||
if x.invoice and has_id_match(x.invoice, ref, msg) and
|
||||
convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
|
||||
convert.str2date(trans.execution_date, '%Y-%m-%d') and
|
||||
(_cached(x) and not _remaining(x))
|
||||
]
|
||||
if paid:
|
||||
log.append(
|
||||
@@ -524,12 +524,10 @@ class banking_import_transaction(orm.Model):
|
||||
"""
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
reconcile_obj = self.pool.get('account.move.reconcile')
|
||||
is_zero = lambda amount: self.pool.get('res.currency').is_zero(
|
||||
cr, uid, currency, amount)
|
||||
move_lines = move_line_obj.browse(cr, uid, move_line_ids,
|
||||
context=context)
|
||||
reconcile = (move_lines[0].reconcile_id
|
||||
or move_lines[0].reconcile_partial_id)
|
||||
reconcile = (move_lines[0].reconcile_id or
|
||||
move_lines[0].reconcile_partial_id)
|
||||
line_ids = [
|
||||
x.id
|
||||
for x in reconcile.line_id or reconcile.line_partial_ids
|
||||
@@ -537,7 +535,9 @@ class banking_import_transaction(orm.Model):
|
||||
for move_line_id in move_line_ids:
|
||||
line_ids.remove(move_line_id)
|
||||
if len(line_ids) > 1:
|
||||
full = is_zero(move_line_obj.get_balance(cr, uid, line_ids))
|
||||
full = self.pool['res.currency'].is_zero(
|
||||
cr, uid, currency,
|
||||
move_line_obj.get_balance(cr, uid, line_ids))
|
||||
if full:
|
||||
line_partial_ids = []
|
||||
else:
|
||||
@@ -633,8 +633,8 @@ class banking_import_transaction(orm.Model):
|
||||
cr, uid, [st_line.voucher_id.id], context=context)
|
||||
voucher_pool.unlink(
|
||||
cr, uid, [st_line.voucher_id.id], context=context)
|
||||
if (transaction.move_line_id
|
||||
and transaction.move_line_id.invoice):
|
||||
if (transaction.move_line_id and
|
||||
transaction.move_line_id.invoice):
|
||||
# reopening the invoice
|
||||
netsvc.LocalService('workflow').trg_validate(
|
||||
uid, 'account.invoice',
|
||||
@@ -934,8 +934,8 @@ class banking_import_transaction(orm.Model):
|
||||
move_lines = []
|
||||
|
||||
# Create fallback currency code
|
||||
currency_code = (transaction.local_currency
|
||||
or company.currency_id.name)
|
||||
currency_code = (transaction.local_currency or
|
||||
company.currency_id.name)
|
||||
|
||||
# Check cache for account info/currency
|
||||
if transaction.local_account in info and \
|
||||
@@ -1045,8 +1045,8 @@ class banking_import_transaction(orm.Model):
|
||||
continue
|
||||
|
||||
# When bank costs are part of transaction itself, split it.
|
||||
if (transaction.type != bt.BANK_COSTS
|
||||
and transaction.provision_costs):
|
||||
if (transaction.type != bt.BANK_COSTS and
|
||||
transaction.provision_costs):
|
||||
# Create new transaction for bank costs
|
||||
cost_id = self.copy(
|
||||
cr, uid, transaction.id,
|
||||
@@ -1132,9 +1132,9 @@ class banking_import_transaction(orm.Model):
|
||||
cr, uid, [partner_bank_id], context=context)
|
||||
|
||||
# Credit means payment... isn't it?
|
||||
if (not move_info
|
||||
and transaction.statement_line_id.amount < 0
|
||||
and payment_lines):
|
||||
if (not move_info and
|
||||
transaction.statement_line_id.amount < 0 and
|
||||
payment_lines):
|
||||
# Link open payment - if any
|
||||
# Note that _match_payment is defined in the
|
||||
# account_banking_payment module which should be installed
|
||||
@@ -1192,13 +1192,11 @@ class banking_import_transaction(orm.Model):
|
||||
values['type'] = move_info['type']
|
||||
else:
|
||||
values['partner_id'] = values['partner_bank_id'] = False
|
||||
if (not values['partner_id']
|
||||
and partner_ids
|
||||
and len(partner_ids) == 1):
|
||||
if (not values['partner_id'] and partner_ids and
|
||||
len(partner_ids) == 1):
|
||||
values['partner_id'] = partner_ids[0]
|
||||
if (not values['partner_bank_id']
|
||||
and partner_banks
|
||||
and len(partner_banks) == 1):
|
||||
if (not values['partner_bank_id'] and partner_banks and
|
||||
len(partner_banks) == 1):
|
||||
values['partner_bank_id'] = partner_banks[0].id
|
||||
|
||||
statement_line_obj.write(
|
||||
@@ -1303,14 +1301,14 @@ class banking_import_transaction(orm.Model):
|
||||
transaction.move_line_id.amount_residual_currency)
|
||||
statement = transaction.statement_line_id.statement_id
|
||||
to_curr_id = (
|
||||
statement.journal_id.currency
|
||||
and statement.journal_id.currency.id
|
||||
or statement.company_id.currency_id.id
|
||||
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
|
||||
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(
|
||||
@@ -1325,8 +1323,8 @@ class banking_import_transaction(orm.Model):
|
||||
if transaction.move_line_id.amount_currency < 0:
|
||||
sign = -1
|
||||
else:
|
||||
if (transaction.move_line_id.debit
|
||||
- transaction.move_line_id.credit) < 0:
|
||||
if (transaction.move_line_id.debit -
|
||||
transaction.move_line_id.credit) < 0:
|
||||
sign = -1
|
||||
res[transaction.id] = sign * amount_currency
|
||||
|
||||
@@ -1497,10 +1495,9 @@ class account_bank_statement_line(orm.Model):
|
||||
res = {}
|
||||
for line in self.browse(cr, uid, ids, context):
|
||||
res[line.id] = bool(
|
||||
line.state == 'draft'
|
||||
and not line.partner_id
|
||||
and line.import_transaction_id
|
||||
and line.import_transaction_id.remote_account)
|
||||
line.state == 'draft' and not line.partner_id and
|
||||
line.import_transaction_id and
|
||||
line.import_transaction_id.remote_account)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
@@ -1587,8 +1584,8 @@ class account_bank_statement_line(orm.Model):
|
||||
{'partner_id': statement_line.partner_bank_id.partner_id.id})
|
||||
return True
|
||||
|
||||
if (not statement_line.import_transaction_id
|
||||
or not statement_line.import_transaction_id.remote_account):
|
||||
if (not statement_line.import_transaction_id or
|
||||
not statement_line.import_transaction_id.remote_account):
|
||||
raise orm.except_orm(
|
||||
_("Error"),
|
||||
_("No bank account available to link partner to"))
|
||||
@@ -1828,8 +1825,8 @@ class account_bank_statement_line(orm.Model):
|
||||
cr, uid, this.import_transaction_id.id
|
||||
)
|
||||
transaction_data['transferred_amount'] = amount
|
||||
transaction_data['message'] = ((transaction_data['message'] or '')
|
||||
+ _(' (split)'))
|
||||
transaction_data['message'] = (
|
||||
(transaction_data['message'] or '') + _(' (split)'))
|
||||
transaction_data['parent_id'] = this.import_transaction_id.id
|
||||
transaction_id = transaction_pool.create(
|
||||
cr,
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
##############################################################################
|
||||
|
||||
import unicodedata
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
__all__ = ['str2date', 'date2str', 'date2date', 'to_swift']
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def str2date(datestr, format='%d/%m/%y'):
|
||||
'''Convert a string to a datatime object'''
|
||||
|
||||
@@ -289,8 +289,8 @@ class mem_bank_transaction(object):
|
||||
Heuristic check: at least id, execution_date, remote_account and
|
||||
transferred_amount should be filled to create a valid transfer.
|
||||
'''
|
||||
return (self.execution_date and self.remote_account
|
||||
and self.transferred_amount and True) or False
|
||||
return (self.execution_date and self.remote_account and
|
||||
self.transferred_amount and True) or False
|
||||
|
||||
|
||||
class parser_type(type):
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import unicodedata
|
||||
from datetime import datetime, date
|
||||
|
||||
|
||||
__all__ = [
|
||||
'Field', 'Filler', 'DateField', 'NumberField', 'RightAlignedField',
|
||||
'RecordType', 'Record', 'asciify'
|
||||
@@ -26,9 +30,6 @@ __all__ = [
|
||||
|
||||
__doc__ = '''Ease working with fixed length records in files'''
|
||||
|
||||
import unicodedata
|
||||
from datetime import datetime, date
|
||||
|
||||
|
||||
def strpdate(str, format):
|
||||
return datetime.strptime(str, format).date()
|
||||
|
||||
@@ -327,8 +327,8 @@ class IBAN(str):
|
||||
'''
|
||||
_buffer = self[4:] + self[:4]
|
||||
return (
|
||||
self.countrycode in self.countries
|
||||
and int(base36_to_base10str(_buffer)) % 97 == 1
|
||||
self.countrycode in self.countries and
|
||||
int(base36_to_base10str(_buffer)) % 97 == 1
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -91,8 +91,7 @@ class link_partner(orm.TransientModel):
|
||||
_('Error'),
|
||||
_('Statement line is already linked to a bank account '))
|
||||
|
||||
if not(transaction
|
||||
and transaction.remote_account):
|
||||
if not (transaction and transaction.remote_account):
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('No transaction data on statement line'))
|
||||
|
||||
@@ -81,8 +81,8 @@ class res_partner_bank(orm.Model):
|
||||
Create dual function IBAN account for SEPA countries
|
||||
'''
|
||||
if vals.get('state') == 'iban':
|
||||
iban = (vals.get('acc_number')
|
||||
or vals.get('acc_number_domestic', False))
|
||||
iban = (vals.get('acc_number') or
|
||||
vals.get('acc_number_domestic', False))
|
||||
vals['acc_number'], vals['acc_number_domestic'] = (
|
||||
self._correct_IBAN(iban))
|
||||
return super(res_partner_bank, self).create(
|
||||
|
||||
@@ -44,13 +44,13 @@ class payment_line(orm.Model):
|
||||
vals = {}
|
||||
partner_bank_id = vals.get('bank_id')
|
||||
move_line_id = vals.get('move_line_id')
|
||||
if (context.get('search_payment_order_type') == 'debit'
|
||||
and 'mandate_id' not in vals):
|
||||
if (context.get('search_payment_order_type') == 'debit' and
|
||||
'mandate_id' not in vals):
|
||||
if move_line_id:
|
||||
line = self.pool['account.move.line'].browse(
|
||||
cr, uid, move_line_id, context=context)
|
||||
if (line.invoice and line.invoice.type == 'out_invoice'
|
||||
and line.invoice.mandate_id):
|
||||
if (line.invoice and line.invoice.type == 'out_invoice' and
|
||||
line.invoice.mandate_id):
|
||||
vals.update({
|
||||
'mandate_id': line.invoice.mandate_id.id,
|
||||
'bank_id':
|
||||
@@ -68,8 +68,8 @@ class payment_line(orm.Model):
|
||||
|
||||
def _check_mandate_bank_link(self, cr, uid, ids):
|
||||
for payline in self.browse(cr, uid, ids):
|
||||
if (payline.mandate_id and payline.bank_id
|
||||
and payline.mandate_id.partner_bank_id.id !=
|
||||
if (payline.mandate_id and payline.bank_id and
|
||||
payline.mandate_id.partner_bank_id.id !=
|
||||
payline.bank_id.id):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
|
||||
@@ -204,10 +204,8 @@ class transaction(models.mem_bank_transaction):
|
||||
key_info = _get_next_key(items, item_index)
|
||||
value_end_index = (key_info and key_info[1]) or items_len
|
||||
sepa_value = (
|
||||
(
|
||||
(value_end_index > item_index)
|
||||
and '/'.join(items[item_index:value_end_index]))
|
||||
or '')
|
||||
((value_end_index > item_index) and
|
||||
'/'.join(items[item_index:value_end_index])) or '')
|
||||
sepa_dict[sepa_key] = sepa_value
|
||||
return sepa_dict
|
||||
|
||||
|
||||
@@ -245,8 +245,8 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
if not clieopfile:
|
||||
# Just once: create clieop file
|
||||
our_account_owner = (
|
||||
payment_order.mode.bank_id.owner_name
|
||||
or payment_order.mode.bank_id.partner_id.name
|
||||
payment_order.mode.bank_id.owner_name or
|
||||
payment_order.mode.bank_id.partner_id.name
|
||||
)
|
||||
|
||||
if payment_order.mode.bank_id.state == 'iban':
|
||||
@@ -306,8 +306,8 @@ class banking_export_clieop_wizard(orm.TransientModel):
|
||||
)
|
||||
)
|
||||
kwargs = dict(
|
||||
name=line.bank_id.owner_name
|
||||
or line.bank_id.partner_id.name,
|
||||
name=(line.bank_id.owner_name or
|
||||
line.bank_id.partner_id.name),
|
||||
amount=line.amount_currency,
|
||||
reference=line.communication or None,
|
||||
)
|
||||
|
||||
@@ -84,10 +84,7 @@ class transaction_message(object):
|
||||
'''
|
||||
retval = super(transaction_message, self).__getattribute__(attr)
|
||||
return attr != (
|
||||
'strattrs'
|
||||
and attr in self.strattrs
|
||||
and to_swift(retval)
|
||||
or retval
|
||||
'strattrs' and attr in self.strattrs and to_swift(retval) or retval
|
||||
)
|
||||
|
||||
def genid(self):
|
||||
@@ -115,10 +112,10 @@ class transaction_message(object):
|
||||
if self.direction == 'A':
|
||||
self.transferred_amount = -float(self.transferred_amount)
|
||||
# payment batch done via clieop
|
||||
if (self.transfer_type == 'VZ'
|
||||
and (not self.remote_account or self.remote_account == '0')
|
||||
and (not self.message or re.match(r'^\s*$', self.message))
|
||||
and self.remote_owner.startswith('TOTAAL ')):
|
||||
if (self.transfer_type == 'VZ' and
|
||||
(not self.remote_account or self.remote_account == '0') and
|
||||
(not self.message or re.match(r'^\s*$', self.message)) and
|
||||
self.remote_owner.startswith('TOTAAL ')):
|
||||
self.transfer_type = 'PB'
|
||||
self.message = self.remote_owner
|
||||
self.remove_owner = False
|
||||
|
||||
@@ -153,9 +153,9 @@ class transaction(models.mem_bank_transaction):
|
||||
have their transfer_type set to 'OPN'.
|
||||
'''
|
||||
return ((
|
||||
self.transferred_amount and self.execution_date
|
||||
and self.value_date)
|
||||
and (self.remote_account or self.transfer_type in [
|
||||
self.transferred_amount and self.execution_date and
|
||||
self.value_date) and (
|
||||
self.remote_account or self.transfer_type in [
|
||||
'KST', 'PRV', 'BTL', 'BEA', 'OPN', 'KNT', 'DIV'
|
||||
] and not self.error_message))
|
||||
|
||||
|
||||
@@ -136,9 +136,9 @@ class transaction(models.mem_bank_transaction):
|
||||
self.message = ''
|
||||
# Decompose structured messages
|
||||
self.parse_message()
|
||||
if (self.transfer_type == 'OV'
|
||||
and not self.remote_account
|
||||
and not self.remote_owner):
|
||||
if (self.transfer_type == 'OV' and
|
||||
not self.remote_account and
|
||||
not self.remote_owner):
|
||||
self.transfer_type = 'KN'
|
||||
|
||||
def is_valid(self):
|
||||
|
||||
@@ -230,13 +230,13 @@ class payment_order(orm.Model):
|
||||
vals = {
|
||||
'journal_id': order.mode.transfer_journal_id.id,
|
||||
'name': '%s %s' % (labels[order.payment_order_type],
|
||||
line.move_line_id
|
||||
and line.move_line_id.move_id.name
|
||||
or line.communication),
|
||||
line.move_line_id and
|
||||
line.move_line_id.move_id.name or
|
||||
line.communication),
|
||||
'ref': '%s %s' % (order.payment_order_type[:3].upper(),
|
||||
line.move_line_id
|
||||
and line.move_line_id.move_id.name
|
||||
or line.communication),
|
||||
line.move_line_id and
|
||||
line.move_line_id.move_id.name or
|
||||
line.communication),
|
||||
}
|
||||
return vals
|
||||
|
||||
@@ -245,17 +245,17 @@ class payment_order(orm.Model):
|
||||
vals = {
|
||||
'name': _('%s for %s') % (
|
||||
labels[order.payment_order_type],
|
||||
line.move_line_id and (line.move_line_id.invoice
|
||||
and line.move_line_id.invoice.number
|
||||
or line.move_line_id.name)
|
||||
or line.communication),
|
||||
line.move_line_id and (line.move_line_id.invoice and
|
||||
line.move_line_id.invoice.number or
|
||||
line.move_line_id.name) or
|
||||
line.communication),
|
||||
'move_id': move_id,
|
||||
'partner_id': False,
|
||||
'account_id': order.mode.transfer_account_id.id,
|
||||
'credit': (order.payment_order_type == 'payment'
|
||||
and line.amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'debit'
|
||||
and line.amount or 0.0),
|
||||
'credit': (order.payment_order_type == 'payment' and
|
||||
line.amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'debit' and
|
||||
line.amount or 0.0),
|
||||
'date': fields.date.context_today(
|
||||
self, cr, uid, context=context),
|
||||
}
|
||||
@@ -265,16 +265,16 @@ class payment_order(orm.Model):
|
||||
self, cr, uid, order, line, vals, context=None):
|
||||
vals.update({
|
||||
'partner_id': line.partner_id.id,
|
||||
'account_id': (line.move_line_id
|
||||
and line.move_line_id.account_id.id
|
||||
or False),
|
||||
'account_id': (line.move_line_id and
|
||||
line.move_line_id.account_id.id or
|
||||
False),
|
||||
# if not line.move_line_id, the field 'account_id' must be set by
|
||||
# another module that inherit this function, like for example in
|
||||
# the module purchase_payment_order
|
||||
'credit': (order.payment_order_type == 'debit'
|
||||
and line.amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'payment'
|
||||
and line.amount or 0.0),
|
||||
'credit': (order.payment_order_type == 'debit' and
|
||||
line.amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'payment' and
|
||||
line.amount or 0.0),
|
||||
})
|
||||
return vals
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ class banking_import_transaction(orm.Model):
|
||||
self, cr, uid, trans, log, order_type='payment', context=None):
|
||||
|
||||
def equals_order_amount(payment_order, transferred_amount):
|
||||
if (not hasattr(payment_order, 'payment_order_type')
|
||||
or payment_order.payment_order_type == 'payment'):
|
||||
if (not hasattr(payment_order, 'payment_order_type') or
|
||||
payment_order.payment_order_type == 'payment'):
|
||||
sign = 1
|
||||
else:
|
||||
sign = -1
|
||||
@@ -137,10 +137,10 @@ class banking_import_transaction(orm.Model):
|
||||
digits = dp.get_precision('Account')(cr)[1]
|
||||
candidates = [
|
||||
line for line in payment_lines
|
||||
if (line.communication == trans.reference
|
||||
and round(line.amount, digits) == -round(
|
||||
trans.statement_line_id.amount, digits)
|
||||
and bank_match(trans.remote_account, line.bank_id))
|
||||
if (line.communication == trans.reference 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]
|
||||
@@ -303,8 +303,8 @@ class banking_import_transaction(orm.Model):
|
||||
raise orm.except_orm(
|
||||
_("Cannot cancel link with storno"),
|
||||
_("Line id not found"))
|
||||
reconcile = (cancel_line.reconcile_id
|
||||
or cancel_line.reconcile_partial_id)
|
||||
reconcile = (cancel_line.reconcile_id or
|
||||
cancel_line.reconcile_partial_id)
|
||||
lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
|
||||
if len(lines_reconcile) < 3:
|
||||
# delete the full reconciliation
|
||||
|
||||
@@ -64,8 +64,8 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
_('When matching a payment order, the amounts have to '
|
||||
'match exactly'))
|
||||
|
||||
if (payment_order.mode
|
||||
and payment_order.mode.transfer_account_id):
|
||||
if (payment_order.mode and
|
||||
payment_order.mode.transfer_account_id):
|
||||
transaction_id.statement_line_id.write({
|
||||
'account_id': (
|
||||
payment_order.mode.transfer_account_id.id),
|
||||
|
||||
@@ -124,8 +124,8 @@ class payment_line(orm.Model):
|
||||
_('Move line %s has already been reconciled') %
|
||||
torec_move_line.name
|
||||
)
|
||||
if (transit_move_line.reconcile_id
|
||||
or transit_move_line.reconcile_partial_id):
|
||||
if (transit_move_line.reconcile_id or
|
||||
transit_move_line.reconcile_partial_id):
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('Move line %s has already been reconciled') %
|
||||
@@ -147,9 +147,9 @@ class payment_line(orm.Model):
|
||||
vals = {
|
||||
'type': 'auto',
|
||||
'line_id': is_zero(total) and [(6, 0, line_ids)] or [(6, 0, [])],
|
||||
'line_partial_ids': (is_zero(total)
|
||||
and [(6, 0, [])]
|
||||
or [(6, 0, line_ids)]),
|
||||
'line_partial_ids': (is_zero(total) and
|
||||
[(6, 0, [])] or
|
||||
[(6, 0, line_ids)]),
|
||||
}
|
||||
|
||||
if torec_move_line.reconcile_partial_id:
|
||||
|
||||
@@ -38,9 +38,9 @@ class payment_mode(orm.Model):
|
||||
res = []
|
||||
payment_mode = self.browse(
|
||||
cr, uid, payment_mode_id, context)
|
||||
if (payment_mode
|
||||
and payment_mode.type
|
||||
and payment_mode.type.suitable_bank_types):
|
||||
if (payment_mode and
|
||||
payment_mode.type and
|
||||
payment_mode.type.suitable_bank_types):
|
||||
res = [t.code for t in payment_mode.type.suitable_bank_types]
|
||||
return res
|
||||
|
||||
|
||||
@@ -133,8 +133,8 @@ class payment_order_create(orm.TransientModel):
|
||||
state = 'structured'
|
||||
|
||||
# support debit orders when enabled
|
||||
if (payment.payment_order_type == 'debit'
|
||||
and 'amount_to_receive' in line):
|
||||
if (payment.payment_order_type == 'debit' and
|
||||
'amount_to_receive' in line):
|
||||
amount_currency = line.amount_to_receive
|
||||
else:
|
||||
amount_currency = line.amount_to_pay
|
||||
@@ -159,9 +159,9 @@ class payment_order_create(orm.TransientModel):
|
||||
'state': state,
|
||||
# end account banking
|
||||
'date': date_to_pay,
|
||||
'currency': (line.invoice and line.invoice.currency_id.id
|
||||
or line.journal_id.currency.id
|
||||
or line.journal_id.company_id.currency_id.id),
|
||||
'currency': (line.invoice and line.invoice.currency_id.id or
|
||||
line.journal_id.currency.id or
|
||||
line.journal_id.company_id.currency_id.id),
|
||||
}
|
||||
return res
|
||||
|
||||
|
||||
@@ -179,22 +179,22 @@ class sdd_mandate(orm.Model):
|
||||
|
||||
def _check_sdd_mandate(self, cr, uid, ids):
|
||||
for mandate in self.browse(cr, uid, ids):
|
||||
if (mandate.type == 'recurrent'
|
||||
and not mandate.recurrent_sequence_type):
|
||||
if (mandate.type == 'recurrent' and
|
||||
not mandate.recurrent_sequence_type):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("The recurrent mandate '%s' must have a sequence type.")
|
||||
% mandate.unique_mandate_reference)
|
||||
if (mandate.type == 'recurrent' and not mandate.sepa_migrated
|
||||
and mandate.recurrent_sequence_type != 'first'):
|
||||
if (mandate.type == 'recurrent' and not mandate.sepa_migrated and
|
||||
mandate.recurrent_sequence_type != 'first'):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("The recurrent mandate '%s' which is not marked as "
|
||||
"'Migrated to SEPA' must have its recurrent sequence "
|
||||
"type set to 'First'.")
|
||||
% mandate.unique_mandate_reference)
|
||||
if (mandate.type == 'recurrent' and not mandate.sepa_migrated
|
||||
and not mandate.original_mandate_identification):
|
||||
if (mandate.type == 'recurrent' and not mandate.sepa_migrated and
|
||||
not mandate.original_mandate_identification):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("You must set the 'Original Mandate Identification' "
|
||||
@@ -230,9 +230,9 @@ class sdd_mandate(orm.Model):
|
||||
last_debit_date, state):
|
||||
res = super(sdd_mandate, self).mandate_partner_bank_change(
|
||||
cr, uid, ids, partner_bank_id, last_debit_date, state)
|
||||
if (state == 'valid' and partner_bank_id
|
||||
and type == 'recurrent'
|
||||
and recurrent_sequence_type != 'first'):
|
||||
if (state == 'valid' and partner_bank_id and
|
||||
type == 'recurrent' and
|
||||
recurrent_sequence_type != 'first'):
|
||||
res['value']['recurrent_sequence_type'] = 'first'
|
||||
res['warning'] = {
|
||||
'title': _('Mandate update'),
|
||||
|
||||
@@ -104,8 +104,8 @@ class banking_export_sdd_wizard(orm.TransientModel):
|
||||
previous_payline_id = False
|
||||
for older_line in older_lines:
|
||||
older_line_date_sent = older_line.order_id.date_sent
|
||||
if (older_line_date_sent
|
||||
and older_line_date_sent > previous_date):
|
||||
if (older_line_date_sent and
|
||||
older_line_date_sent > previous_date):
|
||||
previous_date = older_line_date_sent
|
||||
previous_payline_id = older_line.id
|
||||
if previous_payline_id:
|
||||
|
||||
@@ -25,13 +25,13 @@ import logging
|
||||
|
||||
from account_banking.parsers import models
|
||||
from .mt940_parser import HSBCParser
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv import orm
|
||||
|
||||
|
||||
bt = models.mem_bank_transaction
|
||||
logger = logging.getLogger('hsbc_mt940')
|
||||
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv import orm
|
||||
|
||||
|
||||
def record2float(record, value):
|
||||
if record['creditmarker'][-1] == 'C':
|
||||
@@ -82,8 +82,8 @@ class transaction(models.mem_bank_transaction):
|
||||
'''
|
||||
We don't have remote_account so override base
|
||||
'''
|
||||
return (self.execution_date
|
||||
and self.transferred_amount and True) or False
|
||||
return (self.execution_date and
|
||||
self.transferred_amount and True) or False
|
||||
|
||||
|
||||
class statement(models.mem_bank_statement):
|
||||
|
||||
@@ -119,9 +119,9 @@ class HSBCParser(object):
|
||||
datestring = matchdict[field]
|
||||
|
||||
post_check = False
|
||||
if (len(datestring) == 4
|
||||
and field == "bookingdate"
|
||||
and "valuedate" in matchdict):
|
||||
if (len(datestring) == 4 and
|
||||
field == "bookingdate" and
|
||||
"valuedate" in matchdict):
|
||||
# Get year from valuedate
|
||||
datestring = matchdict['valuedate'].strftime('%y') + datestring
|
||||
post_check = True
|
||||
|
||||
@@ -217,8 +217,8 @@ class NorthAmericanAccount(UKAccount):
|
||||
sortcode = property(_get_sortcode, _set_sortcode)
|
||||
|
||||
def _set_bic(self, bic):
|
||||
if (not edifact_isalnum_size(bic, 8)
|
||||
and not edifact_isalnum_size(bic, 11)):
|
||||
if (not edifact_isalnum_size(bic, 8) and
|
||||
not edifact_isalnum_size(bic, 11)):
|
||||
raise ValueError("Account BIC/Swift code must be 8 or 11 "
|
||||
"characters long: %s" % ustr(bic))
|
||||
self._bic = bic
|
||||
@@ -267,8 +267,8 @@ class SWIFTAccount(UKAccount):
|
||||
sortcode = property(_get_sortcode, _set_sortcode)
|
||||
|
||||
def _set_bic(self, bic):
|
||||
if (not edifact_isalnum_size(bic, 8)
|
||||
and not edifact_isalnum_size(bic, 11)):
|
||||
if (not edifact_isalnum_size(bic, 8) and
|
||||
not edifact_isalnum_size(bic, 11)):
|
||||
raise ValueError("Account BIC/Swift code must be 8 or 11 "
|
||||
"characters long: %s" % ustr(bic))
|
||||
self._bic = bic
|
||||
|
||||
@@ -108,8 +108,8 @@ class payment_line(orm.Model):
|
||||
{'storno': True}, context=context)
|
||||
# put forth the invoice workflow
|
||||
if line.move_line_id.invoice:
|
||||
activity = (storno_retry and 'open_test'
|
||||
or 'invoice_debit_denied')
|
||||
activity = (storno_retry and 'open_test' or
|
||||
'invoice_debit_denied')
|
||||
netsvc.LocalService("workflow").trg_validate(
|
||||
uid, 'account.invoice', line.move_line_id.invoice.id,
|
||||
activity, cr)
|
||||
|
||||
@@ -45,10 +45,10 @@ class payment_order_create(orm.TransientModel):
|
||||
res = super(payment_order_create, self).default_get(
|
||||
cr, uid, fields_list, context=context)
|
||||
|
||||
if (fields_list
|
||||
and 'entries' in fields_list
|
||||
and 'entries' not in res
|
||||
and context.get('line_ids', False)):
|
||||
if (fields_list and
|
||||
'entries' in fields_list and
|
||||
'entries' not in res and
|
||||
context.get('line_ids', False)):
|
||||
res['entries'] = context['line_ids']
|
||||
|
||||
return res
|
||||
|
||||
@@ -195,8 +195,8 @@ class instant_voucher(orm.TransientModel):
|
||||
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)
|
||||
counteramount = abs(instant.voucher_id and
|
||||
instant.voucher_id.amount or 0.0)
|
||||
res[instant.id] = amount - counteramount
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user