From 193a59235786529762ccd8be248a53035ae906f4 Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Fri, 21 Dec 2012 11:10:19 +0100 Subject: [PATCH 01/26] [INIT] init module to manage check deposits --- account_check_deposit/__init__.py | 28 ++++ account_check_deposit/__openerp__.py | 46 +++++++ account_check_deposit/account_deposit.py | 130 ++++++++++++++++++ .../account_deposit_sequence.xml | 26 ++++ .../account_deposit_view.xml | 73 ++++++++++ account_check_deposit/account_type_data.xml | 20 +++ 6 files changed, 323 insertions(+) create mode 100644 account_check_deposit/__init__.py create mode 100644 account_check_deposit/__openerp__.py create mode 100644 account_check_deposit/account_deposit.py create mode 100644 account_check_deposit/account_deposit_sequence.xml create mode 100644 account_check_deposit/account_deposit_view.xml create mode 100644 account_check_deposit/account_type_data.xml diff --git a/account_check_deposit/__init__.py b/account_check_deposit/__init__.py new file mode 100644 index 000000000..d4de023a5 --- /dev/null +++ b/account_check_deposit/__init__.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# # +# account_check_deposit for OpenERP # +# Copyright (C) 2012 Akretion Benoît GUILLOT # +# # +# 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 . # +# # +############################################################################### + + + +import account_deposit + + + + diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py new file mode 100644 index 000000000..4ed1f644e --- /dev/null +++ b/account_check_deposit/__openerp__.py @@ -0,0 +1,46 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# # +# account_check_deposit for OpenERP # +# Copyright (C) 2012 Akretion Benoît GUILLOT # +# # +# 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 . # +# # +############################################################################### + + + +{ + 'name': 'account_check_deposit', + 'version': '7.1', + 'category': 'Generic Modules/Others', + 'license': 'AGPL-3', + 'description': """This module allows you to use check deposits. + With a new model : account_check_deposit you can select all + the checks payments and create a global deposit for the selected checks. + You may have to create an account for recieved checks and a journal for payment by checks.""", + 'author': 'Akretion', + 'website': 'http://www.akretion.com/', + 'depends': ['account'], + 'init_xml': [], + 'update_xml': [ + 'account_deposit_view.xml', + 'account_deposit_sequence.xml', + 'account_type_data.xml', + ], + 'demo_xml': [], + 'installable': True, + 'active': False, +} + diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py new file mode 100644 index 000000000..bd8828e52 --- /dev/null +++ b/account_check_deposit/account_deposit.py @@ -0,0 +1,130 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# # +# account_check_deposit for OpenERP # +# Copyright (C) 2012 Akretion Benoît GUILLOT # +# # +# 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 . # +# # +############################################################################### + +from openerp.osv import fields +from openerp.osv.orm import Model + +class account_check_deposit(Model): + _name = "account.check.deposit" + _description = "Account Check Deposit" + + _columns = { + 'name': fields.char('Name', size=64, required=True), + 'check_payment_ids': fields.one2many('account.move.line', 'check_deposit_id', 'Check Payments'), + 'deposit_date': fields.date('Deposit Date'), + 'journal_id': fields.many2one('account.journal', 'Journal', required=True), + } + + _defaults = { + 'name': lambda self, cr, uid, context: '/', + 'deposit_date': fields.date.context_today, + } + + def create(self, cr, uid, vals, context=None): + if vals.get('name','/')=='/': + vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'account.check.deposit') or '/' + return super(account_check_deposit, self).create(cr, uid, vals, context=context) + + def _get_check_payment_ids(self, cr, uid, ids, context=None): + model, type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, "account_check_deposit", + "data_account_type_received_check") + account_ids = self.pool.get('account.account').search(cr, uid, [('user_type', '=', type_id)], context=context) + check_payment_ids = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', account_ids), + ('reconcile_id', '=', False)], + context=context) + return check_payment_ids + + def get_check_payments(self, cr, uid, ids, context=None): + move_line_obj = self.pool.get('account.move.line') + check_payment_ids = self._get_check_payment_ids(cr, uid, ids, context=context) + move_line_obj.write(cr, uid, check_payment_ids, {'check_deposit_id': ids[0]}, context=context) + return True + + def _prepare_account_move_vals(self, cr, uid, deposit, context=None): + move_vals = {} + move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, move_vals, context=context)]] + for line in deposit.check_payment_ids: + move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)]) + move_vals.update({ + 'journal_id': deposit.journal_id.id, + 'line_id': move_lines, + }) + return move_vals + + def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): + move_line_vals = self.pool.get('account.move.line').default_get(cr, uid, + ['centralisation', 'date','date_created', + 'currency_id', 'journal_id', 'amount_currency', + 'account_id', 'period_id', 'company_id'], + context=context) + move_line_vals.update({ + 'name': line.ref, #name ? + 'credit': line.debit, + 'account_id': line.account_id.id, + }) + move_lines_vals.append(move_line_vals) + return move_line_vals + + def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): + move_line_vals = self.pool.get('account.move.line').default_get(cr, uid, + ['centralisation', 'date','date_created', + 'currency_id', 'journal_id', 'amount_currency', + 'account_id', 'period_id', 'company_id', 'state'], + context=context) + debit = 0.0 + for line in deposit.check_payment_ids: + debit += line.debit + move_line_vals.update({ + 'name': deposit.name, + 'debit': debit, + }) + + return move_line_vals + + def _reconcile_checks(cr, uid, deposit, move_id, context=None): + move_line_obj = self.pool.get('account.move.line') + for line in deposit.check_payment_ids: + move_line_ids = move_line_obj.search(cr, uid, [('move_id', '=', move_id), + ('credit', '=', line.debit), + ('name', '=', line.ref)], context=context) + if move_line_ids: + move_line_obj.reconcile(cr, uid, [line.id, move_line_ids[0]], context=context) + return True + + def validate_deposit(self, cr, uid, ids, context=None): + if context is None: + context = {} + for deposit in self.browse(cr, uid, ids, context=context): + context['journal_id'] = deposit.journal_id.id + move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) + print "move_vals ====>", move_vals + import pdb; pdb.set_trace() + move_id = self.pool.get('account.move').create(cr, uid, move_vals, context=context) + self.post(cr, uid, [move_id], context=context) + self._reconcile_checks(cr, uid, deposit, move_id, context=context) + return True + +class account_move_line(Model): + _inherit = "account.move.line" + + _columns = { + 'check_deposit_id': fields.many2one('account.check.deposit', 'Check Deposit', ondelete="restrict"), + } diff --git a/account_check_deposit/account_deposit_sequence.xml b/account_check_deposit/account_deposit_sequence.xml new file mode 100644 index 000000000..2208a5dbe --- /dev/null +++ b/account_check_deposit/account_deposit_sequence.xml @@ -0,0 +1,26 @@ + + + + + + + + + Account Check Deposit + account.check.deposit + + + + Account Check Deposit + account.check.deposit + DEP + 3 + + + + + diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml new file mode 100644 index 000000000..eb0945c07 --- /dev/null +++ b/account_check_deposit/account_deposit_view.xml @@ -0,0 +1,73 @@ + + + + + + + + + + account_check_deposit.account_check_deposit.view_form + account.check.deposit + form + +
+
+
+ + + + + + + +
+
+
+ + + account_check_deposit.account_check_deposit.view_tree + account.check.deposit + tree + + + + + + + + + + account.check.deposit.search + account.check.deposit + + + + + + + + + + + + Check Deposits + account.check.deposit + form + tree,form,graph + [] + {} + + + + + + +
+
diff --git a/account_check_deposit/account_type_data.xml b/account_check_deposit/account_type_data.xml new file mode 100644 index 000000000..1d34fc717 --- /dev/null +++ b/account_check_deposit/account_type_data.xml @@ -0,0 +1,20 @@ + + + + + + + + + + Recieved Checks + recieved_check + none + + + + From f2eec48063edb742f608d6f6fc9a65c8be979b93 Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Fri, 21 Dec 2012 16:52:25 +0100 Subject: [PATCH 02/26] [IMP] improve module and fix bugs --- account_check_deposit/__init__.py | 2 +- account_check_deposit/__openerp__.py | 6 +- account_check_deposit/account_deposit.py | 64 +++++++++++-------- .../account_deposit_view.xml | 41 ++++++++++-- 4 files changed, 77 insertions(+), 36 deletions(-) diff --git a/account_check_deposit/__init__.py b/account_check_deposit/__init__.py index d4de023a5..d0334331b 100644 --- a/account_check_deposit/__init__.py +++ b/account_check_deposit/__init__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################### # # # account_check_deposit for OpenERP # diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 4ed1f644e..ffbee2c21 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################### # # # account_check_deposit for OpenERP # @@ -23,7 +23,7 @@ { 'name': 'account_check_deposit', - 'version': '7.1', + 'version': '7.0', 'category': 'Generic Modules/Others', 'license': 'AGPL-3', 'description': """This module allows you to use check deposits. @@ -32,7 +32,7 @@ You may have to create an account for recieved checks and a journal for payment by checks.""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': ['account'], + 'depends': ['account_accountant'], 'init_xml': [], 'update_xml': [ 'account_deposit_view.xml', diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index bd8828e52..9643a2a6e 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################### # # # account_check_deposit for OpenERP # @@ -19,45 +19,52 @@ # # ############################################################################### -from openerp.osv import fields +from openerp.osv import fields, osv from openerp.osv.orm import Model +from openerp.tools.translate import _ class account_check_deposit(Model): _name = "account.check.deposit" _description = "Account Check Deposit" _columns = { - 'name': fields.char('Name', size=64, required=True), - 'check_payment_ids': fields.one2many('account.move.line', 'check_deposit_id', 'Check Payments'), - 'deposit_date': fields.date('Deposit Date'), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True), + 'name': fields.char('Name', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}), + 'check_payment_ids': fields.many2many('account.move.line', 'account_move_line_deposit_rel', + 'check_deposit_id', 'move_line_id', 'Check Payments', + readonly=True, states={'draft':[('readonly',False)]}), + 'deposit_date': fields.date('Deposit Date', readonly=True, states={'draft':[('readonly',False)]}), + 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, + states={'draft':[('readonly',False)]}), + 'state': fields.selection([ + ('draft','Draft'), + ('done','Done'), + ('cancel','Cancelled') + ],'Status', readonly=True), + 'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, + states={'draft':[('readonly',False)]}), } _defaults = { 'name': lambda self, cr, uid, context: '/', 'deposit_date': fields.date.context_today, + 'state':'draft', } + def cancel(self, cr, uid, ids, context=None): + for deposit in self.browse(cr, uid, ids, context=context): + if not deposit.journal_id.update_posted: + raise osv.except_osv(_('Error!'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) + for line in deposit.check_payment_ids: + line.reconcile_id.unlink() + deposit.move_id.button_cancel() + deposit.move_id.unlink() + return True + def create(self, cr, uid, vals, context=None): if vals.get('name','/')=='/': vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'account.check.deposit') or '/' return super(account_check_deposit, self).create(cr, uid, vals, context=context) - def _get_check_payment_ids(self, cr, uid, ids, context=None): - model, type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, "account_check_deposit", - "data_account_type_received_check") - account_ids = self.pool.get('account.account').search(cr, uid, [('user_type', '=', type_id)], context=context) - check_payment_ids = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', account_ids), - ('reconcile_id', '=', False)], - context=context) - return check_payment_ids - - def get_check_payments(self, cr, uid, ids, context=None): - move_line_obj = self.pool.get('account.move.line') - check_payment_ids = self._get_check_payment_ids(cr, uid, ids, context=context) - move_line_obj.write(cr, uid, check_payment_ids, {'check_deposit_id': ids[0]}, context=context) - return True - def _prepare_account_move_vals(self, cr, uid, deposit, context=None): move_vals = {} move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, move_vals, context=context)]] @@ -79,8 +86,9 @@ class account_check_deposit(Model): 'name': line.ref, #name ? 'credit': line.debit, 'account_id': line.account_id.id, + 'partner_id': line.partner_id.id, + 'ref': line.ref, }) - move_lines_vals.append(move_line_vals) return move_line_vals def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): @@ -95,11 +103,12 @@ class account_check_deposit(Model): move_line_vals.update({ 'name': deposit.name, 'debit': debit, + 'ref': deposit.name, }) return move_line_vals - def _reconcile_checks(cr, uid, deposit, move_id, context=None): + def _reconcile_checks(self, cr, uid, deposit, move_id, context=None): move_line_obj = self.pool.get('account.move.line') for line in deposit.check_payment_ids: move_line_ids = move_line_obj.search(cr, uid, [('move_id', '=', move_id), @@ -110,6 +119,7 @@ class account_check_deposit(Model): return True def validate_deposit(self, cr, uid, ids, context=None): + move_obj = self.pool.get('account.move') if context is None: context = {} for deposit in self.browse(cr, uid, ids, context=context): @@ -117,14 +127,16 @@ class account_check_deposit(Model): move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) print "move_vals ====>", move_vals import pdb; pdb.set_trace() - move_id = self.pool.get('account.move').create(cr, uid, move_vals, context=context) - self.post(cr, uid, [move_id], context=context) + move_id = move_obj.create(cr, uid, move_vals, context=context) + move_obj.post(cr, uid, [move_id], context=context) self._reconcile_checks(cr, uid, deposit, move_id, context=context) + deposit.write({'state':'done', 'move_id': move_id}) return True class account_move_line(Model): _inherit = "account.move.line" _columns = { - 'check_deposit_id': fields.many2one('account.check.deposit', 'Check Deposit', ondelete="restrict"), + 'check_deposit_id': fields.many2many('account.check.deposit', 'account_move_line_deposit_rel', + 'check_deposit_id', 'move_line_id', 'Check Deposit'), } diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index eb0945c07..10cc6cdd4 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -17,15 +17,40 @@
-
- - - +

+

