[FIX] PEP8

This commit is contained in:
Pedro M. Baeza
2016-04-09 19:48:18 +02:00
parent e78bbcd298
commit 6d81d76e74
29 changed files with 171 additions and 179 deletions

View File

@@ -50,8 +50,8 @@ class AccountBankStatement(orm.Model):
fiscal_position = ( fiscal_position = (
st_line.partner_id.property_account_position st_line.partner_id.property_account_position
if st_line.partner_id if (st_line.partner_id and
and st_line.partner_id.property_account_position st_line.partner_id.property_account_position)
else False) else False)
tax_ids = self.pool.get('account.fiscal.position').map_tax( tax_ids = self.pool.get('account.fiscal.position').map_tax(
cr, uid, fiscal_position, [st_line.tax_id]) cr, uid, fiscal_position, [st_line.tax_id])
@@ -77,8 +77,8 @@ class AccountBankStatement(orm.Model):
move_lines.append({ move_lines.append({
'move_id': defaults['move_id'], 'move_id': defaults['move_id'],
'name': ( 'name': (
defaults.get('name', '') defaults.get('name', '') + ' ' +
+ ' ' + ustr(tax['name'] or '')), ustr(tax['name'] or '')),
'date': defaults.get('date', False), 'date': defaults.get('date', False),
'partner_id': defaults.get('partner_id', False), 'partner_id': defaults.get('partner_id', False),
'ref': defaults.get('ref', False), 'ref': defaults.get('ref', False),

View File

@@ -446,9 +446,9 @@ class account_bank_statement(orm.Model):
('account_id', '=', st_line.account_id.id)], ('account_id', '=', st_line.account_id.id)],
context=context) context=context)
account_move_line_obj.write(cr, uid, torec, { account_move_line_obj.write(cr, uid, torec, {
(st_line.reconcile_id.line_partial_ids (st_line.reconcile_id.line_partial_ids and
and 'reconcile_partial_id' 'reconcile_partial_id' or
or 'reconcile_id'): st_line.reconcile_id.id 'reconcile_id'): st_line.reconcile_id.id
}, context=context) }, context=context)
for move_line in (st_line.reconcile_id.line_id or []) + ( for move_line in (st_line.reconcile_id.line_id or []) + (
st_line.reconcile_id.line_partial_ids or []): st_line.reconcile_id.line_partial_ids or []):

View File

