[FIX] Uncaught flake8 errors

This commit is contained in:
Pedro M. Baeza
2014-10-21 09:51:40 +02:00
parent 2a4bf7d859
commit 10757d8ab4
12 changed files with 107 additions and 131 deletions

View File

@@ -31,7 +31,7 @@
'depends': ['account_banking_payment_export'],
'external_dependencies': {
'python': ['unidecode', 'lxml'],
},
},
'data': [
'views/payment_line_view.xml',
'views/payment_mode_view.xml',

View File

@@ -37,8 +37,8 @@ class BankingExportPain(orm.AbstractModel):
_name = 'banking.export.pain'
def _validate_iban(self, cr, uid, iban, context=None):
'''if IBAN is valid, returns IBAN
if IBAN is NOT valid, raises an error message'''
"""if IBAN is valid, returns IBAN
if IBAN is NOT valid, raises an error message"""
partner_bank_obj = self.pool.get('res.partner.bank')
if partner_bank_obj.is_iban_valid(cr, uid, iban, context=context):
return iban.replace(' ', '')
@@ -162,7 +162,7 @@ class BankingExportPain(orm.AbstractModel):
'res_model': self._name,
'res_id': ids[0],
'target': 'new',
}
}
return action
def generate_group_header_block(
@@ -283,8 +283,8 @@ class BankingExportPain(orm.AbstractModel):
def generate_party_agent(
self, cr, uid, parent_node, party_type, party_type_label,
order, party_name, iban, bic, eval_ctx, gen_args, context=None):
'''Generate the piece of the XML file corresponding to BIC
This code is mutualized between TRF and DD'''
"""Generate the piece of the XML file corresponding to BIC
This code is mutualized between TRF and DD"""
assert order in ('B', 'C'), "Order can be 'B' or 'C'"
try:
bic = self._prepare_field(
@@ -324,8 +324,8 @@ class BankingExportPain(orm.AbstractModel):
def generate_party_block(
self, cr, uid, parent_node, party_type, order, name, iban, bic,
eval_ctx, gen_args, context=None):
'''Generate the piece of the XML file corresponding to Name+IBAN+BIC
This code is mutualized between TRF and DD'''
"""Generate the piece of the XML file corresponding to Name+IBAN+BIC
This code is mutualized between TRF and DD"""
assert order in ('B', 'C'), "Order can be 'B' or 'C'"
if party_type == 'Cdtr':
party_type_label = 'Creditor'
@@ -385,7 +385,7 @@ class BankingExportPain(orm.AbstractModel):
_('Error:'),
_("Missing 'Structured Communication Type' on payment "
"line with reference '%s'.")
% (line.name))
% line.name)
remittance_info_structured_2_100 = etree.SubElement(
remittance_info_2_91, 'Strd')
creditor_ref_information_2_120 = etree.SubElement(
@@ -425,9 +425,8 @@ class BankingExportPain(orm.AbstractModel):
def generate_creditor_scheme_identification(
self, cr, uid, parent_node, identification, identification_label,
eval_ctx, scheme_name_proprietary, gen_args, context=None):
csi_id = etree.SubElement(
parent_node, 'Id')
csi_privateid = csi_id = etree.SubElement(csi_id, 'PrvtId')
csi_id = etree.SubElement(parent_node, 'Id')
csi_privateid = etree.SubElement(csi_id, 'PrvtId')
csi_other = etree.SubElement(csi_privateid, 'Othr')
csi_other_id = etree.SubElement(csi_other, 'Id')
csi_other_id.text = self._prepare_field(

View File

@@ -23,19 +23,18 @@
from openerp.osv import orm, fields
class payment_line(orm.Model):
class PaymentLine(orm.Model):
_inherit = 'payment.line'
def _get_struct_communication_types(self, cr, uid, context=None):
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."),
"the generated PAIN file."),
# Update size from 64 to 140, because PAIN allows 140 caracters
'communication': fields.char(
'Communication', size=140, required=True,

View File

@@ -34,7 +34,7 @@
'depends': [
'account_payment',
'base_iban', # for manual_bank_tranfer
],
],
'conflicts': [
# lp:account-payment/account_payment_extension also adds
# a type field to payment.mode, with a very similar purpose.
@@ -44,7 +44,7 @@
# Proposal to resolve: make account_payment_extension depend
# on the present account_banking_payment_export module.
'account_payment_extension',
],
],
'data': [
'view/account_payment.xml',
'view/payment_mode.xml',

View File

@@ -38,7 +38,7 @@ class PaymentOrderCreate(models.TransientModel):
context = self.env.context
if ('entries' in fields and context.get('line_ids') and
context.get('populate_results')):
res.update({'entries': context['line_ids']})
res.update({'entries': context['line_ids']})
return res
@api.model

View File

@@ -31,7 +31,7 @@
'depends': ['account_banking_pain_base'],
'external_dependencies': {
'python': ['unidecode', 'lxml'],
},
},
'data': [
'views/account_banking_sepa_view.xml',
'wizard/export_sepa_view.xml',

View File

@@ -27,36 +27,35 @@ from openerp import workflow
from lxml import etree
class banking_export_sepa_wizard(orm.TransientModel):
class BankingExportSepaWizard(orm.TransientModel):
_name = 'banking.export.sepa.wizard'
_inherit = ['banking.export.pain']
_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 "
"charges on the debtor side are to be borne by the debtor, "
"transaction charges on the creditor side are to be borne by "
"the creditor. Borne by creditor : all transaction charges are "
"to be borne by the creditor. Borne by debtor : all transaction "
"charges are to be borne by the debtor."),
"applied following the rules agreed in the service level "
"and/or scheme (SEPA Core messages must use this). Shared : "
"transaction charges on the debtor side are to be borne by "
"the debtor, transaction charges on the creditor side are to "
"be borne by the creditor. Borne by creditor : all "
"transaction charges are to be borne by the creditor. Borne "
"by debtor : all transaction charges are to be borne by the "
"debtor."),
'nb_transactions': fields.related(
'file_id', 'nb_transactions', type='integer',
string='Number of Transactions', readonly=True),
@@ -73,19 +72,19 @@ 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', [])
vals.update({
'payment_order_ids': [[6, 0, payment_order_ids]],
})
return super(banking_export_sepa_wizard, self).create(
return super(BankingExportSepaWizard, self).create(
cr, uid, vals, context=context)
def create_sepa(self, cr, uid, ids, context=None):
@@ -143,7 +142,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)
pain_03_to_05 = \

