Merge pull request #121 from acsone/8.0-forward-port-sbi

Forward port '7.0' into 8.0 until 7333aa8
This commit is contained in:
Yannick Vaucher
2015-01-09 17:01:15 +01:00
19 changed files with 1436 additions and 131 deletions

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# 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 <http://www.gnu.org/licenses/>.
#
###############################################################################
from . import account_deposit

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# account_check_deposit for Odoo/OpenERP
# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/)
# @author: Benoît GUILLOT <benoit.guillot@akretion.com>
# @author: Chafique DELLI <chafique.delli@akretion.com>
# @author: Alexis de Lattre <alexis.delattre@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 <http://www.gnu.org/licenses/>.
#
###############################################################################
{
'name': 'Account Check Deposit',
'version': '0.1',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'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': [
'account_accountant',
'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',
],
'installable': False,
'application': True,
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
account_check_deposit for Odoo/OpenERP
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data noupdate="1">
<record id="check_received_journal_seq" model="ir.sequence">
<field name="name">Journal Check Received</field>
<field name="prefix">CHK/</field>
<field name="padding">6</field>
<field name="company_id" ref="base.main_company"/>
</record>
<!-- The user will have to configure manually the default_credit_account_id
and default_debit_account_id, we can't do that for him -->
<record id="check_received_journal" model="account.journal">
<field name="name">Check Received</field>
<field name="code">CHK</field>
<field name="type">bank</field>
<field name="sequence_id" ref="check_received_journal_seq"/>
<field name="company_id" ref="base.main_company"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,340 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# account_check_deposit for Odoo/OpenERP
# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/)
# @author: Benoît GUILLOT <benoit.guillot@akretion.com>
# @author: Chafique DELLI <chafique.delli@akretion.com>
# @author: Alexis de Lattre <alexis.delattre@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 <http://www.gnu.org/licenses/>.
#
###############################################################################
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 _compute_check_deposit(self, cr, uid, ids, name, args, context=None):
res = {}
for deposit in self.browse(cr, uid, ids, context=context):
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:
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:
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, readonly=True),
'check_payment_ids': fields.one2many(
'account.move.line', 'check_deposit_id', 'Check Payments',
states={'done': [('readonly', '=', True)]}),
'deposit_date': fields.date(
'Deposit Date', required=True,
states={'done': [('readonly', '=', True)]}),
'journal_id': fields.many2one(
'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),
'move_id': fields.many2one(
'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),
'company_id': fields.many2one(
'res.company', 'Company', required=True,
change_default=True,
states={'done': [('readonly', '=', True)]}),
'total_amount': fields.function(
_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(
_compute_check_deposit, multi='deposit', readonly=True,
string="Reconcile", type="boolean"),
}
_defaults = {
'name': '/',
'deposit_date': fields.date.context_today,
'state': 'draft',
'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 orm.except_orm(
_('Error!'),
_("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['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,
}
return move_vals
def _prepare_move_line_vals(
self, cr, uid, line, context=None):
assert (line.debit > 0), 'Debit must have a value'
return {
'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,
'currency_id': line.currency_id.id or False,
'amount_currency': line.amount_currency * -1,
}
def _prepare_counterpart_move_lines_vals(
self, cr, uid, deposit, total_debit, total_amount_currency,
context=None):
return {
'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):
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):
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"
_columns = {
'check_deposit_id': fields.many2one(
'account.check.deposit',
'Check Deposit'),
}
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)]),
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
account_check_deposit for Odoo/OpenERP
Copyright (C) 2012-2014 Akretion (http://www.akretion.com/)
@author: Benoît GUILLOT <benoit.guillot@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data noupdate="1">
<!-- Sequences for account.check.deposit -->
<record id="seq_type_account_check_deposit" model="ir.sequence.type">
<field name="name">Account Check Deposit</field>
<field name="code">account.check.deposit</field>
</record>
<record id="seq_account_check_deposit" model="ir.sequence">
<field name="name">Account Check Deposit</field>
<field name="code">account.check.deposit</field>
<field name="prefix">DEP</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
account_check_deposit for Odoo/OpenERP
Copyright (C) 2012-2014 Akretion (http://www.akretion.com/)
@author: Benoît GUILLOT <benoit.guillot@akretion.com>
@author: Chafique DELLI <chafique.delli@akretion.com>
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<report
auto="False"
file="account_check_deposit/report/check_deposit.mako"
id="check_deposit_webkit"
model="account.check.deposit"
name="check.deposit.webkit"
report_type="webkit"
string="Checks Deposit"/>
<record id="account_check_deposit_view_form" model="ir.ui.view">
<field name="name">account.check.deposit.form</field>
<field name="model">account.check.deposit</field>
<field name="arch" type="xml">
<form string="Checks Deposit" version="7.0">
<header>
<button name="validate_deposit" states="draft"
string="Validate"
type="object" class="oe_highlight"/>
<button name="backtodraft" states="done"
string="Back to Draft" type="object" />
<field name="state" widget="statusbar"
statusbar_visible="draft,done" />
</header>
<sheet>
<h1>
<label string="Check Deposit" />
<field name="name" class="oe_inline" />
</h1>
<group name="main">
<group name="left">
<field name="deposit_date" />
<field name="journal_id"
widget="selection"
on_change="onchange_journal_id(journal_id, context)"/>
<field name="journal_default_account_id"
invisible="1"/>
<field name="currency_id"
groups="base.group_multi_currency"
on_change="onchange_currency_id(currency_id, company_id, context)"/>
<field name="partner_bank_id"/>
</group>
<group name="right">
<field name="company_id"
on_change="onchange_company_id(company_id, currency_id, context)"
groups="base.group_multi_company"/>
<field name="currency_none_same_company_id"
invisible="1"/>
<field name="check_count"/>
<field name="total_amount" widget="monetary"
options="{'currency_field': 'currency_id'}"/>
<field name="move_id"/>
</group>
</group>
<group string="Check Payments" name="check_payments">
<field name="check_payment_ids" nolabel="1"
widget="many2many"
domain="[('reconcile_id', '=', False),
('debit', '>', 0),
('journal_id', '=', journal_id),
('currency_id', '=', currency_none_same_company_id),
('account_id', '=', journal_default_account_id)]"
context="{'currency': currency_id,
'journal_id': journal_id}" />
</group>
</sheet>
</form>
</field>
</record>
<record id="account_check_deposit_view_tree" model="ir.ui.view">
<field name="name">account.check.deposit.tree</field>
<field name="model">account.check.deposit</field>
<field name="arch" type="xml">
<tree string="Checks Deposits" colors="blue:state=='draft';">
<field name="name"/>
<field name="deposit_date"/>
<field name="check_count"/>
<field name="total_amount"/>
<field name="currency_id" groups="base.group_multi_currency"/>
<field name="is_reconcile"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_check_deposit_search" model="ir.ui.view">
<field name="name">account.check.deposit.search</field>
<field name="model">account.check.deposit</field>
<field name="arch" type="xml">
<search string="Checks Deposit Search">
<field name="name" string="Checks Deposit"/>
<filter name="draft" string="Draft"
domain="[('state', '=', 'draft')]" />
<filter name="done" string="Done"
domain="[('state', '=', 'done')]" />
<group string="Group By" name="groupby">
<filter name="date_groupby" string="Deposit Date"
context="{'group_by': 'deposit_date'}"/>
<filter name="journal_groupby" string="Journal"
context="{'group_by': 'journal_id'}" />
<filter name="currency_groupby" string="Currency"
context="{'group_by': 'currency_id'}" />
<filter name="partner_bank_groupby" string="Bank Account"
context="{'group_by': 'partner_bank_id'}" />
</group>
</search>
</field>
</record>
<record id="action_check_deposit_tree" model="ir.actions.act_window">
<field name="name">Checks Deposits</field>
<field name="res_model">account.check.deposit</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_check_deposit_tree"
id="menu_check_deposit_tree"
parent="account.menu_finance_bank_and_cash"
sequence="20"/>
</data>
</openerp>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_company_form" model="ir.ui.view">
<field name="name">check.deposit.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<group name="account_grp" position="inside">
<field name="check_deposit_account_id" />
</group>
</field>
</record>
</data>
</openerp>

View File

@@ -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 ""

View File

@@ -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 "Print Checks Deposit"
msgstr "Imprimer 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"

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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 <http://www.gnu.org/licenses/>.
#
###############################################################################
from . import report_webkit_html

View File

@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
<html>
<head>
<style type="text/css">
table {
width: 100%;
page-break-after:auto;
border-collapse: collapse;
cellspacing="0";
font-size:14px;
}
td { margin: 0px; padding: 3px; border: 1px solid lightgrey; vertical-align: top; }
.valign_up1, .valign_up2, .halign, .vtrait1, .vtrait2{
position:absolute;
}
.valign_up1 { left:200px; font-weight: lighter; color:MediumSlateBlue ;
}
.valign_up2 { left:650px; font-weight: lighter; color:MediumSlateBlue ;
}
.halign { left:500px}
.vtrait1 { left:185px; font-weight: lighter; color:MediumSlateBlue ; }
.vtrait2 { left:630px; font-weight: lighter; color:MediumSlateBlue ; }
.entete_tab {text-align:center; white-space:nowrap; border-bottom:1px solid;}
.cellule_tab {white-space:nowrap; text-align:center;}
.amount {white-space:nowrap; text-align:right;}
.total {border-top:2px solid;}
.titre {text-align:center; font-family:helvetica; font-size:35px; background:lightgrey}
pre {font-family:helvetica; font-size:12px;}
h1 {font-family:helvetica; font-size:18px;}
h2 {font-family:helvetica; font-size:25px; border-bottom:1px solid}
h3 {font-family:helvetica; font-size:22px; color: MediumSlateBlue ; margin-bottom: auto;}
</style>
</head>
<body>
%for deposit in objects :
<% setLang(deposit.company_id.partner_id.lang) %>
<b><span class="titre">${_("Deposit Slip of Checks in ")} ${deposit.currency_id.name}</span></b>
<table class="basic_table" width="100%">
<tr>
<th class="date">${_("Deposit Date")}</th>
<th class="text-align:center;">${_("Deposit Ref")}</th>
<th class="text-align:center;">${_("Beneficiary")}</th>
<th class="text-align:center;">${_("Bank Account Number")}</th>
</tr>
<tr>
<td class="date">${formatLang(deposit.deposit_date, date=True)}</td>
<td class="text-align:center;">${deposit.name}</td>
<td class="text-align:center;">${deposit.company_id.partner_id.name}</td>
<td class="text-align:center;">${deposit.partner_bank_id.acc_number}</td>
</tr>
</table>
<h3>${_("Check Payments")}</h3>
<table style="width:100%">
<thead>
<tr>
<th class="entete_tab">${_("Payment Date")}</th>
<th class="entete_tab">${_("Reference")}</th>
<th class="entete_tab">${_("Debtor")}</th>
<th class="entete_tab">${_("Amount")}</th>
</thead>
</tr>
%for move_line in deposit.check_payment_ids :
<tbody>
<tr>
<td class="cellule_tab">${move_line.date or ''}</td>
<td class="cellule_tab">${move_line.ref or ''}</td>
<td class="cellule_tab">${move_line.partner_id.name or ''}</td>
<td class="amount">${deposit.currency_id == deposit.company_id.currency_id and move_line.debit or move_line.amount_currency} ${deposit.currency_id.name}</td>
</tr>
</tbody>
%endfor
%endfor
<tfoot>
<tr>
<td colspan="3" class="amount total"><b>${_("Total:")}</b></td>
<td class="amount total"><b>${deposit.total_amount or '0'} ${deposit.currency_id.name}</b></td>
</tr>
</tfoot>
</table>
</body>
</html>

View File

@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# account_check_deposit for Odoo/OpenERP
# Copyright (C) 2012-2014 Akretion (http://www.akretion.com/)
# @author: Benoît GUILLOT <benoit.guillot@akretion.com>
# @author: Chafique DELLI <chafique.delli@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 <http://www.gnu.org/licenses/>.
#
###############################################################################
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)
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)

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data noupdate="1">
<record id="check_deposit_rule" model="ir.rule">
<field name="name">Check Deposit multi-company</field>
<field name="model_id" ref="model_account_check_deposit"/>
<field name="global" eval="True"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +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","account.group_account_user",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 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

View File

@@ -12,11 +12,11 @@
<menuitem
action="action_account_move_line_search_extension"
icon="STOCK_JUSTIFY_FILL"
id="account.menu_action_account_moves_all"
id="menu_account_move_line_search_extension"
parent="account.menu_finance_entries"
sequence="1"
groups="account.group_account_user"
/>
</data>
</openerp>

View File

@@ -1,93 +1,94 @@
openerp.account_move_line_search_extension = function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.account_move_line_search_extension = {};
instance.web.views.add('account_move_line_search_extension', 'instance.account_move_line_search_extension.ListSearchView');
instance.account_move_line_search_extension.ListSearchView = instance.web.ListView.extend({
init: function() {
this._super.apply(this, arguments);
this.journals = [];
this.current_account = null;
this.current_partner = null;
this.current_journal = null;
this.current_period = null;
},
start:function(){
var tmp = this._super.apply(this, arguments);
var self = this;
this.$el.parent().prepend(QWeb.render('AccountMoveLineSearchExtension', {widget: this}));
this.$el.parent().find('.oe_account_select_account').change(function() {
self.current_account = this.value === '' ? null : this.value;
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_partner').change(function() {
self.current_partner = this.value === '' ? null : this.value;
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_journal').change(function() {
self.current_journal = this.value === '' ? null : parseInt(this.value);
//console.log('start, oasj, self.current_journal=', self.current_journal, 'self.last_domain=', self.last_domain, 'self.last_context=', self.last_context, 'self.last_group_by=', self.last_group_by);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_period').change(function() {
self.current_period = this.value === '' ? null : this.value;
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.on('edit:after', this, function () {
self.$el.parent().find('.oe_account_select_account').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_partner').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled');
});
this.on('save:after cancel:after', this, function () {
self.$el.parent().find('.oe_account_select_account').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_partner').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_period').removeAttr('disabled');
});
return tmp;
},
do_search: function(domain, context, group_by) {
var self = this;
this.last_domain = domain;
this.last_context = context;
this.last_group_by = group_by;
this.old_search = _.bind(this._super, this);
var aj_mod = new instance.web.Model('account.journal');
return $.when(aj_mod.query(['name']).all().then(function(result) {
self.journals = result;
})).then(function () {
var o;
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
self.$el.parent().find('.oe_account_select_journal').append(new Option('', ''));
for (var i = 0;i < self.journals.length;i++){
o = new Option(self.journals[i].name, self.journals[i].id);
if (self.journals[i].id === self.current_journal){
$(o).attr('selected',true);
}
self.$el.parent().find('.oe_account_select_journal').append(o);
}
return self.search_by_selection();
});
},
search_by_selection: function() {
var self = this;
var domain = [];
if (self.current_account) domain.push(['account_id.code', 'ilike', self.current_account]);
if (self.current_partner) domain.push(['partner_id.name', 'ilike', self.current_partner],'|',['partner_id.parent_id','=',false],['partner_id.is_company','=',true]);
if (self.current_journal) domain.push(['journal_id', '=', self.current_journal]);
if (self.current_period) domain.push('|',['period_id.code', 'ilike', self.current_period],['period_id.name', 'ilike', self.current_period]);
//_.each(domain, function(x) {console.log('search_by_journal_period, domain_part = ', x)});
return self.old_search(new instance.web.CompoundDomain(self.last_domain, domain), self.last_context, self.last_group_by);
},
});
};
openerp.account_move_line_search_extension = function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.account_move_line_search_extension = {};
instance.web.views.add('account_move_line_search_extension', 'instance.account_move_line_search_extension.ListSearchView');
instance.account_move_line_search_extension.ListSearchView = instance.web.ListView.extend({
init: function() {
this._super.apply(this, arguments);
this.journals = [];
this.current_account = null;
this.current_partner = null;
this.current_journal = null;
this.current_period = null;
this.options.addable = false;
},
start:function(){
var tmp = this._super.apply(this, arguments);
var self = this;
this.$el.parent().prepend(QWeb.render('AccountMoveLineSearchExtension', {widget: this}));
this.$el.parent().find('.oe_account_select_account').change(function() {
self.current_account = this.value === '' ? null : this.value;
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_partner').change(function() {
self.current_partner = this.value === '' ? null : this.value;
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_journal').change(function() {
self.current_journal = this.value === '' ? null : parseInt(this.value);
//console.log('start, oasj, self.current_journal=', self.current_journal, 'self.last_domain=', self.last_domain, 'self.last_context=', self.last_context, 'self.last_group_by=', self.last_group_by);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_period').change(function() {
self.current_period = this.value === '' ? null : this.value;
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.on('edit:after', this, function () {
self.$el.parent().find('.oe_account_select_account').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_partner').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled');
});
this.on('save:after cancel:after', this, function () {
self.$el.parent().find('.oe_account_select_account').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_partner').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_period').removeAttr('disabled');
});
return tmp;
},
do_search: function(domain, context, group_by) {
var self = this;
this.last_domain = domain;
this.last_context = context;
this.last_group_by = group_by;
this.old_search = _.bind(this._super, this);
var aj_mod = new instance.web.Model('account.journal');
return $.when(aj_mod.query(['name']).all().then(function(result) {
self.journals = result;
})).then(function () {
var o;
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
self.$el.parent().find('.oe_account_select_journal').append(new Option('', ''));
for (var i = 0;i < self.journals.length;i++){
o = new Option(self.journals[i].name, self.journals[i].id);
if (self.journals[i].id === self.current_journal){
$(o).attr('selected',true);
}
self.$el.parent().find('.oe_account_select_journal').append(o);
}
return self.search_by_selection();
});
},
search_by_selection: function() {
var self = this;
var domain = [];
if (self.current_account) domain.push(['account_id.code', 'ilike', self.current_account]);
if (self.current_partner) domain.push(['partner_id.name', 'ilike', self.current_partner],'|',['partner_id.parent_id','=',false],['partner_id.is_company','=',true]);
if (self.current_journal) domain.push(['journal_id', '=', self.current_journal]);
if (self.current_period) domain.push('|',['period_id.code', 'ilike', self.current_period],['period_id.name', 'ilike', self.current_period]);
//_.each(domain, function(x) {console.log('search_by_journal_period, domain_part = ', x)});
return self.old_search(new instance.web.CompoundDomain(self.last_domain, domain), self.last_context, self.last_group_by);
},
});
};

