From 8484817f51b75981de64a2e234ee4f8fb5f1932f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faure-Lacroix?= Date: Thu, 2 Apr 2015 19:46:40 +0300 Subject: [PATCH] Splitted models/account_banking_make_deposit.py by models --- .../models/__init__.py | 4 +- .../models/deposit_method.py | 34 ++++++ ...king_make_deposit.py => deposit_ticket.py} | 98 ---------------- .../models/deposit_ticket_line.py | 110 ++++++++++++++++++ 4 files changed, 147 insertions(+), 99 deletions(-) create mode 100644 account_banking_make_deposit/models/deposit_method.py rename account_banking_make_deposit/models/{account_banking_make_deposit.py => deposit_ticket.py} (83%) create mode 100644 account_banking_make_deposit/models/deposit_ticket_line.py diff --git a/account_banking_make_deposit/models/__init__.py b/account_banking_make_deposit/models/__init__.py index e94e05883..fe185cca8 100644 --- a/account_banking_make_deposit/models/__init__.py +++ b/account_banking_make_deposit/models/__init__.py @@ -19,5 +19,7 @@ # along with this program. If not, see # ############################################################################## -from . import account_banking_make_deposit +from . import deposit_ticket +from . import deposit_ticket_line +from . import deposit_method from . import account_move_line diff --git a/account_banking_make_deposit/models/deposit_method.py b/account_banking_make_deposit/models/deposit_method.py new file mode 100644 index 000000000..8e0adbb1f --- /dev/null +++ b/account_banking_make_deposit/models/deposit_method.py @@ -0,0 +1,34 @@ +# -*- 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 + + +class deposit_method(orm.Model): + _name = "deposit.method" + _description = "Deposit Method" + _columns = { + 'name': fields.char( + 'Name', size=64, + required=True, + help='Name of the method used for deposit' + ) + } diff --git a/account_banking_make_deposit/models/account_banking_make_deposit.py b/account_banking_make_deposit/models/deposit_ticket.py similarity index 83% rename from account_banking_make_deposit/models/account_banking_make_deposit.py rename to account_banking_make_deposit/models/deposit_ticket.py index bf37b6d30..7536f13fb 100644 --- a/account_banking_make_deposit/models/account_banking_make_deposit.py +++ b/account_banking_make_deposit/models/deposit_ticket.py @@ -26,18 +26,6 @@ from openerp.tools.translate import _ import decimal_precision as dp -class deposit_method(orm.Model): - _name = "deposit.method" - _description = "Deposit Method" - _columns = { - 'name': fields.char( - 'Name', size=64, - required=True, - help='Name of the method used for deposit' - ) - } - - class deposit_ticket(orm.Model): _name = "deposit.ticket" _description = "Deposit Ticket" @@ -437,89 +425,3 @@ class deposit_ticket(orm.Model): 'domain': '[]', 'context': dict(context, active_ids=ids) } - - -class deposit_ticket_line(orm.Model): - _name = "deposit.ticket.line" - _description = "Deposit Ticket Line" - _columns = { - 'name': fields.char( - 'Name', - size=64, - required=True, - help="Derived from the related Journal Item." - ), - '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." - ), - 'date': fields.date( - 'Date', - required=True, - help="Derived from related Journal Item." - ), - 'deposit_id': fields.many2one( - 'deposit.ticket', - 'Deposit Ticket', - required=True, - ondelete='cascade' - ), - 'company_id': fields.related( - 'deposit_id', - 'company_id', - type='many2one', - relation='res.company', - string='Company', - readonly=True, - help="Derived from related Journal Item." - ), - 'move_line_id': fields.many2one( - 'account.move.line', - 'Journal Item', - help="Related Journal Item." - ), - } - - def create(self, cr, uid, vals, context=None): - # Any Line cannot be manually added. Use the wizard to add lines. - if not vals.get('move_line_id', False): - raise orm.except_orm( - _('Processing Error'), - _( - 'You cannot add any new deposit ticket line ' - 'manually as of this revision! ' - 'Please use the button \"Add Deposit ' - 'Items\" to add deposit ticket line!' - ) - ) - return super(deposit_ticket_line, self).create( - cr, uid, vals, context=context - ) - - def unlink(self, cr, uid, ids, context=None): - """ - Set the 'draft_assigned' field to False for related account move - lines to allow to be entered for another deposit. - """ - 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) - ] - account_move_line_obj.write( - cr, uid, move_line_ids, {'draft_assigned': False}, context=context - ) - return super(deposit_ticket_line, self).unlink( - cr, uid, ids, context=context - ) diff --git a/account_banking_make_deposit/models/deposit_ticket_line.py b/account_banking_make_deposit/models/deposit_ticket_line.py new file mode 100644 index 000000000..76579900a --- /dev/null +++ b/account_banking_make_deposit/models/deposit_ticket_line.py @@ -0,0 +1,110 @@ +# -*- 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 decimal_precision as dp + + +class deposit_ticket_line(orm.Model): + _name = "deposit.ticket.line" + _description = "Deposit Ticket Line" + _columns = { + 'name': fields.char( + 'Name', + size=64, + required=True, + help="Derived from the related Journal Item." + ), + '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." + ), + 'date': fields.date( + 'Date', + required=True, + help="Derived from related Journal Item." + ), + 'deposit_id': fields.many2one( + 'deposit.ticket', + 'Deposit Ticket', + required=True, + ondelete='cascade' + ), + 'company_id': fields.related( + 'deposit_id', + 'company_id', + type='many2one', + relation='res.company', + string='Company', + readonly=True, + help="Derived from related Journal Item." + ), + 'move_line_id': fields.many2one( + 'account.move.line', + 'Journal Item', + help="Related Journal Item." + ), + } + + def create(self, cr, uid, vals, context=None): + # Any Line cannot be manually added. Use the wizard to add lines. + if not vals.get('move_line_id', False): + raise orm.except_orm( + _('Processing Error'), + _( + 'You cannot add any new deposit ticket line ' + 'manually as of this revision! ' + 'Please use the button \"Add Deposit ' + 'Items\" to add deposit ticket line!' + ) + ) + return super(deposit_ticket_line, self).create( + cr, uid, vals, context=context + ) + + def unlink(self, cr, uid, ids, context=None): + """ + Set the 'draft_assigned' field to False for related account move + lines to allow to be entered for another deposit. + """ + 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) + ] + account_move_line_obj.write( + cr, uid, move_line_ids, {'draft_assigned': False}, context=context + ) + return super(deposit_ticket_line, self).unlink( + cr, uid, ids, context=context + )