@@ -204,8 +204,8 @@ class banking_import_transaction(orm.Model):
iname = invoice.name.upper() iname = invoice.name.upper()
if iname in ref or iname in msg: if iname in ref or iname in msg:
return True return True
if (invoice.supplier_invoice_number if (invoice.supplier_invoice_number and
and len(invoice.supplier_invoice_number) > 2): len(invoice.supplier_invoice_number) > 2):
supp_ref = invoice.supplier_invoice_number.upper() supp_ref = invoice.supplier_invoice_number.upper()
if supp_ref in ref or supp_ref in msg: if supp_ref in ref or supp_ref in msg:
return True return True
@@ -257,8 +257,8 @@ class banking_import_transaction(orm.Model):
if x.partner_id.id in partner_ids and if x.partner_id.id in partner_ids and
(convert.str2date(x.date, '%Y-%m-%d') <= (convert.str2date(x.date, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') + (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window)) self.payment_window)) and
and (not _cached(x) or _remaining(x)) (not _cached(x) or _remaining(x))
] ]
else: else:
candidates = [] candidates = []
@@ -279,10 +279,10 @@ class banking_import_transaction(orm.Model):
if (x.invoice and has_id_match(x.invoice, ref, msg) and if (x.invoice and has_id_match(x.invoice, ref, msg) and
convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <= convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') + (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window) self.payment_window) and
and (not _cached(x) or _remaining(x)) (not _cached(x) or _remaining(x)) and
and (not partner_ids (not partner_ids or
or x.invoice.partner_id.id in partner_ids)) x.invoice.partner_id.id in partner_ids))
] ]
# Match on amount expected. Limit this kind of search to known # Match on amount expected. Limit this kind of search to known
@@ -291,12 +291,12 @@ class banking_import_transaction(orm.Model):
candidates = [ candidates = [
x for x in move_lines x for x in move_lines
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) - if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
trans.statement_line_id.amount) trans.statement_line_id.amount) and
and convert.str2date(x.date, '%Y-%m-%d') <= convert.str2date(x.date, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') + (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window) self.payment_window) and
and (not _cached(x) or _remaining(x)) (not _cached(x) or _remaining(x)) and
and x.partner_id.id in partner_ids) x.partner_id.id in partner_ids)
] ]
move_line = False move_line = False
@@ -309,8 +309,8 @@ class banking_import_transaction(orm.Model):
best = [ best = [
x for x in candidates x for x in candidates
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) - if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
trans.statement_line_id.amount) trans.statement_line_id.amount) and
and convert.str2date(x.date, '%Y-%m-%d') <= convert.str2date(x.date, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') + (convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window)) self.payment_window))
] ]
@@ -329,10 +329,10 @@ class banking_import_transaction(orm.Model):
# transfers first # transfers first
paid = [ paid = [
x for x in move_lines x for x in move_lines
if x.invoice and has_id_match(x.invoice, ref, msg) if x.invoice and has_id_match(x.invoice, ref, msg) and
and convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
<= convert.str2date(trans.execution_date, '%Y-%m-%d') convert.str2date(trans.execution_date, '%Y-%m-%d') and
and (_cached(x) and not _remaining(x)) (_cached(x) and not _remaining(x))
] ]
if paid: if paid:
log.append( log.append(
@@ -524,12 +524,10 @@ class banking_import_transaction(orm.Model):
""" """
move_line_obj = self.pool.get('account.move.line') move_line_obj = self.pool.get('account.move.line')
reconcile_obj = self.pool.get('account.move.reconcile') 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, move_lines = move_line_obj.browse(cr, uid, move_line_ids,
context=context) context=context)
reconcile = (move_lines[0].reconcile_id reconcile = (move_lines[0].reconcile_id or
or move_lines[0].reconcile_partial_id) move_lines[0].reconcile_partial_id)
line_ids = [ line_ids = [
x.id x.id
for x in reconcile.line_id or reconcile.line_partial_ids 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: for move_line_id in move_line_ids:
line_ids.remove(move_line_id) line_ids.remove(move_line_id)
if len(line_ids) > 1: 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: if full:
line_partial_ids = [] line_partial_ids = []
else: else:
@@ -633,8 +633,8 @@ class banking_import_transaction(orm.Model):
cr, uid, [st_line.voucher_id.id], context=context) cr, uid, [st_line.voucher_id.id], context=context)
voucher_pool.unlink( voucher_pool.unlink(
cr, uid, [st_line.voucher_id.id], context=context) cr, uid, [st_line.voucher_id.id], context=context)
if (transaction.move_line_id if (transaction.move_line_id and
and transaction.move_line_id.invoice): transaction.move_line_id.invoice):
# reopening the invoice # reopening the invoice
netsvc.LocalService('workflow').trg_validate( netsvc.LocalService('workflow').trg_validate(
uid, 'account.invoice', uid, 'account.invoice',
@@ -934,8 +934,8 @@ class banking_import_transaction(orm.Model):
move_lines = [] move_lines = []
# Create fallback currency code # Create fallback currency code
currency_code = (transaction.local_currency currency_code = (transaction.local_currency or
or company.currency_id.name) company.currency_id.name)
# Check cache for account info/currency # Check cache for account info/currency
if transaction.local_account in info and \ if transaction.local_account in info and \
@@ -1045,8 +1045,8 @@ class banking_import_transaction(orm.Model):
continue continue
# When bank costs are part of transaction itself, split it. # When bank costs are part of transaction itself, split it.
if (transaction.type != bt.BANK_COSTS if (transaction.type != bt.BANK_COSTS and
and transaction.provision_costs): transaction.provision_costs):
# Create new transaction for bank costs # Create new transaction for bank costs
cost_id = self.copy( cost_id = self.copy(
cr, uid, transaction.id, cr, uid, transaction.id,
@@ -1132,9 +1132,9 @@ class banking_import_transaction(orm.Model):
cr, uid, [partner_bank_id], context=context) cr, uid, [partner_bank_id], context=context)
# Credit means payment... isn't it? # Credit means payment... isn't it?
if (not move_info if (not move_info and
and transaction.statement_line_id.amount < 0 transaction.statement_line_id.amount < 0 and
and payment_lines): payment_lines):
# Link open payment - if any # Link open payment - if any
# Note that _match_payment is defined in the # Note that _match_payment is defined in the
# account_banking_payment module which should be installed # account_banking_payment module which should be installed
@@ -1192,13 +1192,11 @@ class banking_import_transaction(orm.Model):
values['type'] = move_info['type'] values['type'] = move_info['type']
else: else:
values['partner_id'] = values['partner_bank_id'] = False values['partner_id'] = values['partner_bank_id'] = False
if (not values['partner_id'] if (not values['partner_id'] and partner_ids and
and partner_ids len(partner_ids) == 1):
and len(partner_ids) == 1):
values['partner_id'] = partner_ids[0] values['partner_id'] = partner_ids[0]
if (not values['partner_bank_id'] if (not values['partner_bank_id'] and partner_banks and
and partner_banks len(partner_banks) == 1):
and len(partner_banks) == 1):
values['partner_bank_id'] = partner_banks[0].id values['partner_bank_id'] = partner_banks[0].id
statement_line_obj.write( statement_line_obj.write(
@@ -1303,14 +1301,14 @@ class banking_import_transaction(orm.Model):
transaction.move_line_id.amount_residual_currency) transaction.move_line_id.amount_residual_currency)
statement = transaction.statement_line_id.statement_id statement = transaction.statement_line_id.statement_id
to_curr_id = ( to_curr_id = (
statement.journal_id.currency statement.journal_id.currency and
and statement.journal_id.currency.id statement.journal_id.currency.id or
or statement.company_id.currency_id.id statement.company_id.currency_id.id
) )
from_curr_id = ( from_curr_id = (
transaction.move_line_id.currency_id transaction.move_line_id.currency_id and
and transaction.move_line_id.currency_id.id transaction.move_line_id.currency_id.id or
or statement.company_id.currency_id.id statement.company_id.currency_id.id
) )
if from_curr_id != to_curr_id: if from_curr_id != to_curr_id:
amount_currency = stline_pool._convert_currency( amount_currency = stline_pool._convert_currency(
@@ -1325,8 +1323,8 @@ class banking_import_transaction(orm.Model):
if transaction.move_line_id.amount_currency < 0: if transaction.move_line_id.amount_currency < 0:
sign = -1 sign = -1
else: else:
if (transaction.move_line_id.debit if (transaction.move_line_id.debit -
- transaction.move_line_id.credit) < 0: transaction.move_line_id.credit) < 0:
sign = -1 sign = -1
res[transaction.id] = sign * amount_currency res[transaction.id] = sign * amount_currency
@@ -1497,10 +1495,9 @@ class account_bank_statement_line(orm.Model):
res = {} res = {}
for line in self.browse(cr, uid, ids, context): for line in self.browse(cr, uid, ids, context):
res[line.id] = bool( res[line.id] = bool(
line.state == 'draft' line.state == 'draft' and not line.partner_id and
and not line.partner_id line.import_transaction_id and
and line.import_transaction_id line.import_transaction_id.remote_account)
and line.import_transaction_id.remote_account)
return res return res
_columns = { _columns = {
@@ -1587,8 +1584,8 @@ class account_bank_statement_line(orm.Model):
{'partner_id': statement_line.partner_bank_id.partner_id.id}) {'partner_id': statement_line.partner_bank_id.partner_id.id})
return True return True
if (not statement_line.import_transaction_id if (not statement_line.import_transaction_id or
or not statement_line.import_transaction_id.remote_account): not statement_line.import_transaction_id.remote_account):
raise orm.except_orm( raise orm.except_orm(
_("Error"), _("Error"),
_("No bank account available to link partner to")) _("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 cr, uid, this.import_transaction_id.id
) )
transaction_data['transferred_amount'] = amount transaction_data['transferred_amount'] = amount
transaction_data['message'] = ((transaction_data['message'] or '') transaction_data['message'] = (
+ _(' (split)')) (transaction_data['message'] or '') + _(' (split)'))
transaction_data['parent_id'] = this.import_transaction_id.id transaction_data['parent_id'] = this.import_transaction_id.id
transaction_id = transaction_pool.create( transaction_id = transaction_pool.create(
cr, cr,

View File

@@ -20,11 +20,11 @@
############################################################################## ##############################################################################
import unicodedata import unicodedata
from datetime import datetime
__all__ = ['str2date', 'date2str', 'date2date', 'to_swift'] __all__ = ['str2date', 'date2str', 'date2date', 'to_swift']
from datetime import datetime
def str2date(datestr, format='%d/%m/%y'): def str2date(datestr, format='%d/%m/%y'):
'''Convert a string to a datatime object''' '''Convert a string to a datatime object'''

View File

@@ -289,8 +289,8 @@ class mem_bank_transaction(object):
Heuristic check: at least id, execution_date, remote_account and Heuristic check: at least id, execution_date, remote_account and
transferred_amount should be filled to create a valid transfer. transferred_amount should be filled to create a valid transfer.
''' '''
return (self.execution_date and self.remote_account return (self.execution_date and self.remote_account and
and self.transferred_amount and True) or False self.transferred_amount and True) or False
class parser_type(type): class parser_type(type):

View File

@@ -19,6 +19,10 @@
# #
############################################################################## ##############################################################################
import unicodedata
from datetime import datetime, date
__all__ = [ __all__ = [
'Field', 'Filler', 'DateField', 'NumberField', 'RightAlignedField', 'Field', 'Filler', 'DateField', 'NumberField', 'RightAlignedField',
'RecordType', 'Record', 'asciify' 'RecordType', 'Record', 'asciify'
@@ -26,9 +30,6 @@ __all__ = [
__doc__ = '''Ease working with fixed length records in files''' __doc__ = '''Ease working with fixed length records in files'''
import unicodedata
from datetime import datetime, date
def strpdate(str, format): def strpdate(str, format):
return datetime.strptime(str, format).date() return datetime.strptime(str, format).date()

View File

@@ -327,8 +327,8 @@ class IBAN(str):
''' '''
_buffer = self[4:] + self[:4] _buffer = self[4:] + self[:4]
return ( return (
self.countrycode in self.countries self.countrycode in self.countries and
and int(base36_to_base10str(_buffer)) % 97 == 1 int(base36_to_base10str(_buffer)) % 97 == 1
) )
def __repr__(self): def __repr__(self):

View File

@@ -91,8 +91,7 @@ class link_partner(orm.TransientModel):
_('Error'), _('Error'),
_('Statement line is already linked to a bank account ')) _('Statement line is already linked to a bank account '))
if not(transaction if not (transaction and transaction.remote_account):
and transaction.remote_account):
raise orm.except_orm( raise orm.except_orm(
_('Error'), _('Error'),
_('No transaction data on statement line')) _('No transaction data on statement line'))

View File

@@ -81,8 +81,8 @@ class res_partner_bank(orm.Model):
Create dual function IBAN account for SEPA countries Create dual function IBAN account for SEPA countries
''' '''
if vals.get('state') == 'iban': if vals.get('state') == 'iban':
iban = (vals.get('acc_number') iban = (vals.get('acc_number') or
or vals.get('acc_number_domestic', False)) vals.get('acc_number_domestic', False))
vals['acc_number'], vals['acc_number_domestic'] = ( vals['acc_number'], vals['acc_number_domestic'] = (
self._correct_IBAN(iban)) self._correct_IBAN(iban))
return super(res_partner_bank, self).create( return super(res_partner_bank, self).create(

View File

@@ -44,13 +44,13 @@ class payment_line(orm.Model):
vals = {} vals = {}
partner_bank_id = vals.get('bank_id') partner_bank_id = vals.get('bank_id')
move_line_id = vals.get('move_line_id') move_line_id = vals.get('move_line_id')
if (context.get('search_payment_order_type') == 'debit' if (context.get('search_payment_order_type') == 'debit' and
and 'mandate_id' not in vals): 'mandate_id' not in vals):
if move_line_id: if move_line_id:
line = self.pool['account.move.line'].browse( line = self.pool['account.move.line'].browse(
cr, uid, move_line_id, context=context) cr, uid, move_line_id, context=context)
if (line.invoice and line.invoice.type == 'out_invoice' if (line.invoice and line.invoice.type == 'out_invoice' and
and line.invoice.mandate_id): line.invoice.mandate_id):
vals.update({ vals.update({
'mandate_id': line.invoice.mandate_id.id, 'mandate_id': line.invoice.mandate_id.id,
'bank_id': 'bank_id':
@@ -68,8 +68,8 @@ class payment_line(orm.Model):
def _check_mandate_bank_link(self, cr, uid, ids): def _check_mandate_bank_link(self, cr, uid, ids):
for payline in self.browse(cr, uid, ids): for payline in self.browse(cr, uid, ids):
if (payline.mandate_id and payline.bank_id if (payline.mandate_id and payline.bank_id and
and payline.mandate_id.partner_bank_id.id != payline.mandate_id.partner_bank_id.id !=
payline.bank_id.id): payline.bank_id.id):
raise orm.except_orm( raise orm.except_orm(
_('Error:'), _('Error:'),

View File

@@ -204,10 +204,8 @@ class transaction(models.mem_bank_transaction):
key_info = _get_next_key(items, item_index) key_info = _get_next_key(items, item_index)
value_end_index = (key_info and key_info[1]) or items_len value_end_index = (key_info and key_info[1]) or items_len
sepa_value = ( sepa_value = (
( ((value_end_index > item_index) and
(value_end_index > item_index) '/'.join(items[item_index:value_end_index])) or '')
and '/'.join(items[item_index:value_end_index]))
or '')
sepa_dict[sepa_key] = sepa_value sepa_dict[sepa_key] = sepa_value
return sepa_dict return sepa_dict

View File

@@ -114,7 +114,7 @@ class banking_export_clieop_wizard(orm.TransientModel):
), ),
'no_transactions': fields.related( 'no_transactions': fields.related(
'file_id', 'no_transactions', 'file_id', 'no_transactions',
type ='integer', type='integer',
string='Number of Transactions', string='Number of Transactions',
readonly=True, readonly=True,
), ),
@@ -245,8 +245,8 @@ class banking_export_clieop_wizard(orm.TransientModel):
if not clieopfile: if not clieopfile:
# Just once: create clieop file # Just once: create clieop file
our_account_owner = ( our_account_owner = (
payment_order.mode.bank_id.owner_name payment_order.mode.bank_id.owner_name or
or payment_order.mode.bank_id.partner_id.name payment_order.mode.bank_id.partner_id.name
) )
if payment_order.mode.bank_id.state == 'iban': if payment_order.mode.bank_id.state == 'iban':
@@ -306,8 +306,8 @@ class banking_export_clieop_wizard(orm.TransientModel):
) )
) )
kwargs = dict( kwargs = dict(
name=line.bank_id.owner_name name=(line.bank_id.owner_name or
or line.bank_id.partner_id.name, line.bank_id.partner_id.name),
amount=line.amount_currency, amount=line.amount_currency,
reference=line.communication or None, reference=line.communication or None,
) )

View File

@@ -84,10 +84,7 @@ class transaction_message(object):
''' '''
retval = super(transaction_message, self).__getattribute__(attr) retval = super(transaction_message, self).__getattribute__(attr)
return attr != ( return attr != (
'strattrs' 'strattrs' and attr in self.strattrs and to_swift(retval) or retval
and attr in self.strattrs
and to_swift(retval)
or retval
) )
def genid(self): def genid(self):
@@ -115,10 +112,10 @@ class transaction_message(object):
if self.direction == 'A': if self.direction == 'A':
self.transferred_amount = -float(self.transferred_amount) self.transferred_amount = -float(self.transferred_amount)
# payment batch done via clieop # payment batch done via clieop
if (self.transfer_type == 'VZ' if (self.transfer_type == 'VZ' and
and (not self.remote_account or self.remote_account == '0') (not self.remote_account or self.remote_account == '0') and
and (not self.message or re.match(r'^\s*$', self.message)) (not self.message or re.match(r'^\s*$', self.message)) and
and self.remote_owner.startswith('TOTAAL ')): self.remote_owner.startswith('TOTAAL ')):
self.transfer_type = 'PB' self.transfer_type = 'PB'
self.message = self.remote_owner self.message = self.remote_owner
self.remove_owner = False self.remove_owner = False

View File

@@ -153,9 +153,9 @@ class transaction(models.mem_bank_transaction):
have their transfer_type set to 'OPN'. have their transfer_type set to 'OPN'.
''' '''
return (( return ((
self.transferred_amount and self.execution_date self.transferred_amount and self.execution_date and
and self.value_date) self.value_date) and (
and (self.remote_account or self.transfer_type in [ self.remote_account or self.transfer_type in [
'KST', 'PRV', 'BTL', 'BEA', 'OPN', 'KNT', 'DIV' 'KST', 'PRV', 'BTL', 'BEA', 'OPN', 'KNT', 'DIV'
] and not self.error_message)) ] and not self.error_message))

View File

@@ -136,9 +136,9 @@ class transaction(models.mem_bank_transaction):
self.message = '' self.message = ''
# Decompose structured messages # Decompose structured messages
self.parse_message() self.parse_message()
if (self.transfer_type == 'OV' if (self.transfer_type == 'OV' and
and not self.remote_account not self.remote_account and
and not self.remote_owner): not self.remote_owner):
self.transfer_type = 'KN' self.transfer_type = 'KN'
def is_valid(self): def is_valid(self):

View File

@@ -230,13 +230,13 @@ class payment_order(orm.Model):
vals = { vals = {
'journal_id': order.mode.transfer_journal_id.id, 'journal_id': order.mode.transfer_journal_id.id,
'name': '%s %s' % (labels[order.payment_order_type], 'name': '%s %s' % (labels[order.payment_order_type],
line.move_line_id line.move_line_id and
and line.move_line_id.move_id.name line.move_line_id.move_id.name or
or line.communication), line.communication),
'ref': '%s %s' % (order.payment_order_type[:3].upper(), 'ref': '%s %s' % (order.payment_order_type[:3].upper(),
line.move_line_id line.move_line_id and
and line.move_line_id.move_id.name line.move_line_id.move_id.name or
or line.communication), line.communication),
} }
return vals return vals
@@ -245,17 +245,17 @@ class payment_order(orm.Model):
vals = { vals = {
'name': _('%s for %s') % ( 'name': _('%s for %s') % (
labels[order.payment_order_type], labels[order.payment_order_type],
line.move_line_id and (line.move_line_id.invoice line.move_line_id and (line.move_line_id.invoice and
and line.move_line_id.invoice.number line.move_line_id.invoice.number or
or line.move_line_id.name) line.move_line_id.name) or
or line.communication), line.communication),
'move_id': move_id, 'move_id': move_id,
'partner_id': False, 'partner_id': False,
'account_id': order.mode.transfer_account_id.id, 'account_id': order.mode.transfer_account_id.id,
'credit': (order.payment_order_type == 'payment' 'credit': (order.payment_order_type == 'payment' and
and line.amount or 0.0), line.amount or 0.0),
'debit': (order.payment_order_type == 'debit' 'debit': (order.payment_order_type == 'debit' and
and line.amount or 0.0), line.amount or 0.0),
'date': fields.date.context_today( 'date': fields.date.context_today(
self, cr, uid, context=context), self, cr, uid, context=context),
} }
@@ -265,16 +265,16 @@ class payment_order(orm.Model):
self, cr, uid, order, line, vals, context=None): self, cr, uid, order, line, vals, context=None):
vals.update({ vals.update({
'partner_id': line.partner_id.id, 'partner_id': line.partner_id.id,
'account_id': (line.move_line_id 'account_id': (line.move_line_id and
and line.move_line_id.account_id.id line.move_line_id.account_id.id or
or False), False),
# if not line.move_line_id, the field 'account_id' must be set by # if not line.move_line_id, the field 'account_id' must be set by
# another module that inherit this function, like for example in # another module that inherit this function, like for example in
# the module purchase_payment_order # the module purchase_payment_order
'credit': (order.payment_order_type == 'debit' 'credit': (order.payment_order_type == 'debit' and
and line.amount or 0.0), line.amount or 0.0),
'debit': (order.payment_order_type == 'payment' 'debit': (order.payment_order_type == 'payment' and
and line.amount or 0.0), line.amount or 0.0),
}) })
return vals return vals

View File

@@ -39,8 +39,8 @@ class banking_import_transaction(orm.Model):
self, cr, uid, trans, log, order_type='payment', context=None): self, cr, uid, trans, log, order_type='payment', context=None):
def equals_order_amount(payment_order, transferred_amount): def equals_order_amount(payment_order, transferred_amount):
if (not hasattr(payment_order, 'payment_order_type') if (not hasattr(payment_order, 'payment_order_type') or
or payment_order.payment_order_type == 'payment'): payment_order.payment_order_type == 'payment'):
sign = 1 sign = 1
else: else:
sign = -1 sign = -1
@@ -137,10 +137,10 @@ class banking_import_transaction(orm.Model):
digits = dp.get_precision('Account')(cr)[1] digits = dp.get_precision('Account')(cr)[1]
candidates = [ candidates = [
line for line in payment_lines line for line in payment_lines
if (line.communication == trans.reference if (line.communication == trans.reference and
and round(line.amount, digits) == -round( round(line.amount, digits) == -round(
trans.statement_line_id.amount, digits) trans.statement_line_id.amount, digits) and
and bank_match(trans.remote_account, line.bank_id)) bank_match(trans.remote_account, line.bank_id))
] ]
if len(candidates) == 1: if len(candidates) == 1:
candidate = candidates[0] candidate = candidates[0]
@@ -303,8 +303,8 @@ class banking_import_transaction(orm.Model):
raise orm.except_orm( raise orm.except_orm(
_("Cannot cancel link with storno"), _("Cannot cancel link with storno"),
_("Line id not found")) _("Line id not found"))
reconcile = (cancel_line.reconcile_id reconcile = (cancel_line.reconcile_id or
or cancel_line.reconcile_partial_id) cancel_line.reconcile_partial_id)
lines_reconcile = reconcile.line_id or reconcile.line_partial_ids lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
if len(lines_reconcile) < 3: if len(lines_reconcile) < 3:
# delete the full reconciliation # delete the full reconciliation

View File

@@ -64,8 +64,8 @@ class banking_transaction_wizard(orm.TransientModel):
_('When matching a payment order, the amounts have to ' _('When matching a payment order, the amounts have to '
'match exactly')) 'match exactly'))
if (payment_order.mode if (payment_order.mode and
and payment_order.mode.transfer_account_id): payment_order.mode.transfer_account_id):
transaction_id.statement_line_id.write({ transaction_id.statement_line_id.write({
'account_id': ( 'account_id': (
payment_order.mode.transfer_account_id.id), payment_order.mode.transfer_account_id.id),

View File

@@ -124,8 +124,8 @@ class payment_line(orm.Model):
_('Move line %s has already been reconciled') % _('Move line %s has already been reconciled') %
torec_move_line.name torec_move_line.name
) )
if (transit_move_line.reconcile_id if (transit_move_line.reconcile_id or
or transit_move_line.reconcile_partial_id): transit_move_line.reconcile_partial_id):
raise orm.except_orm( raise orm.except_orm(
_('Error'), _('Error'),
_('Move line %s has already been reconciled') % _('Move line %s has already been reconciled') %
@@ -147,9 +147,9 @@ class payment_line(orm.Model):
vals = { vals = {
'type': 'auto', 'type': 'auto',
'line_id': is_zero(total) and [(6, 0, line_ids)] or [(6, 0, [])], 'line_id': is_zero(total) and [(6, 0, line_ids)] or [(6, 0, [])],
'line_partial_ids': (is_zero(total) 'line_partial_ids': (is_zero(total) and
and [(6, 0, [])] [(6, 0, [])] or
or [(6, 0, line_ids)]), [(6, 0, line_ids)]),
} }
if torec_move_line.reconcile_partial_id: if torec_move_line.reconcile_partial_id:

View File

@@ -38,9 +38,9 @@ class payment_mode(orm.Model):
res = [] res = []
payment_mode = self.browse( payment_mode = self.browse(
cr, uid, payment_mode_id, context) cr, uid, payment_mode_id, context)
if (payment_mode if (payment_mode and
and payment_mode.type payment_mode.type and
and payment_mode.type.suitable_bank_types): payment_mode.type.suitable_bank_types):
res = [t.code for t in payment_mode.type.suitable_bank_types] res = [t.code for t in payment_mode.type.suitable_bank_types]
return res return res

View File

@@ -133,8 +133,8 @@ class payment_order_create(orm.TransientModel):
state = 'structured' state = 'structured'
# support debit orders when enabled # support debit orders when enabled
if (payment.payment_order_type == 'debit' if (payment.payment_order_type == 'debit' and
and 'amount_to_receive' in line): 'amount_to_receive' in line):
amount_currency = line.amount_to_receive amount_currency = line.amount_to_receive
else: else:
amount_currency = line.amount_to_pay amount_currency = line.amount_to_pay
@@ -159,9 +159,9 @@ class payment_order_create(orm.TransientModel):
'state': state, 'state': state,
# end account banking # end account banking
'date': date_to_pay, 'date': date_to_pay,
'currency': (line.invoice and line.invoice.currency_id.id 'currency': (line.invoice and line.invoice.currency_id.id or
or line.journal_id.currency.id line.journal_id.currency.id or
or line.journal_id.company_id.currency_id.id), line.journal_id.company_id.currency_id.id),
} }
return res return res

View File

@@ -179,22 +179,22 @@ class sdd_mandate(orm.Model):
def _check_sdd_mandate(self, cr, uid, ids): def _check_sdd_mandate(self, cr, uid, ids):
for mandate in self.browse(cr, uid, ids): for mandate in self.browse(cr, uid, ids):
if (mandate.type == 'recurrent' if (mandate.type == 'recurrent' and
and not mandate.recurrent_sequence_type): not mandate.recurrent_sequence_type):
raise orm.except_orm( raise orm.except_orm(
_('Error:'), _('Error:'),
_("The recurrent mandate '%s' must have a sequence type.") _("The recurrent mandate '%s' must have a sequence type.")
% mandate.unique_mandate_reference) % mandate.unique_mandate_reference)
if (mandate.type == 'recurrent' and not mandate.sepa_migrated if (mandate.type == 'recurrent' and not mandate.sepa_migrated and
and mandate.recurrent_sequence_type != 'first'): mandate.recurrent_sequence_type != 'first'):
raise orm.except_orm( raise orm.except_orm(
_('Error:'), _('Error:'),
_("The recurrent mandate '%s' which is not marked as " _("The recurrent mandate '%s' which is not marked as "
"'Migrated to SEPA' must have its recurrent sequence " "'Migrated to SEPA' must have its recurrent sequence "
"type set to 'First'.") "type set to 'First'.")
% mandate.unique_mandate_reference) % mandate.unique_mandate_reference)
if (mandate.type == 'recurrent' and not mandate.sepa_migrated if (mandate.type == 'recurrent' and not mandate.sepa_migrated and
and not mandate.original_mandate_identification): not mandate.original_mandate_identification):
raise orm.except_orm( raise orm.except_orm(
_('Error:'), _('Error:'),
_("You must set the 'Original Mandate Identification' " _("You must set the 'Original Mandate Identification' "
@@ -230,9 +230,9 @@ class sdd_mandate(orm.Model):
last_debit_date, state): last_debit_date, state):
res = super(sdd_mandate, self).mandate_partner_bank_change( res = super(sdd_mandate, self).mandate_partner_bank_change(
cr, uid, ids, partner_bank_id, last_debit_date, state) cr, uid, ids, partner_bank_id, last_debit_date, state)
if (state == 'valid' and partner_bank_id if (state == 'valid' and partner_bank_id and
and type == 'recurrent' type == 'recurrent' and
and recurrent_sequence_type != 'first'): recurrent_sequence_type != 'first'):
res['value']['recurrent_sequence_type'] = 'first' res['value']['recurrent_sequence_type'] = 'first'
res['warning'] = { res['warning'] = {
'title': _('Mandate update'), 'title': _('Mandate update'),

View File

@@ -104,8 +104,8 @@ class banking_export_sdd_wizard(orm.TransientModel):
previous_payline_id = False previous_payline_id = False
for older_line in older_lines: for older_line in older_lines:
older_line_date_sent = older_line.order_id.date_sent older_line_date_sent = older_line.order_id.date_sent
if (older_line_date_sent if (older_line_date_sent and
and older_line_date_sent > previous_date): older_line_date_sent > previous_date):
previous_date = older_line_date_sent previous_date = older_line_date_sent
previous_payline_id = older_line.id previous_payline_id = older_line.id
if previous_payline_id: if previous_payline_id:

View File

@@ -25,13 +25,13 @@ import logging
from account_banking.parsers import models from account_banking.parsers import models
from .mt940_parser import HSBCParser from .mt940_parser import HSBCParser
from openerp.tools.translate import _
from openerp.osv import orm
bt = models.mem_bank_transaction bt = models.mem_bank_transaction
logger = logging.getLogger('hsbc_mt940') logger = logging.getLogger('hsbc_mt940')
from openerp.tools.translate import _
from openerp.osv import orm
def record2float(record, value): def record2float(record, value):
if record['creditmarker'][-1] == 'C': if record['creditmarker'][-1] == 'C':
@@ -82,8 +82,8 @@ class transaction(models.mem_bank_transaction):
''' '''
We don't have remote_account so override base We don't have remote_account so override base
''' '''
return (self.execution_date return (self.execution_date and
and self.transferred_amount and True) or False self.transferred_amount and True) or False
class statement(models.mem_bank_statement): class statement(models.mem_bank_statement):

View File

@@ -119,9 +119,9 @@ class HSBCParser(object):
datestring = matchdict[field] datestring = matchdict[field]
post_check = False post_check = False
if (len(datestring) == 4 if (len(datestring) == 4 and
and field == "bookingdate" field == "bookingdate" and
and "valuedate" in matchdict): "valuedate" in matchdict):
# Get year from valuedate # Get year from valuedate
datestring = matchdict['valuedate'].strftime('%y') + datestring datestring = matchdict['valuedate'].strftime('%y') + datestring
post_check = True post_check = True

View File

@@ -217,8 +217,8 @@ class NorthAmericanAccount(UKAccount):
sortcode = property(_get_sortcode, _set_sortcode) sortcode = property(_get_sortcode, _set_sortcode)
def _set_bic(self, bic): def _set_bic(self, bic):
if (not edifact_isalnum_size(bic, 8) if (not edifact_isalnum_size(bic, 8) and
and not edifact_isalnum_size(bic, 11)): not edifact_isalnum_size(bic, 11)):
raise ValueError("Account BIC/Swift code must be 8 or 11 " raise ValueError("Account BIC/Swift code must be 8 or 11 "
"characters long: %s" % ustr(bic)) "characters long: %s" % ustr(bic))
self._bic = bic self._bic = bic
@@ -267,8 +267,8 @@ class SWIFTAccount(UKAccount):
sortcode = property(_get_sortcode, _set_sortcode) sortcode = property(_get_sortcode, _set_sortcode)
def _set_bic(self, bic): def _set_bic(self, bic):
if (not edifact_isalnum_size(bic, 8) if (not edifact_isalnum_size(bic, 8) and
and not edifact_isalnum_size(bic, 11)): not edifact_isalnum_size(bic, 11)):
raise ValueError("Account BIC/Swift code must be 8 or 11 " raise ValueError("Account BIC/Swift code must be 8 or 11 "
"characters long: %s" % ustr(bic)) "characters long: %s" % ustr(bic))
self._bic = bic self._bic = bic

View File

@@ -108,8 +108,8 @@ class payment_line(orm.Model):
{'storno': True}, context=context) {'storno': True}, context=context)
# put forth the invoice workflow # put forth the invoice workflow
if line.move_line_id.invoice: if line.move_line_id.invoice:
activity = (storno_retry and 'open_test' activity = (storno_retry and 'open_test' or
or 'invoice_debit_denied') 'invoice_debit_denied')
netsvc.LocalService("workflow").trg_validate( netsvc.LocalService("workflow").trg_validate(
uid, 'account.invoice', line.move_line_id.invoice.id, uid, 'account.invoice', line.move_line_id.invoice.id,
activity, cr) activity, cr)

View File

@@ -45,10 +45,10 @@ class payment_order_create(orm.TransientModel):
res = super(payment_order_create, self).default_get( res = super(payment_order_create, self).default_get(
cr, uid, fields_list, context=context) cr, uid, fields_list, context=context)
if (fields_list if (fields_list and
and 'entries' in fields_list 'entries' in fields_list and
and 'entries' not in res 'entries' not in res and
and context.get('line_ids', False)): context.get('line_ids', False)):
res['entries'] = context['line_ids'] res['entries'] = context['line_ids']
return res return res

View File

@@ -195,8 +195,8 @@ class instant_voucher(orm.TransientModel):
counteramount = line.debit - line.credit counteramount = line.debit - line.credit
else: else:
amount = abs(instant.statement_line_id.amount) amount = abs(instant.statement_line_id.amount)
counteramount = abs(instant.voucher_id counteramount = abs(instant.voucher_id and
and instant.voucher_id.amount or 0.0) instant.voucher_id.amount or 0.0)
res[instant.id] = amount - counteramount res[instant.id] = amount - counteramount
return res return res