+ + + + + - + + + + + + + + + + + + + + +
@@ -39,6 +64,8 @@ + + @@ -50,6 +77,8 @@ + + From 6df43c453fd100797ca7f9467f8da5e4035dc755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Beau?= Date: Fri, 28 Dec 2012 17:03:22 +0100 Subject: [PATCH 03/26] [FIX] fix remove pdb call --- account_check_deposit/account_deposit.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 9643a2a6e..3e2b21100 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -125,8 +125,6 @@ class account_check_deposit(Model): for deposit in self.browse(cr, uid, ids, context=context): context['journal_id'] = deposit.journal_id.id move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) - print "move_vals ====>", move_vals - import pdb; pdb.set_trace() move_id = move_obj.create(cr, uid, move_vals, context=context) move_obj.post(cr, uid, [move_id], context=context) self._reconcile_checks(cr, uid, deposit, move_id, context=context) From f705a6b026710ec782cabbc39b3a03bc6d19ea49 Mon Sep 17 00:00:00 2001 From: Delli Chafique Date: Thu, 21 Feb 2013 12:37:06 +0100 Subject: [PATCH 04/26] [IMP]account_check_deposit: add the print option webkit --- account_check_deposit/__openerp__.py | 3 +- account_check_deposit/account_deposit.py | 43 +++++++++++++------ .../account_deposit_view.xml | 11 ++++- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index ffbee2c21..1392bdc76 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -3,6 +3,7 @@ # # # account_check_deposit for OpenERP # # Copyright (C) 2012 Akretion Benoît GUILLOT # +# Copyright (C) 2013 Akretion Chafique DELLI # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as # @@ -32,7 +33,7 @@ You may have to create an account for recieved checks and a journal for payment by checks.""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': ['account_accountant'], + 'depends': ['account_accountant','report_webkit'], 'init_xml': [], 'update_xml': [ 'account_deposit_view.xml', diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 3e2b21100..8865d6078 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -3,6 +3,7 @@ # # # account_check_deposit for OpenERP # # Copyright (C) 2012 Akretion Benoît GUILLOT # +# Copyright (C) 2013 Akretion Chafique DELLI # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as # @@ -27,6 +28,16 @@ class account_check_deposit(Model): _name = "account.check.deposit" _description = "Account Check Deposit" + def sum_amount(self, cr, uid, ids, name, args, context=None): + res = {} + total = 0 + for deposit in self.browse(cr, uid, ids, context=context): + for line in deposit.check_payment_ids: + total += line.debit + res[deposit.id]= total + return res + + _columns = { 'name': fields.char('Name', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}), 'check_payment_ids': fields.many2many('account.move.line', 'account_move_line_deposit_rel', @@ -42,14 +53,17 @@ class account_check_deposit(Model): ],'Status', readonly=True), 'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, states={'draft':[('readonly',False)]}), + 'total_amount': fields.function(sum_amount, string ="total amount"), } - + _defaults = { 'name': lambda self, cr, uid, context: '/', 'deposit_date': fields.date.context_today, 'state':'draft', } - + + + def cancel(self, cr, uid, ids, context=None): for deposit in self.browse(cr, uid, ids, context=context): if not deposit.journal_id.update_posted: @@ -59,23 +73,23 @@ class account_check_deposit(Model): deposit.move_id.button_cancel() deposit.move_id.unlink() return True - + def create(self, cr, uid, vals, context=None): if vals.get('name','/')=='/': vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'account.check.deposit') or '/' return super(account_check_deposit, self).create(cr, uid, vals, context=context) - + def _prepare_account_move_vals(self, cr, uid, deposit, context=None): move_vals = {} move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, move_vals, context=context)]] for line in deposit.check_payment_ids: - move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)]) + move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)]) move_vals.update({ 'journal_id': deposit.journal_id.id, 'line_id': move_lines, }) return move_vals - + def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): move_line_vals = self.pool.get('account.move.line').default_get(cr, uid, ['centralisation', 'date','date_created', @@ -83,20 +97,21 @@ class account_check_deposit(Model): 'account_id', 'period_id', 'company_id'], context=context) move_line_vals.update({ - 'name': line.ref, #name ? + 'name': line.name, 'credit': line.debit, 'account_id': line.account_id.id, 'partner_id': line.partner_id.id, 'ref': line.ref, }) return move_line_vals - + def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): move_line_vals = self.pool.get('account.move.line').default_get(cr, uid, ['centralisation', 'date','date_created', 'currency_id', 'journal_id', 'amount_currency', 'account_id', 'period_id', 'company_id', 'state'], context=context) + debit = 0.0 for line in deposit.check_payment_ids: debit += line.debit @@ -105,9 +120,9 @@ class account_check_deposit(Model): 'debit': debit, 'ref': deposit.name, }) - + return move_line_vals - + def _reconcile_checks(self, cr, uid, deposit, move_id, context=None): move_line_obj = self.pool.get('account.move.line') for line in deposit.check_payment_ids: @@ -117,7 +132,7 @@ class account_check_deposit(Model): if move_line_ids: move_line_obj.reconcile(cr, uid, [line.id, move_line_ids[0]], context=context) return True - + def validate_deposit(self, cr, uid, ids, context=None): move_obj = self.pool.get('account.move') if context is None: @@ -125,15 +140,17 @@ class account_check_deposit(Model): for deposit in self.browse(cr, uid, ids, context=context): context['journal_id'] = deposit.journal_id.id move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) + print "move_vals ====>", move_vals move_id = move_obj.create(cr, uid, move_vals, context=context) move_obj.post(cr, uid, [move_id], context=context) self._reconcile_checks(cr, uid, deposit, move_id, context=context) deposit.write({'state':'done', 'move_id': move_id}) return True - + + class account_move_line(Model): _inherit = "account.move.line" - + _columns = { 'check_deposit_id': fields.many2many('account.check.deposit', 'account_move_line_deposit_rel', 'check_deposit_id', 'move_line_id', 'Check Deposit'), diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index 10cc6cdd4..d619b127a 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -2,12 +2,21 @@ - + + From 2113099784b33499b36f2213a7416affd0d9925d Mon Sep 17 00:00:00 2001 From: Delli Chafique Date: Thu, 21 Feb 2013 14:11:40 +0100 Subject: [PATCH 05/26] [IMP]account_check_deposit: customization webkit --- account_check_deposit/__openerp__.py | 5 ++-- account_check_deposit/account_deposit.py | 17 ++++++++++++ .../account_deposit_view.xml | 27 ++++++++++--------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 1392bdc76..5fdfa4610 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -33,9 +33,9 @@ You may have to create an account for recieved checks and a journal for payment by checks.""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': ['account_accountant','report_webkit'], + 'depends': ['account_accountant','report_webkit','sale_quick_payment'], 'init_xml': [], - 'update_xml': [ + 'update_xml': [ 'account_deposit_view.xml', 'account_deposit_sequence.xml', 'account_type_data.xml', @@ -44,4 +44,3 @@ 'installable': True, 'active': False, } - diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 8865d6078..81dfdb72e 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -53,6 +53,11 @@ class account_check_deposit(Model): ],'Status', readonly=True), 'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, states={'draft':[('readonly',False)]}), + 'bank_id': fields.many2one('res.partner.bank', 'Bank', required=True, readonly=True, + domain="[('partner_id', '=', partner_id)]", + states={'draft':[('readonly',False)]}), + 'partner_id':fields.related('company_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", readonly=True), + 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}), 'total_amount': fields.function(sum_amount, string ="total amount"), } @@ -60,6 +65,7 @@ class account_check_deposit(Model): 'name': lambda self, cr, uid, context: '/', 'deposit_date': fields.date.context_today, 'state':'draft', + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.check.deposit', context=c), } @@ -133,6 +139,17 @@ class account_check_deposit(Model): move_line_obj.reconcile(cr, uid, [line.id, move_line_ids[0]], context=context) return True + + + def onchange_company_id(self, cr, uid, ids, company_id, context=None): + vals={} + if company_id: + company=self.pool.get('res.company').browse(cr, uid, company_id, context=context) + vals['partner_id']=company.partner_id.id + return {'value':vals} + + + def validate_deposit(self, cr, uid, ids, context=None): move_obj = self.pool.get('account.move') if context is None: diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index d619b127a..856dbbd5b 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -15,8 +15,8 @@ model="account.check.deposit" name="check.deposit.webkit" report_type="webkit" - string="WebKit Check Deposit"/> - + string="WebKit Checks Deposit"/> + @@ -24,7 +24,7 @@ account.check.deposit form -
+

-

+ + + - + @@ -70,7 +73,7 @@ account.check.deposit tree - + @@ -78,13 +81,13 @@ - + account.check.deposit.search account.check.deposit - - + + @@ -93,9 +96,9 @@ - + - Check Deposits + Checks Deposit account.check.deposit form tree,form,graph @@ -105,7 +108,7 @@ - + From 71fadbc2aba6a8701cf61bf4900ae968904f3dbd Mon Sep 17 00:00:00 2001 From: Delli Chafique Date: Thu, 11 Apr 2013 13:33:21 +0200 Subject: [PATCH 06/26] [ADD] add webkit for check deposit --- .../i18n/account_check_deposit.pot | 236 +++++++++++++++ account_check_deposit/i18n/fr.po | 236 +++++++++++++++ account_check_deposit/report/.directory | 6 + account_check_deposit/report/.mako | 275 ++++++++++++++++++ account_check_deposit/report/__init__.py | 32 ++ .../report/check_deposit.mako | 112 +++++++ .../report/report_webkit_html.py | 40 +++ 7 files changed, 937 insertions(+) create mode 100644 account_check_deposit/i18n/account_check_deposit.pot create mode 100644 account_check_deposit/i18n/fr.po create mode 100644 account_check_deposit/report/.directory create mode 100644 account_check_deposit/report/.mako create mode 100644 account_check_deposit/report/__init__.py create mode 100644 account_check_deposit/report/check_deposit.mako create mode 100644 account_check_deposit/report/report_webkit_html.py diff --git a/account_check_deposit/i18n/account_check_deposit.pot b/account_check_deposit/i18n/account_check_deposit.pot new file mode 100644 index 000000000..f54d138c7 --- /dev/null +++ b/account_check_deposit/i18n/account_check_deposit.pot @@ -0,0 +1,236 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_check_deposit +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-21 10:01+0000\n" +"PO-Revision-Date: 2013-02-21 10:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_check_deposit +#: code:addons/account_check_deposit/account_deposit.py:76 +#, python-format +msgid "You cannot modify a posted entry of this journal.\n" +"First you should set the journal to allow cancelling entries." +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:58 +msgid "Beneficiary" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Group By..." +msgstr "" + +#. module: account_check_deposit +#: model:ir.actions.report.xml,name:account_check_deposit.check_deposit_webkit +msgid "WebKit Checks Deposit" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:79 +msgid "Designation" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,state:0 +msgid "Status" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:78 +msgid "Description" +msgstr "" + +#. module: account_check_deposit +#: field:account.move.line,check_deposit_id:0 +msgid "Check Deposit" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,company_id:0 +msgid "Company" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:65 +msgid "RIB Key" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,deposit_date:0 +#: report:addons/account_check_deposit/report/check_deposit.mako:53 +msgid "Deposit Date" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:63 +msgid "Account to crediting" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:76 +msgid "Payment Date" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Date" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Total Credit" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,bank_id:0 +msgid "Bank" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,name:0 +msgid "Name" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Checks Deposit Search" +msgstr "" + +#. module: account_check_deposit +#: model:account.account.type,name:account_check_deposit.data_account_type_received_check +msgid "Recieved Checks" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +#: report:addons/account_check_deposit/report/check_deposit.mako:49 +msgid "Deposit N°" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Total Debit" +msgstr "" + +#. module: account_check_deposit +#: code:addons/account_check_deposit/account_deposit.py:76 +#, python-format +msgid "Error!" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:80 +msgid "Amount" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +#: model:ir.actions.act_window,name:account_check_deposit.action_check_deposit_tree +#: model:ir.ui.menu,name:account_check_deposit.menu_check_deposit_tree +msgid "Checks Deposit" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,total_amount:0 +msgid "total amount" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,partner_id:0 +msgid "Partner" +msgstr "" + +#. module: account_check_deposit +#: selection:account.check.deposit,state:0 +msgid "Cancelled" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Validate Deposit" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +#: field:account.check.deposit,check_payment_ids:0 +#: report:addons/account_check_deposit/report/check_deposit.mako:70 +msgid "Check Payments" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:41 +msgid "Deposit Slip of Checks(\\u20acuros)" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:55 +msgid "Bank Code" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:77 +msgid "Reference" +msgstr "" + +#. module: account_check_deposit +#: model:ir.model,name:account_check_deposit.model_account_check_deposit +msgid "Account Check Deposit" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:60 +msgid "Office Code" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Check Payment" +msgstr "" + +#. module: account_check_deposit +#: selection:account.check.deposit,state:0 +msgid "Done" +msgstr "" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Cancel" +msgstr "" + +#. module: account_check_deposit +#: selection:account.check.deposit,state:0 +msgid "Draft" +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:99 +msgid "Total:" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,move_id:0 +msgid "Journal Entry" +msgstr "" + +#. module: account_check_deposit +#: field:account.check.deposit,journal_id:0 +msgid "Journal" +msgstr "" + +#. module: account_check_deposit +#: model:ir.model,name:account_check_deposit.model_account_move_line +msgid "Journal Items" +msgstr "" + diff --git a/account_check_deposit/i18n/fr.po b/account_check_deposit/i18n/fr.po new file mode 100644 index 000000000..5df143428 --- /dev/null +++ b/account_check_deposit/i18n/fr.po @@ -0,0 +1,236 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_check_deposit +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-21 10:01+0000\n" +"PO-Revision-Date: 2013-02-21 10:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_check_deposit +#: code:addons/account_check_deposit/account_deposit.py:76 +#, python-format +msgid "You cannot modify a posted entry of this journal.\n" +"First you should set the journal to allow cancelling entries." +msgstr "" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:58 +msgid "Beneficiary" +msgstr "Bénéficiaire" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Group By..." +msgstr "Regrouper par..." + +#. module: account_check_deposit +#: model:ir.actions.report.xml,name:account_check_deposit.check_deposit_webkit +msgid "WebKit Checks Deposit" +msgstr "WebKit pour Remise de Chèques" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:79 +msgid "Designation" +msgstr "Désignation" + +#. module: account_check_deposit +#: field:account.check.deposit,state:0 +msgid "Status" +msgstr "Etat" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:78 +msgid "Description" +msgstr "Description" + +#. module: account_check_deposit +#: field:account.move.line,check_deposit_id:0 +msgid "Check Deposit" +msgstr "Remise de Chèque" + +#. module: account_check_deposit +#: field:account.check.deposit,company_id:0 +msgid "Company" +msgstr "Société" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:65 +msgid "BIS Key" +msgstr "Clé RIB" + +#. module: account_check_deposit +#: field:account.check.deposit,deposit_date:0 +#: report:addons/account_check_deposit/report/check_deposit.mako:53 +msgid "Deposit Date" +msgstr "Date du Versement" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:63 +msgid "Account to crediting" +msgstr "Compte à Créditer" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:76 +msgid "Payment Date" +msgstr "Date de Paiement" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Date" +msgstr "Date" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Total Credit" +msgstr "Crédit Total" + +#. module: account_check_deposit +#: field:account.check.deposit,bank_id:0 +msgid "Bank" +msgstr "Banque" + +#. module: account_check_deposit +#: field:account.check.deposit,name:0 +msgid "Name" +msgstr "Nom" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Checks Deposit Search" +msgstr "Rechercher une Remise de Chèques" + +#. module: account_check_deposit +#: model:account.account.type,name:account_check_deposit.data_account_type_received_check +msgid "Recieved Checks" +msgstr "Chèques Reçus" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +#: report:addons/account_check_deposit/report/check_deposit.mako:49 +msgid "Deposit N°" +msgstr "Versement N°" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Total Debit" +msgstr "Débit Total" + +#. module: account_check_deposit +#: code:addons/account_check_deposit/account_deposit.py:76 +#, python-format +msgid "Error!" +msgstr "Erreur!" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:80 +msgid "Amount" +msgstr "Montant" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +#: model:ir.actions.act_window,name:account_check_deposit.action_check_deposit_tree +#: model:ir.ui.menu,name:account_check_deposit.menu_check_deposit_tree +msgid "Checks Deposit" +msgstr "Remise de Chèques" + +#. module: account_check_deposit +#: field:account.check.deposit,total_amount:0 +msgid "total amount" +msgstr "montant total" + +#. module: account_check_deposit +#: field:account.check.deposit,partner_id:0 +msgid "Partner" +msgstr "Partenaire" + +#. module: account_check_deposit +#: selection:account.check.deposit,state:0 +msgid "Cancelled" +msgstr "Annulé" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Validate Deposit" +msgstr "Valider Versement" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +#: field:account.check.deposit,check_payment_ids:0 +#: report:addons/account_check_deposit/report/check_deposit.mako:70 +msgid "Check Payments" +msgstr "Paiements par Chèque" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:41 +msgid "Deposit Slip of Checks(Euros)" +msgstr "Bordereau de Remise de Chèques(Euros)" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:55 +msgid "Bank Code" +msgstr "Code Banque" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:77 +msgid "Reference" +msgstr "Référence" + +#. module: account_check_deposit +#: model:ir.model,name:account_check_deposit.model_account_check_deposit +msgid "Account Check Deposit" +msgstr "Compte Remise de Chèque" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:60 +msgid "Office Code" +msgstr "Code Guichet" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Check Payment" +msgstr "Paiement par Chèque" + +#. module: account_check_deposit +#: selection:account.check.deposit,state:0 +msgid "Done" +msgstr "Terminé" + +#. module: account_check_deposit +#: view:account.check.deposit:0 +msgid "Cancel" +msgstr "Annuler" + +#. module: account_check_deposit +#: selection:account.check.deposit,state:0 +msgid "Draft" +msgstr "Brouillon" + +#. module: account_check_deposit +#: report:addons/account_check_deposit/report/check_deposit.mako:99 +msgid "Total:" +msgstr "Total:" + +#. module: account_check_deposit +#: field:account.check.deposit,move_id:0 +msgid "Journal Entry" +msgstr "Pièce Comptable" + +#. module: account_check_deposit +#: field:account.check.deposit,journal_id:0 +msgid "Journal" +msgstr "Journal" + +#. module: account_check_deposit +#: model:ir.model,name:account_check_deposit.model_account_move_line +msgid "Journal Items" +msgstr "Écritures comptables" + diff --git a/account_check_deposit/report/.directory b/account_check_deposit/report/.directory new file mode 100644 index 000000000..616766eae --- /dev/null +++ b/account_check_deposit/report/.directory @@ -0,0 +1,6 @@ +[Dolphin] +AdditionalInfoV2=Details_Size,Details_Date,CustomizedDetails +Sorting=2 +Timestamp=2012,3,5,14,27,49 +Version=2 +ViewMode=1 diff --git a/account_check_deposit/report/.mako b/account_check_deposit/report/.mako new file mode 100644 index 000000000..63e5128f9 --- /dev/null +++ b/account_check_deposit/report/.mako @@ -0,0 +1,275 @@ + + + + + + + + <% + def carriage_returns(text): + return text.replace('\n', '
') + %> + + %for order in objects : +
+ <% setLang(order.partner_id.lang) %> + + %if order.company_id.address_label_position == 'left': + + + + + + %endif + + %if order.company_id.address_label_position == 'right' or not order.company_id.address_label_position: + + + + + %endif +
+${_("Shipping Address")} +
+
+${order.partner_shipping_id.address_label}
+           
+         
+ %if order.partner_id.address_label != order.partner_shipping_id.address_label: +${_("Ordering Contact")}
+${order.partner_id.address_label|carriage_returns} + %endif + %if order.partner_id.phone : +${_("Phone")}: ${order.partner_id.phone|entity}
+ %endif + %if order.partner_id.fax : +${_("Fax")}: ${order.partner_id.fax|entity}
+ %endif + %if order.partner_id.email : +${_("Mail")}: ${order.partner_id.email|entity}
+ %endif + %if order.partner_invoice_id.address_label != order.partner_shipping_id.address_label: +
+${_("Invoice Address")}
+${order.partner_invoice_id.address_label|carriage_returns} + %endif + %if order.partner_invoice_id.partner_id.vat : +${_("VAT")}: ${order.partner_invoice_id.partner_id.vat|entity}
+ %endif + +
+ %if order.partner_id.address_label != order.partner_shipping_id.address_label: +${_("Ordering Contact")}
+
+${order.partner_id.address_label|carriage_returns} + %endif + %if order.partner_id.phone : +${_("Tel")}: ${order.partner_id.phone|entity}
+ %endif + %if order.partner_id.fax : +${_("Fax")}: ${order.partner_id.fax|entity}
+ %endif + %if order.partner_id.email : +${_("E-mail")}: ${order.partner_id.email|entity}
+ %endif + %if order.partner_invoice_id.address_label != order.partner_shipping_id.address_label: +
+
+${_("Invoice Address")}
+
+${order.partner_invoice_id.address_label|carriage_returns} + %endif + %if order.partner_invoice_id.vat : +${_("VAT")}: ${order.partner_invoice_id.vat|entity}
+ %endif + +
+${_("Shipping Address")}
+
+
+${order.partner_shipping_id.address_label}
+           
+         
+ +
+
+ + %if order.state == 'draft' : + ${_("Quotation N°")} ${order.name or ''|entity} + %elif order.state == 'cancel' : + ${_("Sale Order Canceled")} ${order.name or ''|entity} + %else : + ${_("Order N°")} ${order.name or ''|entity} + %endif +
+ + + %if order.client_order_ref: + + %endif + %if order.project_id: + + %endif + + %if order.carrier_id: + + %endif + %if order.user_id: + + %endif + %if order.payment_term : + + %endif + %if order.incoterm: + + %endif + + + + + %if order.client_order_ref: + + %endif + %if order.project_id: + + %endif + %if order.date_order: + + %endif + %if order.carrier_id: + + %endif + %if order.user_id : + + %endif + %if order.payment_term : + + %endif + %if order.incoterm: + + %endif + + +
${_("Reference")}${_("Projekt")}${_("Order Date")}${_("Carrier")}${_("Salesman")}${_("Payment Term")}${_("Incoterm")}${_("Curr")}
+ ${order.client_order_ref} + ${order.project_id.name} + ${order.date_order or ''} + ${order.carrier_id.name } + ${order.user_id.name or ''}${order.payment_term.name}${order.incoterm.name}${order.pricelist_id.currency_id.name}
+


+ + + +%if order.print_code: + + +%else: + +%endif + +%if order.print_uom: + +%endif +%if order.print_uos: + +%endif +%if order.print_ean: + +%endif +%if order.print_packing: + + +%endif + +%if order.print_discount: + +%endif + + + + %for line in order.order_line_sorted : + + +%if order.print_code: + + +%else: + ${ ', '.join([tax.name or '' for tax in line.tax_id]) } +%if order.print_uom: + + +%endif +%if order.print_uos: + + +%endif +%if order.print_ean: + +%endif +%if order.print_packing: + + +%endif + +%if order.print_discount: + + + %endfor + + + + + + + + + + + + + + + + +
${_("Code")}${_("Description")}${_("Description")}${_("Tax")}${_("Quantity")}${_("UoM")}${_("UoS Qty")}${_("UoS")}${_("EAN")}${_("Pack")}${_("Packaging")}${_("Price Unit")}${_("Discount")}${_("Sub Total")}
${line.product_id.default_code or ''|entity} +${line.product_id.name or line.name|entity} + + +${line.name|entity} + + ${str(line.product_uom_qty).replace(',000','') or '0'}${line.product_uom.name or ''}${str(line.product_uos_qty).replace(',000','') or '0'}${line.product_uos.name or ''}${line.product_packaging.ean or line.product_id.ean13 or ''}${line.product_packaging.qty and line.product_uom_qty/line.product_packaging.qty or ''}${line.product_packaging and line.product_packaging.ul.name or ''} ${line.product_packaging and _(" / " or '')} ${line.product_packaging and line.product_packaging.qty or ''} ${line.product_packaging and line.product_id.uom_id.name or ''}${line.price_unit or ''}${line.discount} +%endif + ${line.price_subtotal or ''}
+ ${_("Net Total:")}${formatLang(order.amount_untaxed, get_digits(dp='Sale Price'))}
+ ${_("Taxes:")}${formatLang(order.amount_tax, get_digits(dp='Sale Price'))}
+ ${_("Total:")}${formatLang(order.amount_total, get_digits(dp='Sale Price'))}
+ +%if order.note and 'note_print' not in order._columns: +
+
${order.note}
+%endif: +%if 'note_print' in order._columns and order.note_print: +
+
${order.note_print}
+%endif: + + +

+ %endfor + + diff --git a/account_check_deposit/report/__init__.py b/account_check_deposit/report/__init__.py new file mode 100644 index 000000000..285cd87c3 --- /dev/null +++ b/account_check_deposit/report/__init__.py @@ -0,0 +1,32 @@ + #-*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) +# All Right Reserved +# +# Author : Ferdinand Gassauer (Camptocamp Austria) +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import report_webkit_html diff --git a/account_check_deposit/report/check_deposit.mako b/account_check_deposit/report/check_deposit.mako new file mode 100644 index 000000000..f2b5afe19 --- /dev/null +++ b/account_check_deposit/report/check_deposit.mako @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- + + + + + +%for deposit in objects : +<% setLang(deposit.partner_id.lang) %> +${_("Deposit Slip of Checks(Euros)")} +
+
+
+
+
+
+

+${_("Deposit N°")} ${deposit.name} +

+ +

+${_("Deposit Date")}${_("|")} + ${deposit.deposit_date} +${_("Bank Code")} +${_("|")} ${deposit.bank_id.bank_code} +
+${_("Beneficiary")}${_("|")} + ${company.partner_id.name} +${_("Office Code")} +${_("|")} ${deposit.bank_id.office} +
+${_("Account to crediting")}${_("|")} + ${deposit.bank_id.rib_acc_number} +${_("BIS Key")}${_("|")} + ${deposit.bank_id.key} +

+
+

+${_("Check Payments")} +

+ + + + + + + + + + + + +
+ %for move_line in deposit.check_payment_ids : + + + + + + + + + + %endfor + %endfor + + + + + + +
${_("Payment Date")}${_("Reference")}${_("Description")}${_("Designation")}${_("Amount")}
${move_line.date or ''}${move_line.ref or ''}${move_line.name or ''}${move_line.partner_id.name or ''}${move_line.debit or '0'}
${_("Total:")}${deposit.total_amount or '0'}
+ + + + + + + + + diff --git a/account_check_deposit/report/report_webkit_html.py b/account_check_deposit/report/report_webkit_html.py new file mode 100644 index 000000000..459915868 --- /dev/null +++ b/account_check_deposit/report/report_webkit_html.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# Copyright (C) 2010-2012 Camptocamp Austria () +# Copyright (C) 2013 AKRETION () +# +# 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 . +# +############################################################################## + +import time +from report import report_sxw +from osv import osv + +class report_webkit_html(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(report_webkit_html, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'cr':cr, + 'uid': uid, + }) + +report_sxw.report_sxw('report.account.check.deposit', + 'account.check.deposit', + 'addons/account_check_deposit/report/check_deposit.mako', + parser=report_webkit_html) From de4844383ee4c69e8ee676772358141b249587b1 Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Thu, 11 Apr 2013 14:32:08 +0200 Subject: [PATCH 07/26] [IMP] clean code --- account_check_deposit/__init__.py | 5 - account_check_deposit/__openerp__.py | 7 +- account_check_deposit/account_deposit.py | 93 ++++++++++++------- .../account_deposit_view.xml | 21 +++-- 4 files changed, 79 insertions(+), 47 deletions(-) diff --git a/account_check_deposit/__init__.py b/account_check_deposit/__init__.py index d0334331b..91e61fc83 100644 --- a/account_check_deposit/__init__.py +++ b/account_check_deposit/__init__.py @@ -19,10 +19,5 @@ # # ############################################################################### - - import account_deposit - - - diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 5fdfa4610..e39cd1b46 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -24,7 +24,7 @@ { 'name': 'account_check_deposit', - 'version': '7.0', + 'version': '0.1', 'category': 'Generic Modules/Others', 'license': 'AGPL-3', 'description': """This module allows you to use check deposits. @@ -33,7 +33,10 @@ You may have to create an account for recieved checks and a journal for payment by checks.""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': ['account_accountant','report_webkit','sale_quick_payment'], + 'depends': ['account_accountant', + 'report_webkit', + 'sale_quick_payment' + ], 'init_xml': [], 'update_xml': [ 'account_deposit_view.xml', diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 81dfdb72e..ac8b5c2ea 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -20,11 +20,11 @@ # # ############################################################################### -from openerp.osv import fields, osv -from openerp.osv.orm import Model +from openerp.osv import fields, osv, orm from openerp.tools.translate import _ -class account_check_deposit(Model): + +class account_check_deposit(orm.Model): _name = "account.check.deposit" _description = "Account Check Deposit" @@ -39,25 +39,38 @@ class account_check_deposit(Model): _columns = { - 'name': fields.char('Name', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}), - 'check_payment_ids': fields.many2many('account.move.line', 'account_move_line_deposit_rel', - 'check_deposit_id', 'move_line_id', 'Check Payments', - readonly=True, states={'draft':[('readonly',False)]}), - 'deposit_date': fields.date('Deposit Date', readonly=True, states={'draft':[('readonly',False)]}), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, + 'name': fields.char('Name', size=64, required=True, readonly=True, + tates={'draft':[('readonly',False)]}), + 'check_payment_ids': fields.many2many('account.move.line', + 'account_move_line_deposit_rel', + 'check_deposit_id', + 'move_line_id', + 'Check Payments', + readonly=True, + states={'draft':[('readonly',False)]}), + 'deposit_date': fields.date('Deposit Date', readonly=True, + states={'draft':[('readonly',False)]}), + 'journal_id': fields.many2one('account.journal', 'Journal', + required=True, readonly=True, states={'draft':[('readonly',False)]}), 'state': fields.selection([ ('draft','Draft'), ('done','Done'), ('cancel','Cancelled') ],'Status', readonly=True), - 'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, + 'move_id': fields.many2one('account.move', 'Journal Entry', + readonly=True, states={'draft':[('readonly',False)]}), - 'bank_id': fields.many2one('res.partner.bank', 'Bank', required=True, readonly=True, - domain="[('partner_id', '=', partner_id)]", + 'bank_id': fields.many2one('res.partner.bank', 'Bank', required=True, + readonly=True, + domain="[('partner_id', '=', partner_id)]", + states={'draft':[('readonly',False)]}), + 'partner_id':fields.related('company_id', 'partner_id', type="many2one", + relation="res.partner", string="Partner", + readonly=True), + 'company_id': fields.many2one('res.company', 'Company', required=True, + change_default=True, readonly=True, states={'draft':[('readonly',False)]}), - 'partner_id':fields.related('company_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", readonly=True), - 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}), 'total_amount': fields.function(sum_amount, string ="total amount"), } @@ -87,9 +100,13 @@ class account_check_deposit(Model): def _prepare_account_move_vals(self, cr, uid, deposit, context=None): move_vals = {} - move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, move_vals, context=context)]] + move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, + deposit, move_vals, + context=context)]] for line in deposit.check_payment_ids: - move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)]) + move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, + move_vals, + context=context)]) move_vals.update({ 'journal_id': deposit.journal_id.id, 'line_id': move_lines, @@ -97,11 +114,12 @@ class account_check_deposit(Model): return move_vals def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): - move_line_vals = self.pool.get('account.move.line').default_get(cr, uid, - ['centralisation', 'date','date_created', - 'currency_id', 'journal_id', 'amount_currency', - 'account_id', 'period_id', 'company_id'], - context=context) + move_line_vals = self.pool.get('account.move.line').default_get( + cr, uid, + ['centralisation', 'date','date_created', 'currency_id', + 'journal_id', 'amount_currency', 'account_id', 'period_id', + 'company_id'], + context=context) move_line_vals.update({ 'name': line.name, 'credit': line.debit, @@ -112,11 +130,12 @@ class account_check_deposit(Model): return move_line_vals def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): - move_line_vals = self.pool.get('account.move.line').default_get(cr, uid, - ['centralisation', 'date','date_created', - 'currency_id', 'journal_id', 'amount_currency', - 'account_id', 'period_id', 'company_id', 'state'], - context=context) + move_line_vals = self.pool.get('account.move.line').default_get( + cr, uid, + ['centralisation', 'date','date_created', 'currency_id', + 'journal_id', 'amount_currency', 'account_id', 'period_id', + 'company_id', 'state'], + context=context) debit = 0.0 for line in deposit.check_payment_ids: @@ -132,11 +151,15 @@ class account_check_deposit(Model): def _reconcile_checks(self, cr, uid, deposit, move_id, context=None): move_line_obj = self.pool.get('account.move.line') for line in deposit.check_payment_ids: - move_line_ids = move_line_obj.search(cr, uid, [('move_id', '=', move_id), - ('credit', '=', line.debit), - ('name', '=', line.ref)], context=context) + move_line_ids = move_line_obj.search(cr, uid, + [('move_id', '=', move_id), + ('credit', '=', line.debit), + ('name', '=', line.ref)], + context=context) if move_line_ids: - move_line_obj.reconcile(cr, uid, [line.id, move_line_ids[0]], context=context) + move_line_obj.reconcile(cr, uid, + [line.id, move_line_ids[0]], + context=context) return True @@ -157,7 +180,6 @@ class account_check_deposit(Model): for deposit in self.browse(cr, uid, ids, context=context): context['journal_id'] = deposit.journal_id.id move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) - print "move_vals ====>", move_vals move_id = move_obj.create(cr, uid, move_vals, context=context) move_obj.post(cr, uid, [move_id], context=context) self._reconcile_checks(cr, uid, deposit, move_id, context=context) @@ -165,10 +187,13 @@ class account_check_deposit(Model): return True -class account_move_line(Model): +class account_move_line(orm.Model): _inherit = "account.move.line" _columns = { - 'check_deposit_id': fields.many2many('account.check.deposit', 'account_move_line_deposit_rel', - 'check_deposit_id', 'move_line_id', 'Check Deposit'), + 'check_deposit_id': fields.many2many('account.check.deposit', + 'account_move_line_deposit_rel', + 'check_deposit_id', + 'move_line_id', + 'Check Deposit'), } diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index 856dbbd5b..e7827b094 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -26,10 +26,13 @@
-
@@ -41,12 +44,14 @@ - + - @@ -108,7 +113,11 @@ - + From 04404349fbe233e3f98a9083b6b0df1bb205ffec Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Thu, 11 Apr 2013 16:46:11 +0200 Subject: [PATCH 08/26] [IMP] add access rules for account_check_deposit --- account_check_deposit/__openerp__.py | 1 + account_check_deposit/security/ir.model.access.csv | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 account_check_deposit/security/ir.model.access.csv diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index e39cd1b46..c63a46b29 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -42,6 +42,7 @@ 'account_deposit_view.xml', 'account_deposit_sequence.xml', 'account_type_data.xml', + 'security/ir.model.access.csv', ], 'demo_xml': [], 'installable': True, diff --git a/account_check_deposit/security/ir.model.access.csv b/account_check_deposit/security/ir.model.access.csv new file mode 100644 index 000000000..8f26e463a --- /dev/null +++ b/account_check_deposit/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_account_check_deposit_account_check_deposit_group_manager","account_check_deposit_account_check_deposit_group_manager","model_account_check_deposit","base.group_system",1,1,1,1 +"access_account_check_deposit_account_check_deposit_group_user","account_check_deposit_account_check_deposit_group_user","model_account_check_deposit","base.group_user",1,0,0,0 From 6e64332586f7e9076b97cddf0b8e6f9586228f9c Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Thu, 11 Apr 2013 17:58:19 +0200 Subject: [PATCH 09/26] [FIX] change print button name --- account_check_deposit/account_deposit_view.xml | 2 +- account_check_deposit/i18n/fr.po | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index e7827b094..2a74daef0 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -15,7 +15,7 @@ model="account.check.deposit" name="check.deposit.webkit" report_type="webkit" - string="WebKit Checks Deposit"/> + string="Print Checks Deposit"/> diff --git a/account_check_deposit/i18n/fr.po b/account_check_deposit/i18n/fr.po index 5df143428..0b869dbdf 100644 --- a/account_check_deposit/i18n/fr.po +++ b/account_check_deposit/i18n/fr.po @@ -34,8 +34,8 @@ msgstr "Regrouper par..." #. module: account_check_deposit #: model:ir.actions.report.xml,name:account_check_deposit.check_deposit_webkit -msgid "WebKit Checks Deposit" -msgstr "WebKit pour Remise de Chèques" +msgid "Print Checks Deposit" +msgstr "Imprimer Remise de Chèques" #. module: account_check_deposit #: report:addons/account_check_deposit/report/check_deposit.mako:79 From 1cda50a36dea88a35ef65cbe7282583f49255b09 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 3 Feb 2014 08:22:31 +0100 Subject: [PATCH 10/26] [FIX] fix datamodel structure, indeed check_payment_ids should be a m2o. In the view we still keep the widget --- account_check_deposit/account_deposit.py | 14 +++++--------- account_check_deposit/security/ir.model.access.csv | 3 +-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index ac8b5c2ea..cd8262ce4 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -40,11 +40,8 @@ class account_check_deposit(orm.Model): _columns = { 'name': fields.char('Name', size=64, required=True, readonly=True, - tates={'draft':[('readonly',False)]}), - 'check_payment_ids': fields.many2many('account.move.line', - 'account_move_line_deposit_rel', + 'check_payment_ids': fields.one2many('account.move.line', 'check_deposit_id', - 'move_line_id', 'Check Payments', readonly=True, states={'draft':[('readonly',False)]}), @@ -88,9 +85,11 @@ class account_check_deposit(orm.Model): if not deposit.journal_id.update_posted: raise osv.except_osv(_('Error!'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) for line in deposit.check_payment_ids: - line.reconcile_id.unlink() + if line.reconcile_id: + line.reconcile_id.unlink() deposit.move_id.button_cancel() deposit.move_id.unlink() + deposit.write({'cancel': 'draft'}) return True def create(self, cr, uid, vals, context=None): @@ -191,9 +190,6 @@ class account_move_line(orm.Model): _inherit = "account.move.line" _columns = { - 'check_deposit_id': fields.many2many('account.check.deposit', - 'account_move_line_deposit_rel', - 'check_deposit_id', - 'move_line_id', + 'check_deposit_id': fields.many2one('account.check.deposit', 'Check Deposit'), } diff --git a/account_check_deposit/security/ir.model.access.csv b/account_check_deposit/security/ir.model.access.csv index 8f26e463a..3e679366f 100644 --- a/account_check_deposit/security/ir.model.access.csv +++ b/account_check_deposit/security/ir.model.access.csv @@ -1,3 +1,2 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_account_check_deposit_account_check_deposit_group_manager","account_check_deposit_account_check_deposit_group_manager","model_account_check_deposit","base.group_system",1,1,1,1 -"access_account_check_deposit_account_check_deposit_group_user","account_check_deposit_account_check_deposit_group_user","model_account_check_deposit","base.group_user",1,0,0,0 +"access_account_check_deposit_account_check_deposit_group_manager","account_check_deposit_account_check_deposit_group_manager","model_account_check_deposit","account.group_account_user",1,1,1,1 From 7db4b4d86309e13d25f84f976be430128f3130da Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 3 Feb 2014 08:23:13 +0100 Subject: [PATCH 11/26] [REF] remove useless state cancel, only draft/done is sufficent for now, forbid to delete a done deposit, fix move_line name need to be the equal to the line.ref for the reconciliation --- account_check_deposit/account_deposit.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index cd8262ce4..e7f8755e1 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -53,7 +53,6 @@ class account_check_deposit(orm.Model): 'state': fields.selection([ ('draft','Draft'), ('done','Done'), - ('cancel','Cancelled') ],'Status', readonly=True), 'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, @@ -78,7 +77,12 @@ class account_check_deposit(orm.Model): 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.check.deposit', context=c), } - + def unlink(self, cr, uid, ids, context=None): + for deposit in self.browse(cr, uid, ids, context=context): + if deposit.state == 'done': + raise osv.except_osv(_('User Error!'), + _('You cannot delete a validad deposit, cancel it before')) + return super(account_check_deposit, self).unlink(cr, uid, ids, context=context) def cancel(self, cr, uid, ids, context=None): for deposit in self.browse(cr, uid, ids, context=context): @@ -87,9 +91,10 @@ class account_check_deposit(orm.Model): for line in deposit.check_payment_ids: if line.reconcile_id: line.reconcile_id.unlink() - deposit.move_id.button_cancel() - deposit.move_id.unlink() - deposit.write({'cancel': 'draft'}) + if deposit.move_id: + deposit.move_id.button_cancel() + deposit.move_id.unlink() + deposit.write({'state': 'draft'}) return True def create(self, cr, uid, vals, context=None): @@ -120,11 +125,10 @@ class account_check_deposit(orm.Model): 'company_id'], context=context) move_line_vals.update({ - 'name': line.name, + 'name': line.ref, 'credit': line.debit, 'account_id': line.account_id.id, 'partner_id': line.partner_id.id, - 'ref': line.ref, }) return move_line_vals From 96264d3b0d1fce505672bcae453cdb89b4fdaaad Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Thu, 3 Oct 2013 23:57:05 +0200 Subject: [PATCH 12/26] [IMP] improve reconciliation between the check and the check deposit --- account_check_deposit/account_deposit.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index e7f8755e1..63a48790b 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -147,6 +147,7 @@ class account_check_deposit(orm.Model): 'name': deposit.name, 'debit': debit, 'ref': deposit.name, + 'check_line_id': line.id, }) return move_line_vals @@ -154,14 +155,9 @@ class account_check_deposit(orm.Model): def _reconcile_checks(self, cr, uid, deposit, move_id, context=None): move_line_obj = self.pool.get('account.move.line') for line in deposit.check_payment_ids: - move_line_ids = move_line_obj.search(cr, uid, - [('move_id', '=', move_id), - ('credit', '=', line.debit), - ('name', '=', line.ref)], - context=context) - if move_line_ids: + if line.check_line_id: move_line_obj.reconcile(cr, uid, - [line.id, move_line_ids[0]], + [line.id, line.check_line_id.id], context=context) return True @@ -196,4 +192,6 @@ class account_move_line(orm.Model): _columns = { 'check_deposit_id': fields.many2one('account.check.deposit', 'Check Deposit'), + 'check_line_id': fields.many2one('account.move.line', + 'Check Receive Move line'), } From d50caab20c67fc77c155fdc87e33fb676356dde3 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 3 Feb 2014 08:35:04 +0100 Subject: [PATCH 13/26] [FIX] set correctly the date on the move line generated --- account_check_deposit/account_deposit.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 63a48790b..fb0d765af 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -103,18 +103,23 @@ class account_check_deposit(orm.Model): return super(account_check_deposit, self).create(cr, uid, vals, context=context) def _prepare_account_move_vals(self, cr, uid, deposit, context=None): - move_vals = {} - move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, - deposit, move_vals, + move_vals = { + 'journal_id': deposit.journal_id.id, + 'date': deposit.deposit_date, + } + period_obj = self.pool['account.period'] + period_ids = period_obj.find(cr, uid, dt=deposit.deposit_date, context=context) + if period_ids: + move_vals['period_id'] = period_ids[0] + + move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, + move_vals, context=context)]] for line in deposit.check_payment_ids: move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)]) - move_vals.update({ - 'journal_id': deposit.journal_id.id, - 'line_id': move_lines, - }) + move_vals.update({'line_id': move_lines}) return move_vals def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): From d5acabfdd40e8dfb8dbcf77189b4da94dbb5162c Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 21 Oct 2013 23:51:08 +0200 Subject: [PATCH 14/26] [FIX] fix reconciliation of check --- account_check_deposit/account_deposit.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index fb0d765af..7f23c4d77 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -134,6 +134,7 @@ class account_check_deposit(orm.Model): 'credit': line.debit, 'account_id': line.account_id.id, 'partner_id': line.partner_id.id, + 'check_line_id': line.id, }) return move_line_vals @@ -152,14 +153,15 @@ class account_check_deposit(orm.Model): 'name': deposit.name, 'debit': debit, 'ref': deposit.name, - 'check_line_id': line.id, }) return move_line_vals - def _reconcile_checks(self, cr, uid, deposit, move_id, context=None): - move_line_obj = self.pool.get('account.move.line') - for line in deposit.check_payment_ids: + def _reconcile_checks(self, cr, uid, move_id, context=None): + move_line_obj = self.pool['account.move.line'] + move_obj = self.pool['account.move'] + move = move_obj.browse(cr, uid, move_id, context=context) + for line in move.line_id: if line.check_line_id: move_line_obj.reconcile(cr, uid, [line.id, line.check_line_id.id], @@ -186,7 +188,7 @@ class account_check_deposit(orm.Model): move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) move_id = move_obj.create(cr, uid, move_vals, context=context) move_obj.post(cr, uid, [move_id], context=context) - self._reconcile_checks(cr, uid, deposit, move_id, context=context) + self._reconcile_checks(cr, uid, move_id, context=context) deposit.write({'state':'done', 'move_id': move_id}) return True From df3295f78c91de38f9f2da5470f422a761179ee1 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 3 Feb 2014 08:43:19 +0100 Subject: [PATCH 15/26] [IMP] check deposit improve view and add tab for move line generated --- account_check_deposit/account_deposit.py | 6 +++ .../account_deposit_view.xml | 44 +++++++++++-------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 7f23c4d77..1daaa5c17 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -61,6 +61,12 @@ class account_check_deposit(orm.Model): readonly=True, domain="[('partner_id', '=', partner_id)]", states={'draft':[('readonly',False)]}), + 'line_ids': fields.related('move_id', 'line_id', + relation='account.move.line', + type='one2many', + string='Lines', + readonly=True, + ), 'partner_id':fields.related('company_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", readonly=True), diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index 2a74daef0..2f97422d9 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -49,25 +49,31 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +
From e3265020e787645b758733a7182681e9ce852cc1 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 3 Feb 2014 08:44:59 +0100 Subject: [PATCH 16/26] [IMP] add total amount and flag to know if the deposit have been reconcile, the best will be to add a workflow --- account_check_deposit/account_deposit.py | 14 ++++++++++++-- account_check_deposit/account_deposit_view.xml | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 1daaa5c17..1f07d3307 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -30,13 +30,22 @@ class account_check_deposit(orm.Model): def sum_amount(self, cr, uid, ids, name, args, context=None): res = {} - total = 0 for deposit in self.browse(cr, uid, ids, context=context): + total = 0 for line in deposit.check_payment_ids: total += line.debit res[deposit.id]= total return res + def _is_reconcile(self, cr, uid, ids, name, args, context=None): + res = {} + for deposit in self.browse(cr, uid, ids, context=context): + res[deposit.id] = False + if deposit.move_id: + for line in deposit.move_id.line_id: + if line.debit > 0 and line.reconcile_id: + res[deposit.id] = True + return res _columns = { 'name': fields.char('Name', size=64, required=True, readonly=True, @@ -73,7 +82,8 @@ class account_check_deposit(orm.Model): 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}), - 'total_amount': fields.function(sum_amount, string ="total amount"), + 'total_amount': fields.function(sum_amount, string ="total amount", type="float"), + 'is_reconcile': fields.function(_is_reconcile, string ="Reconcile", type="boolean"), } _defaults = { diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index 2f97422d9..580d65f10 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -89,6 +89,8 @@ + +
From 18363d20775f33696555678e4a3cdadf8866be91 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 3 Feb 2014 08:55:38 +0100 Subject: [PATCH 17/26] [FIX] fix error when replaying commit --- account_check_deposit/account_deposit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 1f07d3307..ecdf62b39 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -49,6 +49,7 @@ class account_check_deposit(orm.Model): _columns = { 'name': fields.char('Name', size=64, required=True, readonly=True, + states={'draft':[('readonly',False)]}), 'check_payment_ids': fields.one2many('account.move.line', 'check_deposit_id', 'Check Payments', From d2ad519fe19d825edb213df50a4a303e187986eb Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Mon, 10 Mar 2014 23:23:08 +0100 Subject: [PATCH 18/26] [REF] remove dependency on sale_quick_payment as check can be registred in various way like native voucher --- account_check_deposit/__openerp__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index c63a46b29..9fd281ee2 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -35,7 +35,6 @@ 'website': 'http://www.akretion.com/', 'depends': ['account_accountant', 'report_webkit', - 'sale_quick_payment' ], 'init_xml': [], 'update_xml': [ From 70083155455cdc9bbcee11f11492d68ba8f212ec Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Tue, 11 Mar 2014 00:00:09 +0100 Subject: [PATCH 19/26] [CLEAN] pep8 cleanup no code change --- account_check_deposit/account_deposit.py | 220 +++++++++++------- .../report/report_webkit_html.py | 11 +- 2 files changed, 146 insertions(+), 85 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index ecdf62b39..6816d41da 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -34,8 +34,8 @@ class account_check_deposit(orm.Model): total = 0 for line in deposit.check_payment_ids: total += line.debit - res[deposit.id]= total - return res + res[deposit.id] = total + return res def _is_reconcile(self, cr, uid, ids, name, args, context=None): res = {} @@ -45,53 +45,85 @@ class account_check_deposit(orm.Model): for line in deposit.move_id.line_id: if line.debit > 0 and line.reconcile_id: res[deposit.id] = True - return res + return res _columns = { - 'name': fields.char('Name', size=64, required=True, readonly=True, - states={'draft':[('readonly',False)]}), - 'check_payment_ids': fields.one2many('account.move.line', - 'check_deposit_id', - 'Check Payments', - readonly=True, - states={'draft':[('readonly',False)]}), - 'deposit_date': fields.date('Deposit Date', readonly=True, - states={'draft':[('readonly',False)]}), - 'journal_id': fields.many2one('account.journal', 'Journal', - required=True, readonly=True, - states={'draft':[('readonly',False)]}), + 'name': fields.char( + 'Name', + size=64, + required=True, + readonly=True, + states={'draft': [('readonly', '=', False)]}), + 'check_payment_ids': fields.one2many( + 'account.move.line', + 'check_deposit_id', + 'Check Payments', + readonly=True, + states={'draft': [('readonly', '=', False)]}), + 'deposit_date': fields.date( + 'Deposit Date', + readonly=True, + states={'draft': [('readonly', '=', False)]}), + 'journal_id': fields.many2one( + 'account.journal', + 'Journal', + required=True, + readonly=True, + states={'draft': [('readonly', '=', False)]}), 'state': fields.selection([ - ('draft','Draft'), - ('done','Done'), - ],'Status', readonly=True), - 'move_id': fields.many2one('account.move', 'Journal Entry', - readonly=True, - states={'draft':[('readonly',False)]}), - 'bank_id': fields.many2one('res.partner.bank', 'Bank', required=True, - readonly=True, - domain="[('partner_id', '=', partner_id)]", - states={'draft':[('readonly',False)]}), - 'line_ids': fields.related('move_id', 'line_id', + ('draft', 'Draft'), + ('done', 'Done'), + ], 'Status', + readonly=True), + 'move_id': fields.many2one( + 'account.move', + 'Journal Entry', + readonly=True, + states={'draft': [('readonly', '=', False)]}), + 'bank_id': fields.many2one( + 'res.partner.bank', + 'Bank', + required=True, + readonly=True, + domain="[('partner_id', '=', partner_id)]", + states={'draft': [('readonly', '=', False)]}), + 'line_ids': fields.related( + 'move_id', + 'line_id', relation='account.move.line', type='one2many', string='Lines', + readonly=True), + 'partner_id': fields.related( + 'company_id', + 'partner_id', + type="many2one", + relation="res.partner", + string="Partner", + readonly=True), + 'company_id': fields.many2one( + 'res.company', + 'Company', + required=True, + change_default=True, readonly=True, - ), - 'partner_id':fields.related('company_id', 'partner_id', type="many2one", - relation="res.partner", string="Partner", - readonly=True), - 'company_id': fields.many2one('res.company', 'Company', required=True, - change_default=True, readonly=True, - states={'draft':[('readonly',False)]}), - 'total_amount': fields.function(sum_amount, string ="total amount", type="float"), - 'is_reconcile': fields.function(_is_reconcile, string ="Reconcile", type="boolean"), + states={'draft': [('readonly', '=', False)]}), + 'total_amount': fields.function( + sum_amount, + string="total amount", + type="float"), + 'is_reconcile': fields.function( + _is_reconcile, + string="Reconcile", + type="boolean"), } _defaults = { 'name': lambda self, cr, uid, context: '/', 'deposit_date': fields.date.context_today, - 'state':'draft', - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.check.deposit', context=c), + 'state': 'draft', + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company').\ + _company_default_get(cr, uid, 'account.check.deposit', context=c), } def unlink(self, cr, uid, ids, context=None): @@ -104,7 +136,11 @@ class account_check_deposit(orm.Model): def cancel(self, cr, uid, ids, context=None): for deposit in self.browse(cr, uid, ids, context=context): if not deposit.journal_id.update_posted: - raise osv.except_osv(_('Error!'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) + raise osv.except_osv( + _('Error!'), + _('You cannot modify a posted entry of this journal.\n' + 'First you should set the journal to allow cancelling ' + 'entries.')) for line in deposit.check_payment_ids: if line.reconcile_id: line.reconcile_id.unlink() @@ -115,37 +151,50 @@ class account_check_deposit(orm.Model): return True def create(self, cr, uid, vals, context=None): - if vals.get('name','/')=='/': - vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'account.check.deposit') or '/' - return super(account_check_deposit, self).create(cr, uid, vals, context=context) + if vals.get('name', '/') == '/': + vals['name'] = self.pool.get('ir.sequence').\ + get(cr, uid, 'account.check.deposit') + return super(account_check_deposit, self).\ + create(cr, uid, vals, context=context) def _prepare_account_move_vals(self, cr, uid, deposit, context=None): + date = deposit.deposit_date move_vals = { 'journal_id': deposit.journal_id.id, - 'date': deposit.deposit_date, + 'date': date, } period_obj = self.pool['account.period'] - period_ids = period_obj.find(cr, uid, dt=deposit.deposit_date, context=context) + period_ids = period_obj.find(cr, uid, dt=date, context=context) if period_ids: move_vals['period_id'] = period_ids[0] + sum_move_line = self._prepare_sum_move_line_vals( + cr, uid, deposit, move_vals, context=context) + move_lines = [[0, 0, sum_move_line]] - move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, - move_vals, - context=context)]] for line in deposit.check_payment_ids: - move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, - move_vals, - context=context)]) + move_line = self._prepare_move_line_vals( + cr, uid, line, move_vals, context=context) + move_lines.append([0, 0, move_line]) + move_vals.update({'line_id': move_lines}) return move_vals def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): + fields_key = [ + 'centralisation', + 'date', + 'date_created', + 'currency_id', + 'journal_id', + 'amount_currency', + 'account_id', + 'period_id', + 'company_id', + ] + move_line_vals = self.pool.get('account.move.line').default_get( - cr, uid, - ['centralisation', 'date','date_created', 'currency_id', - 'journal_id', 'amount_currency', 'account_id', 'period_id', - 'company_id'], - context=context) + cr, uid, fields_key, context=context) + move_line_vals.update({ 'name': line.ref, 'credit': line.debit, @@ -156,22 +205,33 @@ class account_check_deposit(orm.Model): return move_line_vals def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): + #TODO did it's necessary to call default here? + #If yes it will be better to avoid code duplication with + #the prepare vals + fields_key = [ + 'centralisation', + 'date', + 'date_created', + 'currency_id', + 'journal_id', + 'amount_currency', + 'account_id', + 'period_id', + 'company_id', + 'state', + ] + move_line_vals = self.pool.get('account.move.line').default_get( - cr, uid, - ['centralisation', 'date','date_created', 'currency_id', - 'journal_id', 'amount_currency', 'account_id', 'period_id', - 'company_id', 'state'], - context=context) + cr, uid, fields_key, context=context) debit = 0.0 for line in deposit.check_payment_ids: debit += line.debit move_line_vals.update({ - 'name': deposit.name, - 'debit': debit, - 'ref': deposit.name, - }) - + 'name': deposit.name, + 'debit': debit, + 'ref': deposit.name, + }) return move_line_vals def _reconcile_checks(self, cr, uid, move_id, context=None): @@ -180,21 +240,19 @@ class account_check_deposit(orm.Model): move = move_obj.browse(cr, uid, move_id, context=context) for line in move.line_id: if line.check_line_id: - move_line_obj.reconcile(cr, uid, - [line.id, line.check_line_id.id], - context=context) + move_line_obj.reconcile(cr, uid, [ + line.id, + line.check_line_id.id, + ], context=context) return True - - def onchange_company_id(self, cr, uid, ids, company_id, context=None): - vals={} + vals = {} if company_id: - company=self.pool.get('res.company').browse(cr, uid, company_id, context=context) - vals['partner_id']=company.partner_id.id - return {'value':vals} - - + company = self.pool.get('res.company').\ + browse(cr, uid, company_id, context=context) + vals['partner_id'] = company.partner_id.id + return {'value': vals} def validate_deposit(self, cr, uid, ids, context=None): move_obj = self.pool.get('account.move') @@ -206,7 +264,7 @@ class account_check_deposit(orm.Model): move_id = move_obj.create(cr, uid, move_vals, context=context) move_obj.post(cr, uid, [move_id], context=context) self._reconcile_checks(cr, uid, move_id, context=context) - deposit.write({'state':'done', 'move_id': move_id}) + deposit.write({'state': 'done', 'move_id': move_id}) return True @@ -214,8 +272,10 @@ class account_move_line(orm.Model): _inherit = "account.move.line" _columns = { - 'check_deposit_id': fields.many2one('account.check.deposit', - 'Check Deposit'), - 'check_line_id': fields.many2one('account.move.line', - 'Check Receive Move line'), + 'check_deposit_id': fields.many2one( + 'account.check.deposit', + 'Check Deposit'), + 'check_line_id': fields.many2one( + 'account.move.line', + 'Check Receive Move line'), } diff --git a/account_check_deposit/report/report_webkit_html.py b/account_check_deposit/report/report_webkit_html.py index 459915868..63fba5ef0 100644 --- a/account_check_deposit/report/report_webkit_html.py +++ b/account_check_deposit/report/report_webkit_html.py @@ -23,18 +23,19 @@ import time from report import report_sxw -from osv import osv + class report_webkit_html(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): super(report_webkit_html, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, - 'cr':cr, + 'cr': cr, 'uid': uid, }) report_sxw.report_sxw('report.account.check.deposit', - 'account.check.deposit', - 'addons/account_check_deposit/report/check_deposit.mako', - parser=report_webkit_html) + 'account.check.deposit', + 'addons/account_check_deposit/report/check_deposit.mako', + parser=report_webkit_html) From 3e0c34c00fd8dec030f940357f9f80b655153c63 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Tue, 11 Mar 2014 00:31:58 +0100 Subject: [PATCH 20/26] [REF] clean remove useless code, default value are called during the create --- account_check_deposit/account_deposit.py | 44 +++--------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 6816d41da..49f95fdb1 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -180,59 +180,23 @@ class account_check_deposit(orm.Model): return move_vals def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): - fields_key = [ - 'centralisation', - 'date', - 'date_created', - 'currency_id', - 'journal_id', - 'amount_currency', - 'account_id', - 'period_id', - 'company_id', - ] - - move_line_vals = self.pool.get('account.move.line').default_get( - cr, uid, fields_key, context=context) - - move_line_vals.update({ + return { 'name': line.ref, 'credit': line.debit, 'account_id': line.account_id.id, 'partner_id': line.partner_id.id, 'check_line_id': line.id, - }) - return move_line_vals + } def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): - #TODO did it's necessary to call default here? - #If yes it will be better to avoid code duplication with - #the prepare vals - fields_key = [ - 'centralisation', - 'date', - 'date_created', - 'currency_id', - 'journal_id', - 'amount_currency', - 'account_id', - 'period_id', - 'company_id', - 'state', - ] - - move_line_vals = self.pool.get('account.move.line').default_get( - cr, uid, fields_key, context=context) - debit = 0.0 for line in deposit.check_payment_ids: debit += line.debit - move_line_vals.update({ + return { 'name': deposit.name, 'debit': debit, 'ref': deposit.name, - }) - return move_line_vals + } def _reconcile_checks(self, cr, uid, move_id, context=None): move_line_obj = self.pool['account.move.line'] From a0651738d13dfc4f1d68e1e08ba3b2dd230435e0 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Tue, 11 Mar 2014 00:41:33 +0100 Subject: [PATCH 21/26] [FIX] fix wrong spelling --- account_check_deposit/__openerp__.py | 2 +- account_check_deposit/account_deposit_view.xml | 2 +- account_check_deposit/account_type_data.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 9fd281ee2..86e554bb7 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -30,7 +30,7 @@ 'description': """This module allows you to use check deposits. With a new model : account_check_deposit you can select all the checks payments and create a global deposit for the selected checks. - You may have to create an account for recieved checks and a journal for payment by checks.""", + You may have to create an account for received checks and a journal for payment by checks.""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', 'depends': ['account_accountant', diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index 580d65f10..59f6eb90f 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -54,7 +54,7 @@ + ('account_id.user_type.code','=','received_check')]"> diff --git a/account_check_deposit/account_type_data.xml b/account_check_deposit/account_type_data.xml index 1d34fc717..fd47d8a45 100644 --- a/account_check_deposit/account_type_data.xml +++ b/account_check_deposit/account_type_data.xml @@ -11,8 +11,8 @@ - Recieved Checks - recieved_check + Received Checks + received_check none From c44a194deee7bec39668ca91e00aaa48bf4b2f40 Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Tue, 11 Mar 2014 00:55:19 +0100 Subject: [PATCH 22/26] [REF] V7 clean up --- account_check_deposit/__openerp__.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 86e554bb7..230c2e0b0 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -20,8 +20,6 @@ # # ############################################################################### - - { 'name': 'account_check_deposit', 'version': '0.1', @@ -30,20 +28,21 @@ 'description': """This module allows you to use check deposits. With a new model : account_check_deposit you can select all the checks payments and create a global deposit for the selected checks. - You may have to create an account for received checks and a journal for payment by checks.""", + You may have to create an account for "received checks" and a + journal for payment by checks.""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': ['account_accountant', - 'report_webkit', - ], - 'init_xml': [], - 'update_xml': [ - 'account_deposit_view.xml', - 'account_deposit_sequence.xml', - 'account_type_data.xml', - 'security/ir.model.access.csv', + 'depends': [ + 'account_accountant', + 'report_webkit', + ], + 'data': [ + 'account_deposit_view.xml', + 'account_deposit_sequence.xml', + 'account_type_data.xml', + 'security/ir.model.access.csv', ], - 'demo_xml': [], 'installable': True, + 'application': True, 'active': False, } From 4f660eec2875e6994697d1045f9892dab98a827e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 8 Oct 2014 13:47:28 +0200 Subject: [PATCH 23/26] Add support for multi-currency Works with a single account journal Usability and many other enhancements --- account_check_deposit/__init__.py | 37 +- account_check_deposit/__openerp__.py | 65 ++-- account_check_deposit/account_data.xml | 32 ++ account_check_deposit/account_deposit.py | 368 ++++++++++++------ .../account_deposit_sequence.xml | 5 +- .../account_deposit_view.xml | 134 +++---- account_check_deposit/account_type_data.xml | 20 - account_check_deposit/company_view.xml | 25 ++ account_check_deposit/report/__init__.py | 40 +- .../report/check_deposit.mako | 66 ++-- .../report/report_webkit_html.py | 35 +- .../security/check_deposit_security.xml | 20 + 12 files changed, 505 insertions(+), 342 deletions(-) create mode 100644 account_check_deposit/account_data.xml delete mode 100644 account_check_deposit/account_type_data.xml create mode 100644 account_check_deposit/company_view.xml create mode 100644 account_check_deposit/security/check_deposit_security.xml diff --git a/account_check_deposit/__init__.py b/account_check_deposit/__init__.py index 91e61fc83..20b98b3f5 100644 --- a/account_check_deposit/__init__.py +++ b/account_check_deposit/__init__.py @@ -1,23 +1,22 @@ # -*- coding: utf-8 -*- ############################################################################### -# # -# account_check_deposit for OpenERP # -# Copyright (C) 2012 Akretion Benoît GUILLOT # -# # -# 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 . # -# # +# +# account_check_deposit for Odoo/OpenERP +# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/) +# +# 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 . +# ############################################################################### -import account_deposit - +from . import account_deposit diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 230c2e0b0..815a7555a 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -1,35 +1,45 @@ # -*- coding: utf-8 -*- ############################################################################### -# # -# account_check_deposit for OpenERP # -# Copyright (C) 2012 Akretion Benoît GUILLOT # -# Copyright (C) 2013 Akretion Chafique DELLI # -# # -# 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 . # -# # +# +# account_check_deposit for Odoo/OpenERP +# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/) +# @author: Benoît GUILLOT +# @author: Chafique DELLI +# @author: Alexis de Lattre +# +# 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 . +# ############################################################################### { - 'name': 'account_check_deposit', + 'name': 'Account Check Deposit', 'version': '0.1', - 'category': 'Generic Modules/Others', + 'category': 'Accounting & Finance', 'license': 'AGPL-3', - 'description': """This module allows you to use check deposits. - With a new model : account_check_deposit you can select all - the checks payments and create a global deposit for the selected checks. - You may have to create an account for "received checks" and a - journal for payment by checks.""", + 'summary': 'Manage deposit of checks to the bank', + 'description': """ +Account Check Deposit +===================== +This module allows you to easily manage check deposits : you can select all +the checks you received as payments and create a global deposit for the +selected checks. + +A journal for received checks is automatically created. +You must configure on this journal the default debit account and the default +credit account. You must also configure on the company the account for +check deposits. +""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', 'depends': [ @@ -39,10 +49,11 @@ 'data': [ 'account_deposit_view.xml', 'account_deposit_sequence.xml', - 'account_type_data.xml', + 'company_view.xml', 'security/ir.model.access.csv', + 'security/check_deposit_security.xml', + 'account_data.xml', ], 'installable': True, 'application': True, - 'active': False, } diff --git a/account_check_deposit/account_data.xml b/account_check_deposit/account_data.xml new file mode 100644 index 000000000..8bc79336f --- /dev/null +++ b/account_check_deposit/account_data.xml @@ -0,0 +1,32 @@ + + + + + + + + + Journal Check Received + CHK/ + 6 + + + + + + Check Received + CHK + bank + + + + + + + diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index 49f95fdb1..c635af95d 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -1,59 +1,69 @@ # -*- coding: utf-8 -*- ############################################################################### -# # -# account_check_deposit for OpenERP # -# Copyright (C) 2012 Akretion Benoît GUILLOT # -# Copyright (C) 2013 Akretion Chafique DELLI # -# # -# 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 . # -# # +# +# account_check_deposit for Odoo/OpenERP +# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/) +# @author: Benoît GUILLOT +# @author: Chafique DELLI +# @author: Alexis de Lattre +# +# 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 . +# ############################################################################### -from openerp.osv import fields, osv, orm +from openerp.osv import fields, orm from openerp.tools.translate import _ +import openerp.addons.decimal_precision as dp class account_check_deposit(orm.Model): _name = "account.check.deposit" _description = "Account Check Deposit" + _order = 'deposit_date desc' - def sum_amount(self, cr, uid, ids, name, args, context=None): + def _compute_check_deposit(self, cr, uid, ids, name, args, context=None): res = {} for deposit in self.browse(cr, uid, ids, context=context): - total = 0 + total = 0.0 + count = 0 + reconcile = False + currency_none_same_company_id = False + if deposit.company_id.currency_id != deposit.currency_id: + currency_none_same_company_id = deposit.currency_id.id for line in deposit.check_payment_ids: - total += line.debit - res[deposit.id] = total - return res - - def _is_reconcile(self, cr, uid, ids, name, args, context=None): - res = {} - for deposit in self.browse(cr, uid, ids, context=context): - res[deposit.id] = False + count += 1 + if currency_none_same_company_id: + total += line.amount_currency + else: + total += line.debit if deposit.move_id: for line in deposit.move_id.line_id: if line.debit > 0 and line.reconcile_id: - res[deposit.id] = True + reconcile = True + res[deposit.id] = { + 'total_amount': total, + 'is_reconcile': reconcile, + 'currency_none_same_company_id': currency_none_same_company_id, + 'check_count': count, + } return res _columns = { 'name': fields.char( 'Name', size=64, - required=True, - readonly=True, - states={'draft': [('readonly', '=', False)]}), + readonly=True), 'check_payment_ids': fields.one2many( 'account.move.line', 'check_deposit_id', @@ -62,14 +72,27 @@ class account_check_deposit(orm.Model): states={'draft': [('readonly', '=', False)]}), 'deposit_date': fields.date( 'Deposit Date', + required=True, readonly=True, states={'draft': [('readonly', '=', False)]}), 'journal_id': fields.many2one( 'account.journal', 'Journal', + domain=[('type', '=', 'bank')], required=True, readonly=True, states={'draft': [('readonly', '=', False)]}), + 'journal_default_account_id': fields.related( + 'journal_id', 'default_debit_account_id', type='many2one', + relation='account.account', + string='Default Debit Account of the Journal'), + 'currency_id': fields.many2one( + 'res.currency', 'Currency', required=True, readonly=True, + states={'draft': [('readonly', '=', False)]}), + 'currency_none_same_company_id': fields.function( + _compute_check_deposit, type='many2one', + relation='res.currency', multi='deposit', + string='Currency (False if same as company)'), 'state': fields.selection([ ('draft', 'Draft'), ('done', 'Done'), @@ -78,14 +101,13 @@ class account_check_deposit(orm.Model): 'move_id': fields.many2one( 'account.move', 'Journal Entry', - readonly=True, - states={'draft': [('readonly', '=', False)]}), - 'bank_id': fields.many2one( + readonly=True), + 'partner_bank_id': fields.many2one( 'res.partner.bank', - 'Bank', + 'Bank Account', required=True, readonly=True, - domain="[('partner_id', '=', partner_id)]", + domain="[('company_id', '=', company_id)]", states={'draft': [('readonly', '=', False)]}), 'line_ids': fields.related( 'move_id', @@ -94,13 +116,6 @@ class account_check_deposit(orm.Model): type='one2many', string='Lines', readonly=True), - 'partner_id': fields.related( - 'company_id', - 'partner_id', - type="many2one", - relation="res.partner", - string="Partner", - readonly=True), 'company_id': fields.many2one( 'res.company', 'Company', @@ -109,128 +124,225 @@ class account_check_deposit(orm.Model): readonly=True, states={'draft': [('readonly', '=', False)]}), 'total_amount': fields.function( - sum_amount, - string="total amount", - type="float"), + _compute_check_deposit, + multi='deposit', + string="Total Amount", + type="float", digits_compute=dp.get_precision('Account')), + 'check_count': fields.function( + _compute_check_deposit, multi='deposit', + string="Number of Checks", type="integer"), 'is_reconcile': fields.function( - _is_reconcile, + _compute_check_deposit, + multi='deposit', string="Reconcile", type="boolean"), } _defaults = { - 'name': lambda self, cr, uid, context: '/', + 'name': '/', 'deposit_date': fields.date.context_today, 'state': 'draft', - 'company_id': lambda self, cr, uid, c: self.pool.get('res.company').\ - _company_default_get(cr, uid, 'account.check.deposit', context=c), + 'company_id': lambda self, cr, uid, c: self.pool['res.company']. + _company_default_get(cr, uid, 'account.check.deposit', context=c), } + def _check_deposit(self, cr, uid, ids): + for deposit in self.browse(cr, uid, ids): + deposit_currency = deposit.currency_id + if deposit_currency == deposit.company_id.currency_id: + for line in deposit.check_payment_ids: + if line.currency_id: + raise orm.except_orm( + _('Error:'), + _("The check with amount %s and reference '%s' " + "is in currency %s but the deposit is in " + "currency %s.") % ( + line.debit, line.ref or '', + line.currency_id.name, + deposit_currency.name)) + else: + for line in deposit.check_payment_ids: + if line.currency_id != deposit_currency: + raise orm.except_orm( + _('Error:'), + _("The check with amount %s and reference '%s' " + "is in currency %s but the deposit is in " + "currency %s.") % ( + line.debit, line.ref or '', + line.currency_id.name, + deposit_currency.name)) + return True + + _constraints = [( + _check_deposit, + "All the checks of the deposit must be in the currency of the deposit", + ['currency_id', 'check_payment_ids', 'company_id'] + )] + def unlink(self, cr, uid, ids, context=None): for deposit in self.browse(cr, uid, ids, context=context): if deposit.state == 'done': - raise osv.except_osv(_('User Error!'), - _('You cannot delete a validad deposit, cancel it before')) - return super(account_check_deposit, self).unlink(cr, uid, ids, context=context) - - def cancel(self, cr, uid, ids, context=None): - for deposit in self.browse(cr, uid, ids, context=context): - if not deposit.journal_id.update_posted: - raise osv.except_osv( + raise orm.except_orm( _('Error!'), - _('You cannot modify a posted entry of this journal.\n' - 'First you should set the journal to allow cancelling ' - 'entries.')) - for line in deposit.check_payment_ids: - if line.reconcile_id: - line.reconcile_id.unlink() + _("The deposit '%s' is in valid state, so you must " + "cancel it before deleting it.") + % deposit.name) + return super(account_check_deposit, self).unlink( + cr, uid, ids, context=context) + + def backtodraft(self, cr, uid, ids, context=None): + for deposit in self.browse(cr, uid, ids, context=context): if deposit.move_id: + # It will raise here if journal_id.update_posted = False deposit.move_id.button_cancel() + for line in deposit.check_payment_ids: + if line.reconcile_id: + line.reconcile_id.unlink() deposit.move_id.unlink() deposit.write({'state': 'draft'}) return True def create(self, cr, uid, vals, context=None): if vals.get('name', '/') == '/': - vals['name'] = self.pool.get('ir.sequence').\ - get(cr, uid, 'account.check.deposit') + vals['name'] = self.pool['ir.sequence'].\ + next_by_code(cr, uid, 'account.check.deposit') return super(account_check_deposit, self).\ create(cr, uid, vals, context=context) def _prepare_account_move_vals(self, cr, uid, deposit, context=None): date = deposit.deposit_date + period_obj = self.pool['account.period'] + period_ids = period_obj.find(cr, uid, dt=date, context=context) + # period_ids will always have a value, cf the code of find() move_vals = { 'journal_id': deposit.journal_id.id, 'date': date, + 'period_id': period_ids[0], + 'name': _('Check Deposit %s') % deposit.name, + 'ref': deposit.name, } - period_obj = self.pool['account.period'] - period_ids = period_obj.find(cr, uid, dt=date, context=context) - if period_ids: - move_vals['period_id'] = period_ids[0] - sum_move_line = self._prepare_sum_move_line_vals( - cr, uid, deposit, move_vals, context=context) - move_lines = [[0, 0, sum_move_line]] - - for line in deposit.check_payment_ids: - move_line = self._prepare_move_line_vals( - cr, uid, line, move_vals, context=context) - move_lines.append([0, 0, move_line]) - - move_vals.update({'line_id': move_lines}) return move_vals - def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None): + def _prepare_move_line_vals( + self, cr, uid, line, context=None): + assert (line.debit > 0), 'Debit must have a value' return { - 'name': line.ref, + 'name': _('Check Deposit - Ref. Check %s') % line.ref, 'credit': line.debit, + 'debit': 0.0, 'account_id': line.account_id.id, 'partner_id': line.partner_id.id, - 'check_line_id': line.id, - } + 'currency_id': line.currency_id.id or False, + 'amount_currency': line.amount_currency * -1, + } - def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None): - debit = 0.0 - for line in deposit.check_payment_ids: - debit += line.debit + def _prepare_counterpart_move_lines_vals( + self, cr, uid, deposit, total_debit, total_amount_currency, + context=None): return { - 'name': deposit.name, - 'debit': debit, - 'ref': deposit.name, - } - - def _reconcile_checks(self, cr, uid, move_id, context=None): - move_line_obj = self.pool['account.move.line'] - move_obj = self.pool['account.move'] - move = move_obj.browse(cr, uid, move_id, context=context) - for line in move.line_id: - if line.check_line_id: - move_line_obj.reconcile(cr, uid, [ - line.id, - line.check_line_id.id, - ], context=context) - return True - - def onchange_company_id(self, cr, uid, ids, company_id, context=None): - vals = {} - if company_id: - company = self.pool.get('res.company').\ - browse(cr, uid, company_id, context=context) - vals['partner_id'] = company.partner_id.id - return {'value': vals} + 'name': _('Check Deposit %s') % deposit.name, + 'debit': total_debit, + 'credit': 0.0, + 'account_id': deposit.company_id.check_deposit_account_id.id, + 'partner_id': False, + 'currency_id': deposit.currency_none_same_company_id.id or False, + 'amount_currency': total_amount_currency, + } def validate_deposit(self, cr, uid, ids, context=None): - move_obj = self.pool.get('account.move') + am_obj = self.pool['account.move'] + aml_obj = self.pool['account.move.line'] if context is None: context = {} for deposit in self.browse(cr, uid, ids, context=context): - context['journal_id'] = deposit.journal_id.id - move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context) - move_id = move_obj.create(cr, uid, move_vals, context=context) - move_obj.post(cr, uid, [move_id], context=context) - self._reconcile_checks(cr, uid, move_id, context=context) + move_vals = self._prepare_account_move_vals( + cr, uid, deposit, context=context) + context['journal_id'] = move_vals['journal_id'] + context['period_id'] = move_vals['period_id'] + move_id = am_obj.create(cr, uid, move_vals, context=context) + total_debit = 0.0 + total_amount_currency = 0.0 + to_reconcile_line_ids = [] + for line in deposit.check_payment_ids: + total_debit += line.debit + total_amount_currency += line.amount_currency + line_vals = self._prepare_move_line_vals( + cr, uid, line, context=context) + line_vals['move_id'] = move_id + move_line_id = aml_obj.create( + cr, uid, line_vals, context=context) + to_reconcile_line_ids.append([line.id, move_line_id]) + + # Create counter-part + if not deposit.company_id.check_deposit_account_id: + raise orm.except_orm( + _('Configuration Error:'), + _("Missing Account for Check Deposits on the " + "company '%s'.") % deposit.company_id.name) + + counter_vals = self._prepare_counterpart_move_lines_vals( + cr, uid, deposit, total_debit, total_amount_currency, + context=context) + counter_vals['move_id'] = move_id + aml_obj.create(cr, uid, counter_vals, context=context) + + am_obj.post(cr, uid, [move_id], context=context) deposit.write({'state': 'done', 'move_id': move_id}) + # We have to reconcile after post() + for reconcile_line_ids in to_reconcile_line_ids: + aml_obj.reconcile( + cr, uid, reconcile_line_ids, context=context) return True + def onchange_company_id( + self, cr, uid, ids, company_id, currency_id, context=None): + vals = {} + if company_id: + company = self.pool['res.company'].browse( + cr, uid, company_id, context=context) + if currency_id: + if company.currency_id.id == currency_id: + vals['currency_none_same_company_id'] = False + else: + vals['currency_none_same_company_id'] = currency_id + partner_bank_ids = self.pool['res.partner.bank'].search( + cr, uid, [('company_id', '=', company_id)], context=context) + if len(partner_bank_ids) == 1: + vals['partner_bank_id'] = partner_bank_ids[0] + else: + vals['currency_none_same_company_id'] = False + vals['partner_bank_id'] = False + return {'value': vals} + + def onchange_journal_id(self, cr, uid, ids, journal_id, context=None): + vals = {} + if journal_id: + journal = self.pool['account.journal'].browse( + cr, uid, journal_id, context=context) + vals['journal_default_account_id'] = \ + journal.default_debit_account_id.id + if journal.currency: + vals['currency_id'] = journal.currency.id + else: + vals['currency_id'] = journal.company_id.currency_id.id + else: + vals['journal_default_account_id'] = False + return {'value': vals} + + def onchange_currency_id( + self, cr, uid, ids, currency_id, company_id, context=None): + vals = {} + if currency_id and company_id: + company = self.pool['res.company'].browse( + cr, uid, company_id, context=context) + if company.currency_id.id == currency_id: + vals['currency_none_same_company_id'] = False + else: + vals['currency_none_same_company_id'] = currency_id + else: + vals['currency_none_same_company_id'] = False + return {'value': vals} + class account_move_line(orm.Model): _inherit = "account.move.line" @@ -239,7 +351,17 @@ class account_move_line(orm.Model): 'check_deposit_id': fields.many2one( 'account.check.deposit', 'Check Deposit'), - 'check_line_id': fields.many2one( - 'account.move.line', - 'Check Receive Move line'), } + + +class res_company(orm.Model): + _inherit = 'res.company' + + _columns = { + 'check_deposit_account_id': fields.many2one( + 'account.account', 'Account for Check Deposits', + domain=[ + ('type', '<>', 'view'), + ('type', '<>', 'closed'), + ('reconcile', '=', True)]), + } diff --git a/account_check_deposit/account_deposit_sequence.xml b/account_check_deposit/account_deposit_sequence.xml index 2208a5dbe..912b8047b 100644 --- a/account_check_deposit/account_deposit_sequence.xml +++ b/account_check_deposit/account_deposit_sequence.xml @@ -1,7 +1,8 @@ diff --git a/account_check_deposit/account_deposit_view.xml b/account_check_deposit/account_deposit_view.xml index 59f6eb90f..f4b61143b 100644 --- a/account_check_deposit/account_deposit_view.xml +++ b/account_check_deposit/account_deposit_view.xml @@ -1,8 +1,10 @@ @@ -15,82 +17,81 @@ model="account.check.deposit" name="check.deposit.webkit" report_type="webkit" - string="Print Checks Deposit"/> - - + string="Checks Deposit"/> - account_check_deposit.account_check_deposit.view_form + account.check.deposit.form account.check.deposit - form

-

- - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - -
- account_check_deposit.account_check_deposit.view_tree + account.check.deposit.tree account.check.deposit - tree - + - - + + + + @@ -101,28 +102,31 @@ - - - - + + + + + + +
- Checks Deposit + Checks Deposits account.check.deposit - form - tree,form,graph - [] - {} - - + tree,form - diff --git a/account_check_deposit/account_type_data.xml b/account_check_deposit/account_type_data.xml deleted file mode 100644 index fd47d8a45..000000000 --- a/account_check_deposit/account_type_data.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - Received Checks - received_check - none - - - - diff --git a/account_check_deposit/company_view.xml b/account_check_deposit/company_view.xml new file mode 100644 index 000000000..74b9019e4 --- /dev/null +++ b/account_check_deposit/company_view.xml @@ -0,0 +1,25 @@ + + + + + + + + + check.deposit.company.form + res.company + + + + + + + + + + + diff --git a/account_check_deposit/report/__init__.py b/account_check_deposit/report/__init__.py index 285cd87c3..6d4950f0c 100644 --- a/account_check_deposit/report/__init__.py +++ b/account_check_deposit/report/__init__.py @@ -1,32 +1,22 @@ - #-*- coding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) -# All Right Reserved +# account_check_deposit for Odoo/OpenERP +# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/) # -# Author : Ferdinand Gassauer (Camptocamp Austria) +# 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. # -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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. # -# 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 2 -# of the License, or (at your option) any later version. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## +############################################################################### -import report_webkit_html +from . import report_webkit_html diff --git a/account_check_deposit/report/check_deposit.mako b/account_check_deposit/report/check_deposit.mako index f2b5afe19..67a660ebe 100644 --- a/account_check_deposit/report/check_deposit.mako +++ b/account_check_deposit/report/check_deposit.mako @@ -37,76 +37,54 @@ %for deposit in objects : -<% setLang(deposit.partner_id.lang) %> -${_("Deposit Slip of Checks(Euros)")} -
-
-
-
-
-
-

-${_("Deposit N°")} ${deposit.name} -

+<% setLang(deposit.company_id.partner_id.lang) %> +${_("Deposit Slip of Checks in ")} ${deposit.currency_id.name} -

-${_("Deposit Date")}${_("|")} - ${deposit.deposit_date} -${_("Bank Code")} -${_("|")} ${deposit.bank_id.bank_code} -
-${_("Beneficiary")}${_("|")} - ${company.partner_id.name} -${_("Office Code")} -${_("|")} ${deposit.bank_id.office} -
-${_("Account to crediting")}${_("|")} - ${deposit.bank_id.rib_acc_number} -${_("BIS Key")}${_("|")} - ${deposit.bank_id.key} -

-
-

-${_("Check Payments")} -

+ + + + + + + + + + + + + +
${_("Deposit Date")}${_("Deposit Ref")}${_("Beneficiary")}${_("Bank Account Number")}
${formatLang(deposit.deposit_date, date=True)}${deposit.name}${deposit.company_id.partner_id.name}${deposit.partner_bank_id.acc_number}
+ +

${_("Check Payments")}

- - + -
%for move_line in deposit.check_payment_ids : - - + %endfor %endfor - - + +
${_("Payment Date")} ${_("Reference")}${_("Description")}${_("Designation")}${_("Debtor")} ${_("Amount")}
${move_line.date or ''} ${move_line.ref or ''}${move_line.name or ''} ${move_line.partner_id.name or ''}${move_line.debit or '0'}${deposit.currency_id == deposit.company_id.currency_id and move_line.debit or move_line.amount_currency} ${deposit.currency_id.name}
${_("Total:")}${deposit.total_amount or '0'}${_("Total:")}${deposit.total_amount or '0'} ${deposit.currency_id.name}
- - - - - - diff --git a/account_check_deposit/report/report_webkit_html.py b/account_check_deposit/report/report_webkit_html.py index 63fba5ef0..9d8a2f77c 100644 --- a/account_check_deposit/report/report_webkit_html.py +++ b/account_check_deposit/report/report_webkit_html.py @@ -1,34 +1,35 @@ # -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# Copyright (C) 2010-2012 Camptocamp Austria () -# Copyright (C) 2013 AKRETION () +# account_check_deposit for Odoo/OpenERP +# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/) +# @author: Benoît GUILLOT +# @author: Chafique DELLI # -# 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 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. +# 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 . +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # -############################################################################## +############################################################################### import time from report import report_sxw class report_webkit_html(report_sxw.rml_parse): - + def __init__(self, cr, uid, name, context): - super(report_webkit_html, self).__init__(cr, uid, name, context=context) + super(report_webkit_html, self).__init__( + cr, uid, name, context=context) self.localcontext.update({ 'time': time, 'cr': cr, diff --git a/account_check_deposit/security/check_deposit_security.xml b/account_check_deposit/security/check_deposit_security.xml new file mode 100644 index 000000000..0a952aa30 --- /dev/null +++ b/account_check_deposit/security/check_deposit_security.xml @@ -0,0 +1,20 @@ + + + + + + + + + Check Deposit multi-company + + + ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + + + From e9e9d97ab52796928928a3abfdecad64b308bc49 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 8 Oct 2014 22:03:58 +0200 Subject: [PATCH 24/26] Update field definition --- account_check_deposit/account_deposit.py | 71 ++++++++---------------- 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/account_check_deposit/account_deposit.py b/account_check_deposit/account_deposit.py index c635af95d..a98df3166 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -61,34 +61,23 @@ class account_check_deposit(orm.Model): _columns = { 'name': fields.char( - 'Name', - size=64, - readonly=True), + 'Name', size=64, readonly=True), 'check_payment_ids': fields.one2many( - 'account.move.line', - 'check_deposit_id', - 'Check Payments', - readonly=True, - states={'draft': [('readonly', '=', False)]}), + 'account.move.line', 'check_deposit_id', 'Check Payments', + states={'done': [('readonly', '=', True)]}), 'deposit_date': fields.date( - 'Deposit Date', - required=True, - readonly=True, - states={'draft': [('readonly', '=', False)]}), + 'Deposit Date', required=True, + states={'done': [('readonly', '=', True)]}), 'journal_id': fields.many2one( - 'account.journal', - 'Journal', - domain=[('type', '=', 'bank')], - required=True, - readonly=True, - states={'draft': [('readonly', '=', False)]}), + 'account.journal', 'Journal', domain=[('type', '=', 'bank')], + required=True, states={'done': [('readonly', '=', True)]}), 'journal_default_account_id': fields.related( 'journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Default Debit Account of the Journal'), 'currency_id': fields.many2one( - 'res.currency', 'Currency', required=True, readonly=True, - states={'draft': [('readonly', '=', False)]}), + 'res.currency', 'Currency', required=True, + states={'done': [('readonly', '=', True)]}), 'currency_none_same_company_id': fields.function( _compute_check_deposit, type='many2one', relation='res.currency', multi='deposit', @@ -96,46 +85,30 @@ class account_check_deposit(orm.Model): 'state': fields.selection([ ('draft', 'Draft'), ('done', 'Done'), - ], 'Status', - readonly=True), + ], 'Status', readonly=True), 'move_id': fields.many2one( - 'account.move', - 'Journal Entry', - readonly=True), + 'account.move', 'Journal Entry', readonly=True), 'partner_bank_id': fields.many2one( - 'res.partner.bank', - 'Bank Account', - required=True, - readonly=True, + 'res.partner.bank', 'Bank Account', required=True, domain="[('company_id', '=', company_id)]", - states={'draft': [('readonly', '=', False)]}), + states={'done': [('readonly', '=', True)]}), 'line_ids': fields.related( - 'move_id', - 'line_id', - relation='account.move.line', - type='one2many', - string='Lines', - readonly=True), + 'move_id', 'line_id', relation='account.move.line', + type='one2many', string='Lines', readonly=True), 'company_id': fields.many2one( - 'res.company', - 'Company', - required=True, + 'res.company', 'Company', required=True, change_default=True, - readonly=True, - states={'draft': [('readonly', '=', False)]}), + states={'done': [('readonly', '=', True)]}), 'total_amount': fields.function( - _compute_check_deposit, - multi='deposit', - string="Total Amount", + _compute_check_deposit, multi='deposit', + string="Total Amount", readonly=True, type="float", digits_compute=dp.get_precision('Account')), 'check_count': fields.function( - _compute_check_deposit, multi='deposit', + _compute_check_deposit, multi='deposit', readonly=True, string="Number of Checks", type="integer"), 'is_reconcile': fields.function( - _compute_check_deposit, - multi='deposit', - string="Reconcile", - type="boolean"), + _compute_check_deposit, multi='deposit', readonly=True, + string="Reconcile", type="boolean"), } _defaults = { From b8825b9bf8c206484ed8ca997ee2edcdfef87718 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 5 Nov 2014 22:39:18 +0100 Subject: [PATCH 25/26] Fix flake8 warning --- account_check_deposit/__openerp__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/account_check_deposit/__openerp__.py b/account_check_deposit/__openerp__.py index 815a7555a..136b6dc1d 100644 --- a/account_check_deposit/__openerp__.py +++ b/account_check_deposit/__openerp__.py @@ -47,12 +47,12 @@ check deposits. 'report_webkit', ], 'data': [ - 'account_deposit_view.xml', - 'account_deposit_sequence.xml', - 'company_view.xml', - 'security/ir.model.access.csv', - 'security/check_deposit_security.xml', - 'account_data.xml', + 'account_deposit_view.xml', + 'account_deposit_sequence.xml', + 'company_view.xml', + 'security/ir.model.access.csv', + 'security/check_deposit_security.xml', + 'account_data.xml', ], 'installable': True, 'application': True, From 3bca9518b1baaa06bb083d84669387dc0e3a8e4b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 6 Nov 2014 12:25:52 +0100 Subject: [PATCH 26/26] Remove hidden unused files --- account_check_deposit/report/.directory | 6 - account_check_deposit/report/.mako | 275 ------------------------ 2 files changed, 281 deletions(-) delete mode 100644 account_check_deposit/report/.directory delete mode 100644 account_check_deposit/report/.mako diff --git a/account_check_deposit/report/.directory b/account_check_deposit/report/.directory deleted file mode 100644 index 616766eae..000000000 --- a/account_check_deposit/report/.directory +++ /dev/null @@ -1,6 +0,0 @@ -[Dolphin] -AdditionalInfoV2=Details_Size,Details_Date,CustomizedDetails -Sorting=2 -Timestamp=2012,3,5,14,27,49 -Version=2 -ViewMode=1 diff --git a/account_check_deposit/report/.mako b/account_check_deposit/report/.mako deleted file mode 100644 index 63e5128f9..000000000 --- a/account_check_deposit/report/.mako +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - - <% - def carriage_returns(text): - return text.replace('\n', '
') - %> - - %for order in objects : -
- <% setLang(order.partner_id.lang) %> - - %if order.company_id.address_label_position == 'left': - - - - - - %endif - - %if order.company_id.address_label_position == 'right' or not order.company_id.address_label_position: - - - - - %endif -
-${_("Shipping Address")} -
-
-${order.partner_shipping_id.address_label}
-           
-         
- %if order.partner_id.address_label != order.partner_shipping_id.address_label: -${_("Ordering Contact")}
-${order.partner_id.address_label|carriage_returns} - %endif - %if order.partner_id.phone : -${_("Phone")}: ${order.partner_id.phone|entity}
- %endif - %if order.partner_id.fax : -${_("Fax")}: ${order.partner_id.fax|entity}
- %endif - %if order.partner_id.email : -${_("Mail")}: ${order.partner_id.email|entity}
- %endif - %if order.partner_invoice_id.address_label != order.partner_shipping_id.address_label: -
-${_("Invoice Address")}
-${order.partner_invoice_id.address_label|carriage_returns} - %endif - %if order.partner_invoice_id.partner_id.vat : -${_("VAT")}: ${order.partner_invoice_id.partner_id.vat|entity}
- %endif - -
- %if order.partner_id.address_label != order.partner_shipping_id.address_label: -${_("Ordering Contact")}
-
-${order.partner_id.address_label|carriage_returns} - %endif - %if order.partner_id.phone : -${_("Tel")}: ${order.partner_id.phone|entity}
- %endif - %if order.partner_id.fax : -${_("Fax")}: ${order.partner_id.fax|entity}
- %endif - %if order.partner_id.email : -${_("E-mail")}: ${order.partner_id.email|entity}
- %endif - %if order.partner_invoice_id.address_label != order.partner_shipping_id.address_label: -
-
-${_("Invoice Address")}
-
-${order.partner_invoice_id.address_label|carriage_returns} - %endif - %if order.partner_invoice_id.vat : -${_("VAT")}: ${order.partner_invoice_id.vat|entity}
- %endif - -
-${_("Shipping Address")}
-
-
-${order.partner_shipping_id.address_label}
-           
-         
- -
-
- - %if order.state == 'draft' : - ${_("Quotation N°")} ${order.name or ''|entity} - %elif order.state == 'cancel' : - ${_("Sale Order Canceled")} ${order.name or ''|entity} - %else : - ${_("Order N°")} ${order.name or ''|entity} - %endif -
- - - %if order.client_order_ref: - - %endif - %if order.project_id: - - %endif - - %if order.carrier_id: - - %endif - %if order.user_id: - - %endif - %if order.payment_term : - - %endif - %if order.incoterm: - - %endif - - - - - %if order.client_order_ref: - - %endif - %if order.project_id: - - %endif - %if order.date_order: - - %endif - %if order.carrier_id: - - %endif - %if order.user_id : - - %endif - %if order.payment_term : - - %endif - %if order.incoterm: - - %endif - - -
${_("Reference")}${_("Projekt")}${_("Order Date")}${_("Carrier")}${_("Salesman")}${_("Payment Term")}${_("Incoterm")}${_("Curr")}
- ${order.client_order_ref} - ${order.project_id.name} - ${order.date_order or ''} - ${order.carrier_id.name } - ${order.user_id.name or ''}${order.payment_term.name}${order.incoterm.name}${order.pricelist_id.currency_id.name}
-


- - - -%if order.print_code: - - -%else: - -%endif - -%if order.print_uom: - -%endif -%if order.print_uos: - -%endif -%if order.print_ean: - -%endif -%if order.print_packing: - - -%endif - -%if order.print_discount: - -%endif - - - - %for line in order.order_line_sorted : - - -%if order.print_code: - - -%else: - ${ ', '.join([tax.name or '' for tax in line.tax_id]) } -%if order.print_uom: - - -%endif -%if order.print_uos: - - -%endif -%if order.print_ean: - -%endif -%if order.print_packing: - - -%endif - -%if order.print_discount: - - - %endfor - - - - - - - - - - - - - - - - -
${_("Code")}${_("Description")}${_("Description")}${_("Tax")}${_("Quantity")}${_("UoM")}${_("UoS Qty")}${_("UoS")}${_("EAN")}${_("Pack")}${_("Packaging")}${_("Price Unit")}${_("Discount")}${_("Sub Total")}
${line.product_id.default_code or ''|entity} -${line.product_id.name or line.name|entity} - - -${line.name|entity} - - ${str(line.product_uom_qty).replace(',000','') or '0'}${line.product_uom.name or ''}${str(line.product_uos_qty).replace(',000','') or '0'}${line.product_uos.name or ''}${line.product_packaging.ean or line.product_id.ean13 or ''}${line.product_packaging.qty and line.product_uom_qty/line.product_packaging.qty or ''}${line.product_packaging and line.product_packaging.ul.name or ''} ${line.product_packaging and _(" / " or '')} ${line.product_packaging and line.product_packaging.qty or ''} ${line.product_packaging and line.product_id.uom_id.name or ''}${line.price_unit or ''}${line.discount} -%endif - ${line.price_subtotal or ''}
- ${_("Net Total:")}${formatLang(order.amount_untaxed, get_digits(dp='Sale Price'))}
- ${_("Taxes:")}${formatLang(order.amount_tax, get_digits(dp='Sale Price'))}
- ${_("Total:")}${formatLang(order.amount_total, get_digits(dp='Sale Price'))}
- -%if order.note and 'note_print' not in order._columns: -
-
${order.note}
-%endif: -%if 'note_print' in order._columns and order.note_print: -
-
${order.note_print}
-%endif: - - -

- %endfor - -