From 6c16849eb2aacfbb2b403e3d39597930d389c61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faure-Lacroix?= Date: Thu, 2 Apr 2015 22:55:17 +0300 Subject: [PATCH] Moved models in folder and splitted account_banking_reconciliation.py --- account_banking_reconciliation/__init__.py | 3 +- .../models/__init__.py | 3 + .../{ => models}/account_move_line.py | 0 .../models/bank_acc_rec_satetement_line.py | 139 ++++++++++++++++++ .../bank_acc_rec_statement.py} | 115 --------------- 5 files changed, 143 insertions(+), 117 deletions(-) create mode 100644 account_banking_reconciliation/models/__init__.py rename account_banking_reconciliation/{ => models}/account_move_line.py (100%) create mode 100644 account_banking_reconciliation/models/bank_acc_rec_satetement_line.py rename account_banking_reconciliation/{account_banking_reconciliation.py => models/bank_acc_rec_statement.py} (92%) diff --git a/account_banking_reconciliation/__init__.py b/account_banking_reconciliation/__init__.py index 38baff3d1..bebdb69cd 100644 --- a/account_banking_reconciliation/__init__.py +++ b/account_banking_reconciliation/__init__.py @@ -19,6 +19,5 @@ # along with this program. If not, see # ############################################################################## -from . import account_banking_reconciliation -from . import account_move_line from . import report +from . import models diff --git a/account_banking_reconciliation/models/__init__.py b/account_banking_reconciliation/models/__init__.py new file mode 100644 index 000000000..15a406a95 --- /dev/null +++ b/account_banking_reconciliation/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_move_line +from . import bank_acc_rec_satetement_line +from . import bank_acc_rec_statement diff --git a/account_banking_reconciliation/account_move_line.py b/account_banking_reconciliation/models/account_move_line.py similarity index 100% rename from account_banking_reconciliation/account_move_line.py rename to account_banking_reconciliation/models/account_move_line.py diff --git a/account_banking_reconciliation/models/bank_acc_rec_satetement_line.py b/account_banking_reconciliation/models/bank_acc_rec_satetement_line.py new file mode 100644 index 000000000..d812c64c1 --- /dev/null +++ b/account_banking_reconciliation/models/bank_acc_rec_satetement_line.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 NovaPoint Group LLC () +# Copyright (C) 2004-2010 OpenERP SA () +# +# 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. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# +############################################################################## +from openerp.osv import fields, orm +from openerp.tools.translate import _ +import openerp.addons.decimal_precision as dp + + +class bank_acc_rec_statement_line(orm.Model): + _name = "bank.acc.rec.statement.line" + _description = "Statement Line" + _columns = { + 'name': fields.char( + 'Name', + size=64, + help="Derived from the related Journal Item.", + required=True + ), + 'ref': fields.char( + 'Reference', + size=64, + help="Derived from related Journal Item." + ), + 'partner_id': fields.many2one( + 'res.partner', + string='Partner', + help="Derived from related Journal Item." + ), + 'amount': fields.float( + 'Amount', + digits_compute=dp.get_precision('Account'), + help="Derived from the 'debit' amount from related Journal Item." + ), + 'amount_in_currency': fields.float( + 'Amount in Currency', + digits_compute=dp.get_precision('Account'), + help="Amount in currency from the related Journal Item." + ), + 'date': fields.date( + 'Date', + required=True, + help="Derived from related Journal Item." + ), + 'statement_id': fields.many2one( + 'bank.acc.rec.statement', + 'Statement', + required=True, + ondelete='cascade' + ), + 'move_line_id': fields.many2one( + 'account.move.line', + 'Journal Item', + help="Related Journal Item." + ), + 'cleared_bank_account': fields.boolean( + 'Cleared? ', + help='Check if the transaction has cleared from the bank' + ), + 'research_required': fields.boolean( + 'Research Required? ', + help=( + 'Check if the transaction should be researched by ' + 'Accounting personal' + ), + ), + 'currency_id': fields.many2one( + 'res.currency', + 'Currency', + help="The optional other currency if it is a multi-currency entry." + ), + 'type': fields.selection( + [ + ('dr', 'Debit'), + ('cr', 'Credit') + ], + 'Cr/Dr' + ), + } + + def create(self, cr, uid, vals, context=None): + account_move_line_obj = self.pool.get('account.move.line') + # Prevent manually adding new statement line. + # This would allow only onchange method to pre-populate + # statement lines based on the filter rules. + if not vals.get('move_line_id', False): + raise orm.except_orm( + _('Processing Error'), + _('You cannot add any new bank statement line ' + 'manually as of this revision!') + ) + account_move_line_obj.write( + cr, uid, + [vals['move_line_id']], + {'draft_assigned_to_statement': True}, + context=context + ) + return super(bank_acc_rec_statement_line, self).create( + cr, uid, vals, context=context + ) + + def unlink(self, cr, uid, ids, context=None): + account_move_line_obj = self.pool.get('account.move.line') + move_line_ids = [ + line.move_line_id.id + for line in self.browse(cr, uid, ids, context=context) + if line.move_line_id + ] + # Reset field values in move lines to be added later + account_move_line_obj.write( + cr, uid, + move_line_ids, + { + 'draft_assigned_to_statement': False, + 'cleared_bank_account': False, + 'bank_acc_rec_statement_id': False, + }, + context=context + ) + return super(bank_acc_rec_statement_line, self).unlink( + cr, uid, ids, context=context + ) diff --git a/account_banking_reconciliation/account_banking_reconciliation.py b/account_banking_reconciliation/models/bank_acc_rec_statement.py similarity index 92% rename from account_banking_reconciliation/account_banking_reconciliation.py rename to account_banking_reconciliation/models/bank_acc_rec_statement.py index 30097fa92..1d2fbcd3c 100644 --- a/account_banking_reconciliation/account_banking_reconciliation.py +++ b/account_banking_reconciliation/models/bank_acc_rec_statement.py @@ -1110,118 +1110,3 @@ class bank_acc_rec_statement(orm.Model): ) ) ] - - -class bank_acc_rec_statement_line(orm.Model): - _name = "bank.acc.rec.statement.line" - _description = "Statement Line" - _columns = { - 'name': fields.char( - 'Name', - size=64, - help="Derived from the related Journal Item.", - required=True - ), - 'ref': fields.char( - 'Reference', - size=64, - help="Derived from related Journal Item." - ), - 'partner_id': fields.many2one( - 'res.partner', - string='Partner', - help="Derived from related Journal Item." - ), - 'amount': fields.float( - 'Amount', - digits_compute=dp.get_precision('Account'), - help="Derived from the 'debit' amount from related Journal Item." - ), - 'amount_in_currency': fields.float( - 'Amount in Currency', - digits_compute=dp.get_precision('Account'), - help="Amount in currency from the related Journal Item." - ), - 'date': fields.date( - 'Date', - required=True, - help="Derived from related Journal Item." - ), - 'statement_id': fields.many2one( - 'bank.acc.rec.statement', - 'Statement', - required=True, - ondelete='cascade' - ), - 'move_line_id': fields.many2one( - 'account.move.line', - 'Journal Item', - help="Related Journal Item." - ), - 'cleared_bank_account': fields.boolean( - 'Cleared? ', - help='Check if the transaction has cleared from the bank' - ), - 'research_required': fields.boolean( - 'Research Required? ', - help=( - 'Check if the transaction should be researched by ' - 'Accounting personal' - ), - ), - 'currency_id': fields.many2one( - 'res.currency', - 'Currency', - help="The optional other currency if it is a multi-currency entry." - ), - 'type': fields.selection( - [ - ('dr', 'Debit'), - ('cr', 'Credit') - ], - 'Cr/Dr' - ), - } - - def create(self, cr, uid, vals, context=None): - account_move_line_obj = self.pool.get('account.move.line') - # Prevent manually adding new statement line. - # This would allow only onchange method to pre-populate - # statement lines based on the filter rules. - if not vals.get('move_line_id', False): - raise orm.except_orm( - _('Processing Error'), - _('You cannot add any new bank statement line ' - 'manually as of this revision!') - ) - account_move_line_obj.write( - cr, uid, - [vals['move_line_id']], - {'draft_assigned_to_statement': True}, - context=context - ) - return super(bank_acc_rec_statement_line, self).create( - cr, uid, vals, context=context - ) - - def unlink(self, cr, uid, ids, context=None): - account_move_line_obj = self.pool.get('account.move.line') - move_line_ids = [ - line.move_line_id.id - for line in self.browse(cr, uid, ids, context=context) - if line.move_line_id - ] - # Reset field values in move lines to be added later - account_move_line_obj.write( - cr, uid, - move_line_ids, - { - 'draft_assigned_to_statement': False, - 'cleared_bank_account': False, - 'bank_acc_rec_statement_id': False, - }, - context=context - ) - return super(bank_acc_rec_statement_line, self).unlink( - cr, uid, ids, context=context - )