diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index 8a6dd055f..009bbe603 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -267,7 +267,7 @@ class account_banking_imported_file(orm.Model): } _defaults = { 'date': fields.date.context_today, - 'user_id': lambda self, cursor, uid, context: uid, + 'user_id': lambda self, cr, uid, context: uid, } account_banking_imported_file() @@ -320,12 +320,12 @@ class account_bank_statement(orm.Model): ['journal_id','period_id']), ] - def _get_period(self, cursor, uid, date, context=None): + def _get_period(self, cr, uid, date, context=None): ''' Find matching period for date, not meant for _defaults. ''' period_obj = self.pool.get('account.period') - periods = period_obj.find(cursor, uid, dt=date, context=context) + periods = period_obj.find(cr, uid, dt=date, context=context) return periods and periods[0] or False def _prepare_move( @@ -467,12 +467,12 @@ class account_bank_statement_line(orm.Model): _inherit = 'account.bank.statement.line' _description = 'Bank Transaction' - def _get_period(self, cursor, user, context=None): + def _get_period(self, cr, uid, context=None): date = context.get('date', None) - periods = self.pool.get('account.period').find(cursor, user, dt=date) + periods = self.pool.get('account.period').find(cr, uid, dt=date) return periods and periods[0] or False - def _get_currency(self, cursor, user, context=None): + def _get_currency(self, cr, uid, context=None): ''' Get the default currency (required to allow other modules to function, which assume currency to be a calculated field and thus optional) @@ -480,7 +480,7 @@ class account_bank_statement_line(orm.Model): which is inaccessible from within this method. ''' res_users_obj = self.pool.get('res.users') - return res_users_obj.browse(cursor, user, user, + return res_users_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id def _get_invoice_id(self, cr, uid, ids, name, args, context=None): @@ -605,7 +605,7 @@ class res_partner_bank(orm.Model): iban = sepa.IBAN(acc_number) return (str(iban), iban.localized_BBAN) - def create(self, cursor, uid, vals, context=None): + def create(self, cr, uid, vals, context=None): ''' Create dual function IBAN account for SEPA countries ''' @@ -614,7 +614,7 @@ class res_partner_bank(orm.Model): or vals.get('acc_number_domestic', False)) vals['acc_number'], vals['acc_number_domestic'] = ( self._correct_IBAN(iban)) - return self._founder.create(self, cursor, uid, vals, context) + return self._founder.create(self, cr, uid, vals, context) def write(self, cr, uid, ids, vals, context=None): ''' @@ -637,7 +637,7 @@ class res_partner_bank(orm.Model): self._founder.write(self, cr, uid, account['id'], vals, context) return True - def search(self, cursor, uid, args, *rest, **kwargs): + def search(self, cr, uid, args, *rest, **kwargs): ''' Overwrite search, as both acc_number and iban now can be filled, so the original base_iban 'search and search again fuzzy' tactic now can @@ -698,7 +698,7 @@ class res_partner_bank(orm.Model): # Original search results = super(res_partner_bank, self).search( - cursor, uid, newargs, *rest, **kwargs) + cr, uid, newargs, *rest, **kwargs) return results def read( @@ -721,23 +721,23 @@ class res_partner_bank(orm.Model): return records return records[0] - def check_iban(self, cursor, uid, ids): + def check_iban(self, cr, uid, ids): ''' Check IBAN number ''' - for bank_acc in self.browse(cursor, uid, ids): + for bank_acc in self.browse(cr, uid, ids): if bank_acc.state == 'iban' and bank_acc.acc_number: iban = sepa.IBAN(bank_acc.acc_number) if not iban.valid: return False return True - def get_bban_from_iban(self, cursor, uid, ids, context=None): + def get_bban_from_iban(self, cr, uid, ids, context=None): ''' Return the local bank account number aka BBAN from the IBAN. ''' res = {} - for record in self.browse(cursor, uid, ids, context): + for record in self.browse(cr, uid, ids, context): if not record.state == 'iban': res[record.id] = False else: @@ -763,7 +763,7 @@ class res_partner_bank(orm.Model): ) def onchange_domestic( - self, cursor, uid, ids, acc_number, + self, cr, uid, ids, acc_number, partner_id, country_id, context=None): ''' Trigger to find IBAN. When found: @@ -785,7 +785,7 @@ class res_partner_bank(orm.Model): # which can be overridden by the user. # 1. Use provided country_id (manually filled) if country_id: - country = country_obj.browse(cursor, uid, country_id) + country = country_obj.browse(cr, uid, country_id) country_ids = [country_id] # 2. Use country_id of found bank accounts # This can be usefull when there is no country set in the partners @@ -793,7 +793,7 @@ class res_partner_bank(orm.Model): # account itself before this method was triggered. elif ids and len(ids) == 1: partner_bank_obj = self.pool.get('res.partner.bank') - partner_bank_id = partner_bank_obj.browse(cursor, uid, ids[0]) + partner_bank_id = partner_bank_obj.browse(cr, uid, ids[0]) if partner_bank_id.country_id: country = partner_bank_id.country_id country_ids = [country.id] @@ -804,12 +804,12 @@ class res_partner_bank(orm.Model): # bank account, hence the additional check. elif partner_id: partner_obj = self.pool.get('res.partner') - country = partner_obj.browse(cursor, uid, partner_id).country + country = partner_obj.browse(cr, uid, partner_id).country country_ids = country and [country.id] or [] # 4. Without any of the above, take the country from the company of # the handling user if not country_ids: - user = self.pool.get('res.users').browse(cursor, uid, uid) + user = self.pool.get('res.users').browse(cr, uid, uid) # Try user companies partner (user no longer has address in 6.1) if (user.company_id and user.company_id.partner_id and @@ -830,7 +830,7 @@ class res_partner_bank(orm.Model): # Complete data with online database when available if country_ids: country = country_obj.browse( - cursor, uid, country_ids[0], context=context) + cr, uid, country_ids[0], context=context) values['country_id'] = country_ids[0] if country and country.code in sepa.IBAN.countries: try: @@ -842,7 +842,7 @@ class res_partner_bank(orm.Model): values['acc_number'] = unicode(iban_acc) values['state'] = 'iban' bank_id, country_id = get_or_create_bank( - self.pool, cursor, uid, + self.pool, cr, uid, info.bic or iban_acc.BIC_searchkey, name = info.bank ) @@ -911,7 +911,7 @@ class res_bank(orm.Model): ''' _inherit = 'res.bank' - def onchange_bic(self, cursor, uid, ids, bic, name, context=None): + def onchange_bic(self, cr, uid, ids, bic, name, context=None): ''' Trigger to auto complete other fields. ''' @@ -924,7 +924,7 @@ class res_bank(orm.Model): if address and address.country_id: country_id = self.pool.get('res.country').search( - cursor, uid, [('code','=',address.country_id)] + cr, uid, [('code','=',address.country_id)] ) country_id = country_id and country_id[0] or False else: diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index 14a38f0e3..e882a8627 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1630,14 +1630,14 @@ account_bank_statement_line() class account_bank_statement(orm.Model): _inherit = 'account.bank.statement' - def _end_balance(self, cursor, user, ids, name, attr, context=None): + def _end_balance(self, cr, uid, ids, name, attr, context=None): """ This method taken from account/account_bank_statement.py and altered to take the statement line subflow into account """ res = {} - statements = self.browse(cursor, user, ids, context=context) + statements = self.browse(cr, uid, ids, context=context) for statement in statements: res[statement.id] = statement.balance_start diff --git a/account_banking/wizard/bank_import.py b/account_banking/wizard/bank_import.py index 9687b7dfd..873b439b7 100644 --- a/account_banking/wizard/bank_import.py +++ b/account_banking/wizard/bank_import.py @@ -28,9 +28,9 @@ This module contains the business logic of the wizard account_banking_import. The parsing is done in the parser modules. Every parser module is required to use parser.models as a mean of communication with the business logic. ''' -from osv import orm, fields import base64 import datetime +from openerp.osv import orm, fields from openerp.tools.translate import _ from openerp.addons.account_banking.parsers import models from openerp.addons.account_banking.parsers import convert @@ -97,13 +97,13 @@ class banking_import_line(orm.TransientModel): class banking_import(orm.TransientModel): _name = 'account.banking.bank.import' - def import_statements_file(self, cursor, uid, ids, context): + def import_statements_file(self, cr, uid, ids, context): ''' Import bank statements / bank transactions file. This method is a wrapper for the business logic on the transaction. The parser modules represent the decoding logic. ''' - banking_import = self.browse(cursor, uid, ids, context)[0] + banking_import = self.browse(cr, uid, ids, context)[0] statements_file = banking_import.file data = base64.decodestring(statements_file) @@ -125,10 +125,10 @@ class banking_import(orm.TransientModel): # Get the company company = (banking_import.company or - user_obj.browse(cursor, uid, uid, context).company_id) + user_obj.browse(cr, uid, uid, context).company_id) # Parse the file - statements = parser.parse(cursor, data) + statements = parser.parse(cr, data) if any([x for x in statements if not x.is_valid()]): raise orm.except_orm( @@ -137,7 +137,7 @@ class banking_import(orm.TransientModel): ) # Create the file now, as the statements need to be linked to it - import_id = statement_file_obj.create(cursor, uid, dict( + import_id = statement_file_obj.create(cr, uid, dict( company_id = company.id, file = statements_file, state = 'unfinished', @@ -184,7 +184,7 @@ class banking_import(orm.TransientModel): else: # Pull account info/currency account_info = banktools.get_company_bank_account( - self.pool, cursor, uid, statement.local_account, + self.pool, cr, uid, statement.local_account, statement.local_currency, company, results.log ) if not account_info: @@ -238,7 +238,7 @@ class banking_import(orm.TransientModel): # (e.g. a datetime string of the moment of import) # and have potential duplicates flagged by the # matching procedure - statement_ids = statement_obj.search(cursor, uid, [ + statement_ids = statement_obj.search(cr, uid, [ ('name', '=', statement.id), ('date', '=', convert.date2str(statement.date)), ]) @@ -252,7 +252,7 @@ class banking_import(orm.TransientModel): # Get the period for the statement (as bank statement object checks this) period_ids = period_obj.search( - cursor, uid, [ + cr, uid, [ ('company_id', '=', company.id), ('date_start', '<=', statement.date), ('date_stop', '>=', statement.date), @@ -270,7 +270,7 @@ class banking_import(orm.TransientModel): continue # Create the bank statement record - statement_id = statement_obj.create(cursor, uid, dict( + statement_id = statement_obj.create(cr, uid, dict( name = statement.id, journal_id = account_info.journal_id.id, date = convert.date2str(statement.date), @@ -302,21 +302,21 @@ class banking_import(orm.TransientModel): values['local_currency'] = statement.local_currency transaction_id = import_transaction_obj.create( - cursor, uid, values, context=context) + cr, uid, values, context=context) transaction_ids.append(transaction_id) results.stat_loaded_cnt += 1 - import_transaction_obj.match(cursor, uid, transaction_ids, results=results, context=context) + import_transaction_obj.match(cr, uid, transaction_ids, results=results, context=context) #recompute statement end_balance for validation statement_obj.button_dummy( - cursor, uid, imported_statement_ids, context=context) + cr, uid, imported_statement_ids, context=context) # Original code. Didn't take workflow logistics into account... # - #cursor.execute( + #cr.execute( # "UPDATE payment_order o " # "SET state = 'done', " # "date_done = '%s' " @@ -358,13 +358,13 @@ class banking_import(orm.TransientModel): ] text_log = '\n'.join(report + results.log) state = results.error_cnt and 'error' or 'ready' - statement_file_obj.write(cursor, uid, import_id, dict( + statement_file_obj.write(cr, uid, import_id, dict( state = state, log = text_log, ), context) if not imported_statement_ids or not results.trans_loaded_cnt: # file state can be 'ready' while import state is 'error' state = 'error' - self.write(cursor, uid, [ids[0]], dict( + self.write(cr, uid, [ids[0]], dict( import_id = import_id, log = text_log, state = state, statement_ids = [(6, 0, imported_statement_ids)], ), context) diff --git a/account_banking/wizard/banktools.py b/account_banking/wizard/banktools.py index abec5ef12..aad9ddf10 100644 --- a/account_banking/wizard/banktools.py +++ b/account_banking/wizard/banktools.py @@ -50,7 +50,7 @@ def get_period(pool, cr, uid, date, company, log=None): return False return period_ids[0] -def get_bank_accounts(pool, cursor, uid, account_number, log, fail=False): +def get_bank_accounts(pool, cr, uid, account_number, log, fail=False): ''' Get the bank account with account number account_number ''' @@ -59,13 +59,13 @@ def get_bank_accounts(pool, cursor, uid, account_number, log, fail=False): return False partner_bank_obj = pool.get('res.partner.bank') - bank_account_ids = partner_bank_obj.search(cursor, uid, [ + bank_account_ids = partner_bank_obj.search(cr, uid, [ ('acc_number', '=', account_number) ]) if not bank_account_ids: # SR 2012-02-19 does the search() override in res_partner_bank # provides this result on the previous query? - bank_account_ids = partner_bank_obj.search(cursor, uid, [ + bank_account_ids = partner_bank_obj.search(cr, uid, [ ('acc_number_domestic', '=', account_number) ]) if not bank_account_ids: @@ -75,7 +75,7 @@ def get_bank_accounts(pool, cursor, uid, account_number, log, fail=False): % dict(account_no=account_number) ) return False - return partner_bank_obj.browse(cursor, uid, bank_account_ids) + return partner_bank_obj.browse(cr, uid, bank_account_ids) def _has_attr(obj, attr): # Needed for dangling addresses and a weird exception scheme in @@ -154,14 +154,14 @@ def get_or_create_partner(pool, cr, uid, name, address, postal_code, city, partner_id = partner_ids[0] return partner_id -def get_company_bank_account(pool, cursor, uid, account_number, currency, +def get_company_bank_account(pool, cr, uid, account_number, currency, company, log): ''' Get the matching bank account for this company. Currency is the ISO code for the requested currency. ''' results = struct() - bank_accounts = get_bank_accounts(pool, cursor, uid, account_number, log, + bank_accounts = get_bank_accounts(pool, cr, uid, account_number, log, fail=True) if not bank_accounts: return False @@ -184,12 +184,12 @@ def get_company_bank_account(pool, cursor, uid, account_number, currency, # Find matching journal for currency journal_obj = pool.get('account.journal') - journal_ids = journal_obj.search(cursor, uid, [ + journal_ids = journal_obj.search(cr, uid, [ ('type', '=', 'bank'), ('currency.name', '=', currency or company.currency_id.name) ]) if currency == company.currency_id.name: - journal_ids_no_curr = journal_obj.search(cursor, uid, [ + journal_ids_no_curr = journal_obj.search(cr, uid, [ ('type', '=', 'bank'), ('currency', '=', False) ]) journal_ids.extend(journal_ids_no_curr) @@ -197,9 +197,9 @@ def get_company_bank_account(pool, cursor, uid, account_number, currency, criteria.append(('journal_id', 'in', journal_ids)) # Find bank account settings - bank_settings_ids = bank_settings_obj.search(cursor, uid, criteria) + bank_settings_ids = bank_settings_obj.search(cr, uid, criteria) if bank_settings_ids: - settings = bank_settings_obj.browse(cursor, uid, bank_settings_ids)[0] + settings = bank_settings_obj.browse(cr, uid, bank_settings_ids)[0] results.company_id = company results.journal_id = settings.journal_id @@ -217,7 +217,7 @@ def get_company_bank_account(pool, cursor, uid, account_number, currency, return results -def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, +def get_or_create_bank(pool, cr, uid, bic, online=False, code=None, name=None): ''' Find or create the bank with the provided BIC code. @@ -233,27 +233,27 @@ def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, if len(bic) < 8: # search key bank_ids = bank_obj.search( - cursor, uid, [ + cr, uid, [ ('bic', '=', bic[:6]) ]) if not bank_ids: bank_ids = bank_obj.search( - cursor, uid, [ + cr, uid, [ ('bic', 'ilike', bic + '%') ]) else: bank_ids = bank_obj.search( - cursor, uid, [ + cr, uid, [ ('bic', '=', bic) ]) if bank_ids and len(bank_ids) == 1: - banks = bank_obj.browse(cursor, uid, bank_ids) + banks = bank_obj.browse(cr, uid, bank_ids) return banks[0].id, banks[0].country.id country_obj = pool.get('res.country') country_ids = country_obj.search( - cursor, uid, [('code', '=', bic[4:6])] + cr, uid, [('code', '=', bic[4:6])] ) country_id = country_ids and country_ids[0] or False bank_id = False @@ -261,7 +261,7 @@ def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, if online: info, address = sepa.online.bank_info(bic) if info: - bank_id = bank_obj.create(cursor, uid, dict( + bank_id = bank_obj.create(cr, uid, dict( code = info.code, name = info.name, street = address.street, @@ -275,7 +275,7 @@ def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, info = struct(name=name, code=code) if not online or not bank_id: - bank_id = bank_obj.create(cursor, uid, dict( + bank_id = bank_obj.create(cr, uid, dict( code = info.code or 'UNKNOW', name = info.name or _('Unknown Bank'), country = country_id, @@ -283,7 +283,7 @@ def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, )) return bank_id, country_id -def create_bank_account(pool, cursor, uid, partner_id, +def create_bank_account(pool, cr, uid, partner_id, account_number, holder_name, address, city, country_code, log, bic=False, ): @@ -309,16 +309,16 @@ def create_bank_account(pool, cursor, uid, partner_id, if not country_code: country = pool.get('res.partner').browse( - cursor, uid, partner_id).country + cr, uid, partner_id).country country_code = country.code country_id = country.id else: if iban.valid: - country_ids = country_obj.search(cursor, uid, + country_ids = country_obj.search(cr, uid, [('code', '=', iban.countrycode)] ) else: - country_ids = country_obj.search(cursor, uid, + country_ids = country_obj.search(cr, uid, [('code', '=', country_code)] ) country_id = country_ids[0] @@ -339,10 +339,10 @@ def create_bank_account(pool, cursor, uid, partner_id, bic = account_info.bic if bic: - values.bank = get_or_create_bank(pool, cursor, uid, bic)[0] + values.bank = get_or_create_bank(pool, cr, uid, bic)[0] values.bank_bic = bic # Create bank account and return - return pool.get('res.partner.bank').create(cursor, uid, values) + return pool.get('res.partner.bank').create(cr, uid, values) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_nl_clieop/account_banking_nl_clieop.py b/account_banking_nl_clieop/account_banking_nl_clieop.py index b0da0bb74..44b68c3cb 100644 --- a/account_banking_nl_clieop/account_banking_nl_clieop.py +++ b/account_banking_nl_clieop/account_banking_nl_clieop.py @@ -1,6 +1,7 @@ ############################################################################## # # Copyright (C) 2009 EduSense BV (). +# (C) 2011 - 2013 Therp BV (). # All Rights Reserved # # This program is free software: you can redistribute it and/or modify @@ -18,11 +19,12 @@ # ############################################################################## -from osv import osv, fields from datetime import date -from tools.translate import _ +from openerp.osv import orm, fields +from openerp.tools.translate import _ -class clieop_export(osv.osv): + +class clieop_export(orm.Model): '''ClieOp3 Export''' _name = 'banking.export.clieop' _description = __doc__ @@ -94,6 +96,3 @@ class clieop_export(osv.osv): 'state': 'draft', 'daynumber': get_daynr, } -clieop_export() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_nl_clieop/wizard/export_clieop.py b/account_banking_nl_clieop/wizard/export_clieop.py index 641507124..985455887 100644 --- a/account_banking_nl_clieop/wizard/export_clieop.py +++ b/account_banking_nl_clieop/wizard/export_clieop.py @@ -2,6 +2,7 @@ ############################################################################## # # Copyright (C) 2009 EduSense BV (). +# 2011 - 2013 Therp BV (). # All Rights Reserved # # This program is free software: you can redistribute it and/or modify @@ -21,11 +22,11 @@ import base64 from datetime import datetime, date, timedelta -from osv import osv, fields -from tools.translate import _ -import netsvc -from account_banking import sepa -import clieop +from openerp.osv import orm, fields +from openerp.tools.translate import _ +from openerp import netsvc +from openerp.addons.account_banking import sepa +from openerp.addons.account_banking_nl_clieop.wizard import clieop def strpdate(arg, format='%Y-%m-%d'): '''shortcut''' @@ -35,7 +36,7 @@ def strfdate(arg, format='%Y-%m-%d'): '''shortcut''' return arg.strftime(format) -class banking_export_clieop_wizard(osv.osv_memory): +class banking_export_clieop_wizard(orm.TransientModel): _name = 'banking.export.clieop.wizard' _description = 'Client Opdrachten Export' _columns = { @@ -155,17 +156,17 @@ class banking_export_clieop_wizard(osv.osv_memory): 'test': True, } - def create(self, cursor, uid, vals, context=None): + def create(self, cr, uid, vals, context=None): ''' Retrieve a sane set of default values based on the payment orders from the context. ''' if 'batchtype' not in vals: - self.check_orders(cursor, uid, vals, context) + self.check_orders(cr, uid, vals, context) return super(banking_export_clieop_wizard, self).create( - cursor, uid, vals, context) + cr, uid, vals, context) - def check_orders(self, cursor, uid, vals, context): + def check_orders(self, cr, uid, vals, context): ''' Check payment type for all orders. @@ -177,14 +178,14 @@ class banking_export_clieop_wizard(osv.osv_memory): Also mind that rates for batches are way higher than those for transactions. It pays to limit the number of batches. ''' - today = date.today() + today = fields.date.context_date(self, cr, uid, context=context) payment_order_obj = self.pool.get('payment.order') # Payment order ids are provided in the context payment_order_ids = context.get('active_ids', []) runs = {} # Only orders of same type can be combined - payment_orders = payment_order_obj.browse(cursor, uid, payment_order_ids) + payment_orders = payment_order_obj.browse(cr, uid, payment_order_ids) for payment_order in payment_orders: payment_type = payment_order.mode.type.code @@ -212,12 +213,12 @@ class banking_export_clieop_wizard(osv.osv_memory): else: execution_date = today if execution_date and execution_date >= max_date: - raise osv.except_osv( + raise orm.except_orm( _('Error'), _('You can\'t create ClieOp orders more than 30 days in advance.') ) if len(runs) != 1: - raise osv.except_osv( + raise orm.except_orm( _('Error'), _('You can only combine payment orders of the same type') ) @@ -231,12 +232,12 @@ class banking_export_clieop_wizard(osv.osv_memory): 'state': 'create', }) - def create_clieop(self, cursor, uid, ids, context): + def create_clieop(self, cr, uid, ids, context): ''' Wizard to actually create the ClieOp3 file ''' payment_order_obj = self.pool.get('payment.order') - clieop_export = self.browse(cursor, uid, ids, context)[0] + clieop_export = self.browse(cr, uid, ids, context)[0] clieopfile = None for payment_order in clieop_export.payment_order_ids: if not clieopfile: @@ -253,7 +254,7 @@ class banking_export_clieop_wizard(osv.osv_memory): else: our_account_nr = payment_order.mode.bank_id.acc_number if not our_account_nr: - raise osv.except_osv( + raise orm.except_orm( _('Error'), _('Your bank account has to have a valid account number') ) @@ -267,7 +268,7 @@ class banking_export_clieop_wizard(osv.osv_memory): accountno_sender = our_account_nr, seqno = self.pool.get( 'banking.export.clieop').get_daynr( - cursor, uid, context=context), + cr, uid, context=context), test = clieop_export['test'] ) @@ -291,7 +292,7 @@ class banking_export_clieop_wizard(osv.osv_memory): for line in payment_order.line_ids: # Check on missing partner of bank account (this can happen!) if not line.bank_id or not line.bank_id.partner_id: - raise osv.except_osv( + raise orm.except_orm( _('Error'), _('There is insufficient information.\r\n' 'Both destination address and account ' @@ -314,7 +315,7 @@ class banking_export_clieop_wizard(osv.osv_memory): # Is this an IBAN account? if iban.valid: if iban.countrycode != 'NL': - raise osv.except_osv( + raise orm.except_orm( _('Error'), _('You cannot send international bank transfers ' 'through ClieOp3!') @@ -331,7 +332,7 @@ class banking_export_clieop_wizard(osv.osv_memory): # Generate the specifics of this clieopfile order = clieopfile.order file_id = self.pool.get('banking.export.clieop').create( - cursor, uid, dict( + cr, uid, dict( filetype = order.name_transactioncode, identification = order.identification, prefered_date = strfdate(order.preferred_execution_date), @@ -346,7 +347,7 @@ class banking_export_clieop_wizard(osv.osv_memory): [6, 0, [x.id for x in clieop_export['payment_order_ids']]] ], ), context) - self.write(cursor, uid, [ids[0]], dict( + self.write(cr, uid, [ids[0]], dict( filetype = order.name_transactioncode, testcode = order.testcode, file_id = file_id, @@ -364,31 +365,27 @@ class banking_export_clieop_wizard(osv.osv_memory): 'res_id': ids[0] or False, } - def cancel_clieop(self, cursor, uid, ids, context): + def cancel_clieop(self, cr, uid, ids, context): ''' Cancel the ClieOp: just drop the file ''' - clieop_export = self.read(cursor, uid, ids, ['file_id'], context)[0] - self.pool.get('banking.export.clieop').unlink(cursor, uid, clieop_export['file_id'][0]) + clieop_export = self.read(cr, uid, ids, ['file_id'], context)[0] + self.pool.get('banking.export.clieop').unlink(cr, uid, clieop_export['file_id'][0]) return {'type': 'ir.actions.act_window_close'} - def save_clieop(self, cursor, uid, ids, context): + def save_clieop(self, cr, uid, ids, context): ''' Save the ClieOp: mark all payments in the file as 'sent', if not a test ''' clieop_export = self.browse( - cursor, uid, ids, context)[0] + cr, uid, ids, context)[0] if not clieop_export['test']: clieop_obj = self.pool.get('banking.export.clieop') payment_order_obj = self.pool.get('payment.order') clieop_file = clieop_obj.write( - cursor, uid, clieop_export['file_id'].id, {'state': 'sent'} + cr, uid, clieop_export['file_id'].id, {'state': 'sent'} ) wf_service = netsvc.LocalService('workflow') for order in clieop_export['payment_order_ids']: - wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cursor) + wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr) return {'type': 'ir.actions.act_window_close'} - -banking_export_clieop_wizard() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bank_statement_instant_voucher/model/account_bank_statement_line.py b/bank_statement_instant_voucher/model/account_bank_statement_line.py index cf8beb9c3..a72205281 100644 --- a/bank_statement_instant_voucher/model/account_bank_statement_line.py +++ b/bank_statement_instant_voucher/model/account_bank_statement_line.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# This module copyright (C) 2012 Therp BV (). +# This module copyright (C) 2012 - 2013 Therp BV (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,10 +19,10 @@ # ############################################################################## -from openerp.osv import osv, fields +from openerp.osv import orm, fields -class account_bank_statement_line(osv.Model): +class account_bank_statement_line(orm.Model): _inherit = 'account.bank.statement.line' def create_instant_voucher(self, cr, uid, ids, context=None): res = False diff --git a/bank_statement_instant_voucher/model/account_voucher_instant.py b/bank_statement_instant_voucher/model/account_voucher_instant.py index 7ca3727ba..3c7354ded 100644 --- a/bank_statement_instant_voucher/model/account_voucher_instant.py +++ b/bank_statement_instant_voucher/model/account_voucher_instant.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# This module copyright (C) 2012 Therp BV (). +# This module copyright (C) 2012 - 2013 Therp BV (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,12 +19,12 @@ # ############################################################################## -from openerp.osv import osv, fields +from openerp.osv import orm, fields from openerp.tools.translate import _ from openerp.addons.decimal_precision import decimal_precision as dp -class instant_voucher(osv.TransientModel): +class instant_voucher(orm.TransientModel): _name = 'account.voucher.instant' _description = 'Instant Voucher' @@ -76,7 +76,7 @@ class instant_voucher(osv.TransientModel): cr, uid, [('company_id', '=', line.company_id.id), ('type', '=', voucher_type)]) if not journal_ids: - osv.exept_osv( + orm.exept_orm( _('Error'), _('No %s journal defined') % voucher_type) @@ -156,7 +156,7 @@ class instant_voucher(osv.TransientModel): context.get('active_id') or context.get('active_ids') and context.get('active_ids')[0]) if not res['statement_line_id']: - raise osv.except_osv( + raise orm.except_orm( _('Error'), _('Cannot determine statement line')) line = self.pool.get('account.bank.statement.line').browse( @@ -212,7 +212,7 @@ class instant_voucher(osv.TransientModel): instant.voucher_id.company_id.currency_id) if (instant.statement_line_id.statement_id.currency.id != voucher_currency.id): - raise osv.except_osv( + raise orm.except_orm( _("Error"), _("Currency on the bank statement line needs to be the " "same as on the voucher. Currency conversion is not yet " @@ -222,7 +222,7 @@ class instant_voucher(osv.TransientModel): cr, uid, [instant.voucher_id.id], context=context) instant.refresh() if instant.voucher_id.state != 'posted': - raise osv.except_osv( + raise orm.except_orm( _("Error"), _("The voucher could not be posted.")) if instant.voucher_id.move_id.state != 'posted': @@ -230,12 +230,12 @@ class instant_voucher(osv.TransientModel): cr, uid, [instant.voucher_id.move_id.id], context=context) instant.refresh() if instant.voucher_id.move_id.state != 'posted': - raise osv.except_osv( + raise orm.except_orm( _("Error"), _("The voucher's move line could not be posted.")) if not self.pool.get('res.currency').is_zero( cr, uid, voucher_currency, instant.balance): - raise osv.except_osv( + raise orm.except_orm( _("Error"), _("The amount on the bank statement line needs to be the " "same as on the voucher. Write-off is not yet " @@ -245,7 +245,7 @@ class instant_voucher(osv.TransientModel): # and trigger its posting and reconciliation. if 'import_transaction_id' in statement_line_obj._columns: if instant.statement_line_id.state == 'confirmed': - raise osv.except_osv( + raise orm.except_orm( _("Error"), _("Cannot match a confirmed statement line")) if not instant.statement_line_id.import_transaction_id: