[FIX] Fixes from pylint

This commit is contained in:
Stefan Rijnhart
2013-03-17 10:10:15 +01:00
parent 931110224a
commit 943343061a
10 changed files with 102 additions and 82 deletions

View File

@@ -805,7 +805,7 @@ class banking_import_transaction(osv.osv):
retval['type'] = type_map[move_lines[0].invoice.type]
return retval
def move_info2values(move_info):
def move_info2values(self, move_info):
vals = {}
vals['match_type'] = move_info['match_type']
vals['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]

View File

@@ -1,7 +1,32 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class account_bank_statement_line(osv.osv):
class account_bank_statement_line(orm.Model):
_inherit = 'account.bank.statement.line'
_columns = {
'match_type': fields.related(

View File

@@ -110,7 +110,7 @@ class payment_order(orm.Model):
}
_defaults = {
'payment_order_type': lambda *a: 'payment',
'payment_order_type': 'payment',
}
def launch_wizard(self, cr, uid, ids, context=None):

View File

@@ -1,20 +1,24 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -24,11 +28,10 @@ This module contains a single "wizard" for including a 'sent' state for manual
bank transfers.
'''
import wizard
import pooler
from openerp.osv import orm
class payment_manual(osv.Model):
class payment_manual(orm.Model):
_name = 'payment.manual'
_description = 'Set payment orders to \'sent\' manually'

View File

@@ -24,31 +24,14 @@
##############################################################################
from openerp.osv import orm, fields
from openerp import netsvc
from openerp.tools.translate import _
from openerp.addons.account_banking.parsers.convert import str2date
class banking_import_transaction(orm.Model):
_inherit = 'banking.import.transaction'
confirm_map = {
# Add storno and payment types
'storno': _confirm_storno,
'invoice': _confirm_move,
'manual': _confirm_move,
'payment_order': _confirm_payment_order,
'payment': _confirm_payment,
'move': _confirm_move,
}
cancel_map = {
'storno': _cancel_storno,
'invoice': _cancel_voucher,
'manual': _cancel_voucher,
'move': _cancel_voucher,
'payment_order': _cancel_payment_order,
'payment': _cancel_payment,
}
def _match_debit_order(
self, cr, uid, trans, log, context=None):
@@ -127,18 +110,21 @@ class banking_import_transaction(orm.Model):
# TODO: Not sure what side effects are created when payments are done
# for credited customer invoices, which will be matched later on too.
digits = dp.get_precision('Account')(cr)[1]
candidates = [x for x in payment_lines
if x.communication == trans.reference
and round(x.amount, digits) == -round(trans.transferred_amount, digits)
and trans.remote_account in (x.bank_id.acc_number,
x.bank_id.acc_number_domestic)
]
candidates = [
x for x in payment_lines
if x.communication == trans.reference
and round(x.amount, digits) == -round(
trans.transferred_amount, digits)
and trans.remote_account in (x.bank_id.acc_number,
x.bank_id.acc_number_domestic)
]
if len(candidates) == 1:
candidate = candidates[0]
# Check cache to prevent multiple matching of a single payment
if candidate.id not in linked_payments:
linked_payments[candidate.id] = True
move_info = self._get_move_info(cr, uid, [candidate.move_line_id.id])
move_info = self._get_move_info(
cr, uid, [candidate.move_line_id.id])
move_info.update({
'match_type': 'payment',
'payment_line_id': candidate.id,
@@ -157,7 +143,7 @@ class banking_import_transaction(orm.Model):
statement_line_pool = self.pool.get('account.bank.statement.line')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_line_id:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot link with storno"),
_("No direct debit order item"))
reconcile_id = payment_line_pool.debit_storno(
@@ -182,11 +168,11 @@ class banking_import_transaction(orm.Model):
statement_line_pool = self.pool.get('account.bank.statement.line')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_order_id:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot reconcile"),
_("Cannot reconcile: no direct debit order"))
if transaction.payment_order_id.payment_order_type != 'debit':
raise osv.except_osv(
raise orm.except_orm(
_("Cannot reconcile"),
_("Reconcile payment order not implemented"))
reconcile_id = payment_order_obj.debit_reconcile_transfer(
@@ -217,7 +203,7 @@ class banking_import_transaction(orm.Model):
def _cancel_payment(
self, cr, uid, transaction_id, context=None):
raise osv.except_osv(
raise orm.except_orm(
_("Cannot unreconcile"),
_("Cannot unreconcile: this operation is not yet supported for "
"match type 'payment'"))
@@ -229,11 +215,11 @@ class banking_import_transaction(orm.Model):
payment_order_obj = self.pool.get('payment.order')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_order_id:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot unreconcile"),
_("Cannot unreconcile: no direct debit order"))
if transaction.payment_order_id.payment_order_type != 'debit':
raise osv.except_osv(
raise orm.except_orm(
_("Cannot unreconcile"),
_("Unreconcile payment order not implemented"))
return payment_order_obj.debit_unreconcile_transfer(
@@ -253,11 +239,11 @@ class banking_import_transaction(orm.Model):
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_line_id:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel link with storno"),
_("No direct debit order item"))
if not transaction.payment_line_id.storno:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel link with storno"),
_("The direct debit order item is not marked for storno"))
@@ -276,7 +262,7 @@ class banking_import_transaction(orm.Model):
cancel_line = line
break
if not cancel_line:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel link with storno"),
_("Line id not found"))
reconcile = cancel_line.reconcile_id or cancel_line.reconcile_partial_id
@@ -289,7 +275,8 @@ class banking_import_transaction(orm.Model):
reconcile_obj.write(
cr, uid, reconcile.id,
{'line_partial_ids':
[(6, 0, [x.id for x in lines_reconcile if x.id != cancel_line.id])],
[(6, 0, [x.id for x in lines_reconcile
if x.id != cancel_line.id])],
'line_id': [(6, 0, [])],
}, context)
# redo the original payment line reconciliation with the invoice
@@ -341,7 +328,7 @@ class banking_import_transaction(orm.Model):
},
context=context)
def move_info2values(move_info):
def move_info2values(self, move_info):
vals = super(banking_import_transaction, self).move_info2values
vals['payment_line_id'] = move_info.get('payment_line_id', False)
vals['payment_order_ids'] = [
@@ -383,3 +370,16 @@ class banking_import_transaction(orm.Model):
wf_service.trg_validate(
uid, 'payment.order', id, 'done', cr)
return res
def __init__(self, pool, cr):
super(banking_import_transaction, self).__init__(pool, cr)
self.confirm_map.update({
'storno': self._confirm_storno,
'payment_order': self._confirm_payment_order,
'payment': self._confirm_payment,
})
self.cancel_map.update({
'storno': self._cancel_storno,
'payment_order': self._cancel_payment_order,
'payment': self._cancel_payment,
})

View File

@@ -30,12 +30,16 @@ class banking_transaction_wizard(orm.TransientModel):
_inherit = 'banking.transaction.wizard'
_columns = {
'payment_line_id': fields.related(
'import_transaction_id', 'payment_line_id', string="Matching payment or storno",
type='many2one', relation='payment.line', readonly=True),
'import_transaction_id', 'payment_line_id',
string="Matching payment or storno",
type='many2one', relation='payment.line',
readonly=True),
'payment_order_ids': fields.related(
'import_transaction_id', 'payment_order_ids', string="Matching payment orders",
'import_transaction_id', 'payment_order_ids',
string="Matching payment orders",
type='many2many', relation='payment.order'),
'payment_order_id': fields.related(
'import_transaction_id', 'payment_order_id', string="Payment order to reconcile",
'import_transaction_id', 'payment_order_id',
string="Payment order to reconcile",
type='many2one', relation='payment.order'),
}

View File

@@ -26,7 +26,7 @@
from openerp.osv import orm, fields
class payment_line(osv.osv):
class payment_line(orm.Model):
'''
Add extra export_state and date_done fields; make destination bank account
mandatory, as it makes no sense to send payments into thin air.
@@ -160,9 +160,9 @@ class payment_line(osv.osv):
),
}
_defaults = {
'export_state': lambda *a: 'draft',
'date_done': lambda *a: False,
'msg': lambda *a: '',
'export_state': 'draft',
'date_done': False,
'msg': '',
}
def fields_get(self, cr, uid, fields=None, context=None):
@@ -216,6 +216,3 @@ class payment_line(osv.osv):
"""
return False
payment_line()

View File

@@ -49,4 +49,3 @@ class payment_mode(orm.Model):
help='Select the Payment Type for the Payment Mode.'
),
}
payment_mode()

View File

@@ -27,9 +27,9 @@ from openerp.osv import orm, fields
class payment_mode_type(orm.Model):
_name= 'payment.mode.type'
_description= 'Payment Mode Type'
_columns= {
_name = 'payment.mode.type'
_description = 'Payment Mode Type'
_columns = {
'name': fields.char(
'Name', size=64, required=True,
help='Payment Type'
@@ -58,5 +58,5 @@ class payment_mode_type(orm.Model):
}
_defaults = {
'payment_order_type': lambda *a: 'payment',
'payment_order_type': 'payment',
}

View File

@@ -23,16 +23,8 @@
#
##############################################################################
import datetime
from openerp.osv import orm
from account_banking.struct import struct
from account_banking.parsers import convert
from openerp.osv import orm, fields
today = datetime.date.today
def str2date(str):
dt = convert.str2date(str, '%Y-%m-%d')
return datetime.date(dt.year, dt.month, dt.day)
class payment_order_create(orm.TransientModel):
_inherit = 'payment.order.create'
@@ -62,7 +54,7 @@ class payment_order_create(orm.TransientModel):
# t = None
# line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context)
_today = today()
_today = fields.date.context_today(self, cr, uid, context=context)
### end account banking
## Finally populate the current payment with new lines:
@@ -73,16 +65,16 @@ class payment_order_create(orm.TransientModel):
elif payment.date_prefered == 'due':
### account_banking
# date_to_pay = line.date_maturity
date_to_pay = line.date_maturity and \
str2date(line.date_maturity) > _today\
and line.date_maturity or False
date_to_pay = (
line.date_maturity if line.date_maturity
and line.date_maturity > _today else False)
### end account banking
elif payment.date_prefered == 'fixed':
### account_banking
# date_to_pay = payment.date_planned
date_to_pay = payment.date_planned and \
str2date(payment.date_planned) > _today\
and payment.date_planned or False
date_to_pay = (
payment.date_planned if payment.date_planned
and payment.date_planned > _today else False)
### end account banking
### account_banking
@@ -111,7 +103,7 @@ class payment_order_create(orm.TransientModel):
amount_currency = line.amount_to_pay
### end account_banking
payment_obj.create(cr, uid,{
payment_obj.create(cr, uid, {
'move_line_id': line.id,
'amount_currency': amount_currency,
'bank_id': line2bank.get(line.id),