From 58291eac6579963828de910401dd0a6694de9b3a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 8 Oct 2014 13:47:28 +0200 Subject: [PATCH] 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 | 71 +-- account_check_deposit/account_data.xml | 32 ++ account_check_deposit/account_deposit.py | 413 +++++++++++------- .../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/.directory | 6 - account_check_deposit/report/.mako | 275 ------------ account_check_deposit/report/__init__.py | 40 +- .../report/check_deposit.mako | 66 +-- .../report/report_webkit_html.py | 35 +- .../security/check_deposit_security.xml | 20 + 14 files changed, 517 insertions(+), 662 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 delete mode 100644 account_check_deposit/report/.directory delete mode 100644 account_check_deposit/report/.mako 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..136b6dc1d 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': [ @@ -37,12 +47,13 @@ 'report_webkit', ], 'data': [ - 'account_deposit_view.xml', - 'account_deposit_sequence.xml', - 'account_type_data.xml', - 'security/ir.model.access.csv', + '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, - '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..a98df3166 100644 --- a/account_check_deposit/account_deposit.py +++ b/account_check_deposit/account_deposit.py @@ -1,236 +1,321 @@ # -*- 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)]}), + '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', - readonly=True, - states={'draft': [('readonly', '=', False)]}), + 'Deposit Date', required=True, + states={'done': [('readonly', '=', True)]}), 'journal_id': fields.many2one( - 'account.journal', - 'Journal', - 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, + states={'done': [('readonly', '=', True)]}), + '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'), - ], 'Status', - readonly=True), + ], '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)]}), + 'account.move', 'Journal Entry', readonly=True), + 'partner_bank_id': fields.many2one( + 'res.partner.bank', 'Bank Account', required=True, + domain="[('company_id', '=', company_id)]", + states={'done': [('readonly', '=', True)]}), '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), + '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( - sum_amount, - string="total amount", - type="float"), + _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', readonly=True, + string="Number of Checks", type="integer"), 'is_reconcile': fields.function( - _is_reconcile, - string="Reconcile", - type="boolean"), + _compute_check_deposit, multi='deposit', readonly=True, + 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 +324,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/.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 - - 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])] + + + +