View File

@@ -18,8 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import base64
import tempfile
import time
import openerp.tests.common as test_common
from openerp import addons
@@ -28,14 +27,15 @@ from openerp import addons
class TestMoveLineImporter(test_common.SingleTransactionCase):
def get_file(self, filename):
"""Retrive file from test data"""
"""Retrieve file from test data,
encode it as base64
and adjust it for current year
"""
path = addons.get_module_resource('async_move_line_importer',
'tests', 'data', filename)
with open(path) as test_data:
with tempfile.TemporaryFile() as out:
base64.encode(test_data, out)
out.seek(0)
return out.read()
test_data = open(path).read()
test_data = test_data.replace('2014', time.strftime('%Y'))
return test_data.encode("base64")
def setUp(self):
super(TestMoveLineImporter, self).setUp()

View File

@@ -99,43 +99,64 @@ def journal_period_draft(self, journal_period_id, context):
context=context)
def get_journal_copy_id(self, journal_id, context=None):
return self.registry('account.journal').copy(self.cr, self.uid,
journal_id, {}, context)
def create_fiscalyear(self, year, company_id):
fiscalyear_obj = self.registry('account.fiscalyear')
fiscalyear_id = fiscalyear_obj.create(self.cr, self.uid, {
'name': year,
'code': year,
'date_start': year + '-01-01',
'date_stop': year + '-12-31',
'company_id': company_id
})
fiscalyear_obj.create_period(self.cr, self.uid, [fiscalyear_id])
return fiscalyear_id
class TestAccountJournalPeriodClose(common.TransactionCase):
def setUp(self):
super(TestAccountJournalPeriodClose, self).setUp()
company_id = self.ref('base.main_company')
fiscalyear_id = create_fiscalyear(self, '2013', company_id)
journal_id = self.ref('account.sales_journal')
self.period_id = self.registry('account.period')\
.search(self.cr, self.uid, [('fiscalyear_id', '=', fiscalyear_id)],
limit=1)[0]
self.journal_id = get_journal_copy_id(self, journal_id)
def test_close_period_open_journal(self):
context = {}
journal_id = self.ref('account.sales_journal')
period_id = self.ref('account.period_1')
close_period(self, period_id, context)
close_period(self, self.period_id, context)
journal_period_id = create_journal_period(self,
period_id,
journal_id,
self.period_id,
self.journal_id,
context)
journal_period_draft(self, journal_period_id, context)
self.registry('account.move')\
.create(self.cr,
self.uid,
get_simple_account_move_values(self,
period_id,
journal_id),
self.period_id,
self.journal_id),
context=context)
# Here, no exception should be raised because the journal's state is
# draft although the period is closed
def test_open_period_close_journal(self):
context = {}
journal_id = self.ref('account.sales_journal')
period_id = self.ref('account.period_1')
journal_period_id = create_journal_period(self,
period_id,
journal_id,
self.period_id,
self.journal_id,
context)
journal_period_done(self, journal_period_id, context)
move_values = get_simple_account_move_values(self,
period_id,
journal_id)
self.period_id,
self.journal_id)
# I check if the exception is correctly raised at create of an account
# move which is linked with a closed journal
self.assertRaises(except_orm,
@@ -144,16 +165,14 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
def test_change_journal_on_move(self):
context = {}
journal_id = self.ref('account.sales_journal')
journal_cash_id = self.ref('account.cash_journal')
period_id = self.ref('account.period_1')
journal_period_id = create_journal_period(self,
period_id,
journal_id,
self.period_id,
self.journal_id,
context)
journal_period_done(self, journal_period_id, context)
move_values = get_simple_account_move_values(self,
period_id,
self.period_id,
journal_cash_id)
self.registry('account.move').create(self.cr,
self.uid,
@@ -173,11 +192,9 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
context = {}
jour_per_obj = self.registry('account.journal.period')
journal_id = self.ref('account.sales_journal')
period_id = self.ref('account.period_1')
move_values = get_simple_account_move_values(self,
period_id,
journal_id)
self.period_id,
self.journal_id)
self.registry('account.move').create(self.cr,
self.uid,
move_values,
@@ -185,8 +202,8 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
journal_period_ids =\
jour_per_obj.search(self.cr,
self.uid,
[('period_id', '=', period_id),
('journal_id', '=', journal_id),
[('period_id', '=', self.period_id),
('journal_id', '=', self.journal_id),
],
context=context)
# I check if the exception is correctly raised at closing journal that
@@ -198,15 +215,13 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
def test_duplicate_journal_period(self):
context = {}
journal_id = self.ref('account.sales_journal')
period_id = self.ref('account.period_1')
create_journal_period(self, period_id, journal_id, context)
create_journal_period(self, self.period_id, self.journal_id, context)
# I check if the exception is correctly raised at adding both same
# journal on a period
self.cr._default_log_exceptions = False
try:
self.assertRaises(IntegrityError,
create_journal_period,
self, period_id, journal_id, context)
self, self.period_id, self.journal_id, context)
finally:
self.cr._default_log_exceptions = True

View File

@@ -80,3 +80,4 @@ class MX_BdM_getter(Currency_getter_interface):
self.updated_currency[curr] = rate
logger.debug("Rate retrieved : %s = %s %s" %
(main_currency, rate, curr))
return self.updated_currency, self.log_info