[RFR] License and coding standards

This commit is contained in:
Stefan Rijnhart
2013-03-18 15:56:40 +01:00
parent 8819b9b28f
commit b0e9934df3

View File

@@ -1,45 +1,44 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# Contributions by Kaspars Vilkens (KNdati):
# lenghty discussions, bugreports and bugfixes
# Refractoring (C) 2011 Therp BV (<http://therp.nl>).
# (C) 2011 Smile (<http://smile.fr>).
# (C) 2011 Therp BV (<http://therp.nl>).
# (C) 2011 Smile (<http://smile.fr>).
#
# 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/>.
#
##############################################################################
from osv import osv, fields
import netsvc
import base64
import datetime
from tools import config
from tools.translate import _
from parsers import models
from parsers.convert import *
# from account_banking.struct import struct
from account_banking import sepa
from wizard.banktools import *
import decimal_precision as dp
from openerp.osv import orm, fields
from openerp import netsvc
from openerp.tools import config
from openerp.tools.translate import _
from openerp.addons.decimal_precision import decimal_precision as dp
from openerp.addons.account_banking.parsers import models
from openerp.addons.account_banking.parsers.convert import *
from openerp.addons.account_banking import sepa
from openerp.addons.account_banking.wizard.banktools import *
bt = models.mem_bank_transaction
class banking_import_transaction(osv.osv):
class banking_import_transaction(orm.Model):
""" orm representation of mem_bank_transaction() for interactive and posthoc
configuration of reconciliation in the bank statement view.
@@ -406,7 +405,7 @@ class banking_import_transaction(osv.osv):
transaction = self.browse(cr, uid, transaction_id, context)
if not transaction.move_line_id:
if transaction.match_type == 'invoice':
raise osv.except_osv(
raise orm.except_orm(
_("Cannot link transaction %s with invoice") %
transaction.statement_line_id.name,
(transaction.invoice_ids and
@@ -416,7 +415,7 @@ class banking_import_transaction(osv.osv):
transaction.statement_line_id.name
)))
else:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot link transaction %s with accounting entry") %
transaction.statement_line_id.name,
(transaction.move_line_ids and
@@ -649,7 +648,7 @@ class banking_import_transaction(osv.osv):
if not transaction.match_type:
continue
if transaction.match_type not in self.cancel_map:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel type %s" % transaction.match_type),
_("No method found to cancel this type"))
self.cancel_map[transaction.match_type](
@@ -670,7 +669,7 @@ class banking_import_transaction(osv.osv):
if not transaction.match_type:
continue
if transaction.match_type not in self.confirm_map:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot reconcile"),
_("Cannot reconcile type %s. No method found to " +
"reconcile this type") %
@@ -678,7 +677,7 @@ class banking_import_transaction(osv.osv):
)
if (transaction.residual and transaction.writeoff_account_id):
if transaction.match_type not in ('invoice', 'move', 'manual'):
raise osv.except_osv(
raise orm.except_orm(
_("Cannot reconcile"),
_("Bank transaction %s: write off not implemented for " +
"this match type.") %
@@ -727,7 +726,7 @@ class banking_import_transaction(osv.osv):
me['transferred_amount'] - trans.transferred_amount):
dupes.append(trans.id)
if len(dupes) < 1:
raise osv.except_osv(_('Cannot check for duplicate'),
raise orm.except_orm(_('Cannot check for duplicate'),
_("Cannot check for duplicate. "
"I can't find myself."))
if len(dupes) > 1:
@@ -886,7 +885,7 @@ class banking_import_transaction(osv.osv):
if (transaction.statement_line_id and
transaction.statement_line_id.state == 'confirmed'):
raise osv.except_osv(
raise orm.except_orm(
_("Cannot perform match"),
_("Cannot perform match on a confirmed transction"))
@@ -1412,7 +1411,8 @@ class banking_import_transaction(osv.osv):
banking_import_transaction()
class account_bank_statement_line(osv.osv):
class account_bank_statement_line(orm.Model):
_inherit = 'account.bank.statement.line'
_columns = {
'import_transaction_id': fields.many2one(
@@ -1490,14 +1490,14 @@ class account_bank_statement_line(osv.osv):
if st_line.state != 'draft':
continue
if st_line.duplicate:
raise osv.except_osv(
raise orm.except_orm(
_('Bank transfer flagged as duplicate'),
_("You cannot confirm a bank transfer marked as a "
"duplicate (%s.%s)") %
(st_line.statement_id.name, st_line.name,))
if st_line.analytic_account_id:
if not st_line.statement_id.journal_id.analytic_journal_id:
raise osv.except_osv(
raise orm.except_orm(
_('No Analytic Journal !'),
_("You have to define an analytic journal on the '%s' "
"journal!") % (st_line.statement_id.journal_id.name,))
@@ -1549,7 +1549,7 @@ class account_bank_statement_line(osv.osv):
if st_line.state != 'confirmed':
continue
if st_line.statement_id.state != 'draft':
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel bank transaction"),
_("The bank statement that this transaction belongs to has "
"already been confirmed"))
@@ -1584,7 +1584,7 @@ class account_bank_statement_line(osv.osv):
ids = [ids]
for line in self.browse(cr, uid, ids, context=context):
if line.state == 'confirmed':
raise osv.except_osv(
raise orm.except_orm(
_('Confirmed Statement Line'),
_("You cannot delete a confirmed Statement Line"
": '%s'" % line.name))
@@ -1629,7 +1629,8 @@ class account_bank_statement_line(osv.osv):
account_bank_statement_line()
class account_bank_statement(osv.osv):
class account_bank_statement(orm.Model):
_inherit = 'account.bank.statement'
def _end_balance(self, cursor, user, ids, name, attr, context=None):
@@ -1665,13 +1666,13 @@ class account_bank_statement(osv.osv):
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
raise osv.except_osv(_('Configuration Error !'),
raise orm.except_orm(_('Configuration Error !'),
_('Please verify that an account is defined in the journal.'))
# protect against misguided manual changes
for line in st.move_line_ids:
if line.state != 'valid':
raise osv.except_osv(_('Error !'),
raise orm.except_orm(_('Error !'),
_('The account entries lines are not in valid state.'))
line_obj.confirm(cr, uid, [line.id for line in st.line_ids], context)
@@ -1696,7 +1697,7 @@ class account_bank_statement(osv.osv):
for st in self.browse(cr, uid, ids, context=context):
for line in st.line_ids:
if line.state == 'confirmed':
raise osv.except_osv(_('Confirmed Statement Lines'), _("You cannot delete a Statement with confirmed Statement Lines: '%s'" % st.name))
raise orm.except_orm(_('Confirmed Statement Lines'), _("You cannot delete a Statement with confirmed Statement Lines: '%s'" % st.name))
return super(account_bank_statement,self).unlink(cr, uid, ids, context=context)
_columns = {