View File

@@ -62,7 +62,7 @@ class ResCompany(models.Model):
after_replacement = ''
for char in before_replacement:
if char.isalpha():
after_replacement += str(ord(char)-87)
after_replacement += str(ord(char) - 87)
else:
after_replacement += char
logger.debug(

View File

@@ -28,35 +28,34 @@ from datetime import datetime
from lxml import etree
class banking_export_sdd_wizard(orm.TransientModel):
class BankingExportSddWizard(orm.TransientModel):
_name = 'banking.export.sdd.wizard'
_inherit = ['banking.export.pain']
_description = 'Export SEPA Direct Debit 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 credit "
"line for all the direct debits of the SEPA file ; if false, "
"the bank statement will display one credit line per direct "
"debit of the SEPA 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 "
"charges on the creditor side are to be borne by the creditor, "
"transaction charges on the debtor side are to be borne by the "
"debtor. Borne by creditor : all transaction charges are to be "
"borne by the creditor. Borne by debtor : all transaction "
"charges are to be borne by the debtor."),
"applied following the rules agreed in the service level "
"and/or scheme (SEPA Core messages must use this). Shared : "
"transaction charges on the creditor side are to be borne "
"by the creditor, transaction charges on the debtor side are "
"to be borne by the debtor. Borne by creditor : all "
"transaction charges are to be borne by the creditor. Borne "
"by debtor : all transaction charges are to be borne by the "
"debtor."),
'nb_transactions': fields.related(
'file_id', 'nb_transactions', type='integer',
string='Number of Transactions', readonly=True),
@@ -73,19 +72,19 @@ class banking_export_sdd_wizard(orm.TransientModel):
'payment_order_ids': fields.many2many(
'payment.order', 'wiz_sdd_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', [])
vals.update({
'payment_order_ids': [[6, 0, payment_order_ids]],
})
return super(banking_export_sdd_wizard, self).create(
return super(BankingExportSddWizard, self).create(
cr, uid, vals, context=context)
def _get_previous_bank(self, cr, uid, payline, context=None):
@@ -115,9 +114,7 @@ class banking_export_sdd_wizard(orm.TransientModel):
return previous_bank
def create_sepa(self, cr, uid, ids, context=None):
'''
Creates the SEPA Direct Debit file. That's the important code !
'''
"""Creates the SEPA Direct Debit file. That's the important code !"""
sepa_export = self.browse(cr, uid, ids[0], context=context)
pain_flavor = sepa_export.payment_order_ids[0].mode.type.code
@@ -139,10 +136,9 @@ class banking_export_sdd_wizard(orm.TransientModel):
raise orm.except_orm(
_('Error:'),
_("Payment Type Code '%s' is not supported. The only "
"Payment Type Code supported for SEPA Direct Debit "
"are 'pain.008.001.02', 'pain.008.001.03' and "
"'pain.008.001.04'.") % pain_flavor)
"Payment Type Code supported for SEPA Direct Debit are "
"'pain.008.001.02', 'pain.008.001.03' and "
"'pain.008.001.04'.") % pain_flavor)
gen_args = {
'bic_xml_tag': bic_xml_tag,
'name_maxsize': name_maxsize,
@@ -154,20 +150,16 @@ class banking_export_sdd_wizard(orm.TransientModel):
'pain_xsd_file':
'account_banking_sepa_direct_debit/data/%s.xsd' % pain_flavor,
}
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)
# A. Group header
group_header_1_0, nb_of_transactions_1_6, control_sum_1_7 = \
self.generate_group_header_block(
cr, uid, pain_root, gen_args, context=context)
transactions_count_1_6 = 0
total_amount = 0.0
amount_control_sum_1_7 = 0.0
@@ -192,36 +184,35 @@ class banking_export_sdd_wizard(orm.TransientModel):
raise orm.except_orm(
_('Error:'),
_("Missing SEPA Direct Debit mandate on the payment "
"line with partner '%s' and Invoice ref '%s'.")
"line with partner '%s' and Invoice ref '%s'.")
% (line.partner_id.name,
line.ml_inv_ref.number))
line.ml_inv_ref.number))
scheme = line.mandate_id.scheme
if line.mandate_id.state != 'valid':
raise orm.except_orm(
_('Error:'),
_("The SEPA Direct Debit mandate with reference '%s' "
"for partner '%s' has expired.")
"for partner '%s' has expired.")
% (line.mandate_id.unique_mandate_reference,
line.mandate_id.partner_id.name))
line.mandate_id.partner_id.name))
if line.mandate_id.type == 'oneoff':
if not line.mandate_id.last_debit_date:
seq_type = 'OOFF'
else:
seq_type = 'OOFF'
if line.mandate_id.last_debit_date:
raise orm.except_orm(
_('Error:'),
_("The mandate with reference '%s' for partner "
"'%s' has type set to 'One-Off' and it has a "
"last debit date set to '%s', so we can't use "
"it.")
"'%s' has type set to 'One-Off' and it has a "
"last debit date set to '%s', so we can't use "
"it.")
% (line.mandate_id.unique_mandate_reference,
line.mandate_id.partner_id.name,
line.mandate_id.last_debit_date))
line.mandate_id.partner_id.name,
line.mandate_id.last_debit_date))
elif line.mandate_id.type == 'recurrent':
seq_type_map = {
'recurring': 'RCUR',
'first': 'FRST',
'final': 'FNAL',
}
}
seq_type_label = \
line.mandate_id.recurrent_sequence_type
assert seq_type_label is not False
@@ -261,10 +252,8 @@ class banking_export_sdd_wizard(orm.TransientModel):
'sepa_export.payment_order_ids[0].mode.bank_id.bank.bic',
{'sepa_export': sepa_export},
gen_args, context=context)
charge_bearer_2_24 = etree.SubElement(payment_info_2_0, 'ChrgBr')
charge_bearer_2_24.text = sepa_export.charge_bearer
creditor_scheme_identification_2_27 = etree.SubElement(
payment_info_2_0, 'CdtrSchmeId')
self.generate_creditor_scheme_identification(
@@ -273,7 +262,6 @@ class banking_export_sdd_wizard(orm.TransientModel):
'sepa_creditor_identifier',
'SEPA Creditor Identifier', {'sepa_export': sepa_export},
'SEPA', gen_args, context=context)
transactions_count_2_4 = 0
amount_control_sum_2_5 = 0.0
for line in lines:
@@ -404,20 +392,17 @@ class banking_export_sdd_wizard(orm.TransientModel):
gen_args, context=context)
def cancel_sepa(self, cr, uid, ids, context=None):
'''
Cancel the SEPA file: just drop the file
'''
"""Cancel the SEPA file: just drop the file"""
sepa_export = self.browse(cr, uid, ids[0], context=context)
self.pool.get('banking.export.sdd').unlink(
cr, uid, sepa_export.file_id.id, context=context)
return {'type': 'ir.actions.act_window_close'}
def save_sepa(self, cr, uid, ids, context=None):
'''
Save the SEPA Direct Debit file: mark all payments in the file
"""Save the SEPA Direct Debit file: mark all payments in the file
as 'sent'. Write 'last debit date' on mandate and set oneoff
mandate to expired
'''
mandate to expired.
"""
sepa_export = self.browse(cr, uid, ids[0], context=context)
self.pool.get('banking.export.sdd').write(
cr, uid, sepa_export.file_id.id, {'state': 'sent'},

View File

@@ -80,7 +80,6 @@ class AccountMoveLine(orm.Model):
AND reconcile_id IS null
AND debit > 0
AND ''' + where + ' and ' + query), ('receivable',) + sql_args)
res = cr.fetchall()
if not res:
return [('id', '=', '0')]
@@ -118,4 +117,4 @@ class AccountMoveLine(orm.Model):
_amount_to_receive, method=True,
type='float', string='Amount to receive',
fnct_search=_to_receive_search),
}
}

View File

@@ -48,10 +48,9 @@ class PaymentLine(orm.Model):
if len(reconcile.line_partial_ids) == 2:
# reuse the simple reconcile for the storno transfer
reconcile_obj.write(
cr, uid, reconcile_id, {
'line_id': [(6, 0, line.transit_move_line_id.id)],
'line_partial_ids': [(6, 0, [])],
}, context=context)
cr, uid, reconcile_id,
{'line_id': [(6, 0, line.transit_move_line_id.id)],
'line_partial_ids': [(6, 0, [])]}, context=context)
else:
# split up the original reconcile in a partial one
# and a new one for reconciling the storno transfer
@@ -61,36 +60,33 @@ class PaymentLine(orm.Model):
reconcile_obj.write(
cr, uid, reconcile_id, reconcile, context=context)
reconcile_id = reconcile_obj.create(
cr, uid, {
'type': 'auto',
'line_id': [(6, 0, line.transit_move_line_id.id)],
}, context=context)
cr, uid,
{'type': 'auto',
'line_id': [(6, 0, line.transit_move_line_id.id)]},
context=context)
elif line.transit_move_line_id.reconcile_id:
reconcile_id = line.transit_move_line_id.reconcile_id.id
if len(line.transit_move_line_id.reconcile_id.line_id) == 2:
# reuse the simple reconcile for the storno transfer
reconcile_obj.write(
cr, uid, reconcile_id, {
'line_id': [(6, 0, [line.transit_move_line_id.id])]
}, context=context)
cr, uid, reconcile_id,
{'line_id': [(6, 0, [line.transit_move_line_id.id])]},
context=context)
else:
# split up the original reconcile in a partial one
# and a new one for reconciling the storno transfer
reconcile = line.transit_move_line_id.reconcile_id
partial_ids = [
x.id for x in reconcile.line_id
if x.id != line.transit_move_line_id.id
]
partial_ids = [x.id for x in reconcile.line_id
if x.id != line.transit_move_line_id.id]
reconcile_obj.write(
cr, uid, reconcile_id, {
'line_partial_ids': [(6, 0, partial_ids)],
'line_id': [(6, 0, [])],
}, context=context)
cr, uid, reconcile_id,
{'line_partial_ids': [(6, 0, partial_ids)],
'line_id': [(6, 0, [])]}, context=context)
reconcile_id = reconcile_obj.create(
cr, uid, {
'type': 'auto',
'line_id': [(6, 0, line.transit_move_line_id.id)],
}, context=context)
cr, uid,
{'type': 'auto',
'line_id': [(6, 0, line.transit_move_line_id.id)]},
context=context)
# mark the payment line for storno processed
if reconcile_id:
self.write(cr, uid, [payment_line_id],
@@ -146,4 +142,4 @@ class PaymentLine(orm.Model):
readonly=True,
help=("If this is true, the debit order has been canceled "
"by the bank or by the customer")),
}
}

View File

@@ -23,17 +23,16 @@
from openerp.osv import orm
class payment_order_create(orm.TransientModel):
class PaymentOrderCreate(orm.TransientModel):
_inherit = 'payment.order.create'
def extend_payment_order_domain(
self, cr, uid, payment_order, domain, context=None):
super(payment_order_create, self).extend_payment_order_domain(
super(PaymentOrderCreate, self).extend_payment_order_domain(
cr, uid, payment_order, domain, context=context)
domain += [
'|', '|',
('invoice', '=', False),
('invoice.payment_mode_id', '=', False),
('invoice.payment_mode_id', '=', payment_order.mode.id)
]
('invoice.payment_mode_id', '=', payment_order.mode.id)]
return True