Set as uninstallable and moved to __unported__ all modules.

This commit is contained in:
Pedro M. Baeza
2014-07-02 12:46:57 +02:00
parent ba27994ae0
commit e4a743bc7d
225 changed files with 23 additions and 23 deletions

View File

@@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Joel Grand-Guillaume
# Copyright 2011-2012 Camptocamp SA
#
# 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 statement
import report
import account
import voucher

View File

@@ -1,89 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Joel Grand-Guillaume
# Copyright 2011-2013 Camptocamp SA
#
# 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': "Bank statement extension and profiles",
'version': '1.3.6',
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
'complexity': 'normal',
'depends': ['account',
'report_webkit',
'account_voucher'],
'description': """
Improve the basic bank statement, by adding various new features,
and help dealing with huge volume of reconciliation through payment offices such as Paypal, Lazer,
Visa, Amazon...
It is mostly used for E-commerce but can be useful for other use cases as it introduces a
notion of profile on the bank statement to have more control on the generated entries. It serves as
a base for all new features developped to improve the reconciliation process (see our other
set of modules:
* account_statement_base_completion
* account_statement_base_import
* account_advanced_reconcile
Features:
1) Improve the bank statement: allows to define profiles (for each
Office or Bank). The bank statement will then generate the entries based on some criteria chosen
in the selected profile. You can setup on the profile:
- the journal to use
- use balance check or not
- account commission and Analytic account for commission
- partner concerned by the profile (used in commission and optionaly on generated credit move)
- use a specific credit account (instead of the receivalble/payable default one)
- force Partner on the counter-part move (e.g. 100.- debit, Partner: M.Martin; 100.- credit, Partner: HSBC)
2) Add a report on bank statement that can be used for checks remittance
3) When an error occurs in a bank statement confirmation, go through all line anyway and summarize
all the erronous line in a same popup instead of raising and crashing on every step.
4) Remove the period on the bank statement, and compute it for each line based on their date instead.
It also adds this feature in the voucher in order to compute the period correctly.
5) Cancelling a bank statement is much more easy and will cancel all related entries, unreconcile them,
and finally delete them.
6) Add the ID in entries view so that you can easily filter on a statement ID to reconcile all related
entries at once (e.g. one statement (ID 100) for paypal on an intermediate account, and then another for
the bank on the bank account. You can then manually reconcile all the line from the first one with
one line of the second by finding them through the statement ID.)
""",
'website': 'http://www.camptocamp.com',
'data': ['statement_view.xml',
'account_view.xml',
'report/bank_statement_webkit_header.xml',
'report.xml',
'security/ir.model.access.csv',
'security/ir_rule.xml'],
'demo_xml': [],
'test': ['test/test_profile_related_fields.yml'],
'installable': True,
'images': [],
'auto_install': False,
'license': 'AGPL-3',
'active': False,
}

View File

@@ -1,41 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Joel Grand-Guillaume
# Copyright 2011-2012 Camptocamp SA
#
# 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.orm import Model
from openerp.osv import fields
class account_move(Model):
_inherit = 'account.move'
def unlink(self, cr, uid, ids, context=None):
"""
Delete the reconciliation when we delete the moves. This
allow an easier way of cancelling the bank statement.
"""
reconcile_to_delete = []
reconcile_obj = self.pool.get('account.move.reconcile')
for move in self.browse(cr, uid, ids, context=context):
for move_line in move.line_id:
if move_line.reconcile_id:
reconcile_to_delete.append(move_line.reconcile_id.id)
reconcile_obj.unlink(cr, uid, reconcile_to_delete, context=context)
return super(account_move, self).unlink(cr, uid, ids, context=context)

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_line_filter_add_statement" model="ir.ui.view">
<field name="name">Journal Items add statement</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_account_move_line_filter"/>
<field name="arch" type="xml">
<xpath expr="/search/group/filter[@string='Period']" position="after">
<filter string="Bank Statement" context="{'group_by': 'statement_id'}" icon="terp-partner"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@@ -1,377 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_statement_ext
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-09 17:23+0000\n"
"PO-Revision-Date: 2014-06-09 17:45+0000\n"
"Last-Translator: Pedro Manuel Baeza <pedro.baeza@gmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-10 06:51+0000\n"
"X-Generator: Launchpad (build 17031)\n"
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_move
#, python-format
msgid "Account Entry"
msgstr "Asiento contable"
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_voucher
#, python-format
msgid "Accounting Voucher"
msgstr "Recibo de pago"
#. module: account_statement_ext
#: code:addons/account_statement_ext/report/bank_statement_report.py:37
#: code:addons/account_statement_ext/report/bank_statement_report.py:44
#, python-format
msgid "BORDEREAU DE REMISE DE CHEQUES"
msgstr "CALENDARIO DE ENTREGA DE VALES"
#. module: account_statement_ext
#: field:account.bank.statement,balance_check:0
#: field:account.statement.profile,balance_check:0
msgid "Balance check"
msgstr "Comprobar saldo"
#. module: account_statement_ext
#: field:account.bank.statement,profile_id:0
msgid "Bank Account Profile"
msgstr "Perfil de cuenta bancaria"
#. module: account_statement_ext
#: code:_description:0
#: view:account.move.line:0
#: model:ir.actions.report.xml,name:account_statement_ext.report_bank_statement_webkit
#: model:ir.model,name:account_statement_ext.model_account_bank_statement
#, python-format
msgid "Bank Statement"
msgstr "Extracto bancario"
#. module: account_statement_ext
#: field:account.statement.profile,bank_statement_ids:0
msgid "Bank Statement Imported"
msgstr "Extracto bancario importado"
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_bank_statement_line
#, python-format
msgid "Bank Statement Line"
msgstr "Línea de extracto bancario"
#. module: account_statement_ext
#: field:account.statement.profile,bank_statement_prefix:0
msgid "Bank Statement Prefix"
msgstr "Prefijo de extracto bancario"
#. module: account_statement_ext
#: model:ir.actions.act_window,name:account_statement_ext.action_treasury_statement_profile_tree
#: model:ir.ui.menu,name:account_statement_ext.menu_treasury_statement_profile_tree
msgid "Bank Statements Profile"
msgstr "Perfil de extracto bancario"
#. module: account_statement_ext
#: field:account.statement.profile,partner_id:0
msgid "Bank/Payment Office partner"
msgstr "Empresa para el banco/oficina de pago"
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:20
msgid "Bordereau"
msgstr "Calendario"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:525
#, python-format
msgid "Can not determine account"
msgstr "No se puede determinar la cuenta"
#. module: account_statement_ext
#: help:account.statement.profile,receivable_account_id:0
msgid ""
"Choose a receivable account to force the default debit/credit account (eg. "
"an intermediat bank account instead of default debitors)."
msgstr ""
"Escoja una cuenta a cobrar para forzar la cuenta debe/haber por defecto (por "
"ejemplo, una cuenta intermedia en lugar de la deudora por defecto)."
#. module: account_statement_ext
#: field:account.statement.profile,commission_account_id:0
msgid "Commission account"
msgstr "Cuenta contable para la comisión"
#. module: account_statement_ext
#: field:account.statement.profile,commission_analytic_id:0
msgid "Commission analytic account"
msgstr "Cuenta analítica para la comisión"
#. module: account_statement_ext
#: field:account.statement.profile,company_id:0
msgid "Company"
msgstr "Compañía"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:399
#, python-format
msgid "Configuration Error!"
msgstr "Error de configuración"
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:21
msgid "Date"
msgstr "Fecha"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:436
#, python-format
msgid "Error"
msgstr "Error"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:410
#, python-format
msgid "Error!"
msgstr "Error"
#. module: account_statement_ext
#: view:account.bank.statement:0
#: field:account.bank.statement,credit_partner_id:0
msgid "Financial Partner"
msgstr "Institución financiera"
#. module: account_statement_ext
#: field:account.statement.profile,journal_id:0
msgid "Financial journal to use for transaction"
msgstr "Diario contable a usar para la transacción"
#. module: account_statement_ext
#: field:account.statement.profile,message_follower_ids:0
msgid "Followers"
msgstr "Seguidores"
#. module: account_statement_ext
#: field:account.statement.profile,receivable_account_id:0
msgid "Force Receivable/Payable Account"
msgstr "Forzar cuenta a pagar/a cobrar"
#. module: account_statement_ext
#: field:account.statement.profile,force_partner_on_bank:0
msgid "Force partner on bank move"
msgstr "Forzar empresa en la línea del extracto"
#. module: account_statement_ext
#: help:account.statement.profile,sequence:0
msgid "Gives a sequence in lists, the first profile will be used as default"
msgstr ""
"Da una orden en las listas de selección. El primer perfil será el que se use "
"por defecto."
#. module: account_statement_ext
#: help:account.statement.profile,message_summary:0
msgid ""
"Holds the Chatter summary (number of messages, ...). This summary is "
"directly in html format in order to be inserted in kanban views."
msgstr ""
"Contiene el resumen del chatter (nº de mensajes, ...). Este resumen está "
"directamente en formato html para ser insertado en vistas kanban."
#. module: account_statement_ext
#: help:account.statement.profile,message_unread:0
msgid "If checked new messages require your attention."
msgstr "Si está marcado, hay nuevos mensajes que requieren su atención."
#. module: account_statement_ext
#: view:account.statement.profile:0
msgid "Import statement"
msgstr "Importar extracto"
#. module: account_statement_ext
#: field:account.statement.profile,message_is_follower:0
msgid "Is a Follower"
msgstr "Es un seguidor"
#. module: account_statement_ext
#: field:account.statement.profile,message_ids:0
msgid "Messages"
msgstr "Mensajes"
#. module: account_statement_ext
#: help:account.statement.profile,message_ids:0
msgid "Messages and communication history"
msgstr "Mensajes e historial de comunicación"
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:38
msgid "Montant"
msgstr "Importe"
#. module: account_statement_ext
#: field:account.statement.profile,name:0
msgid "Name"
msgstr "Nombre"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:418
#, python-format
msgid "No Analytic Journal!"
msgstr "Sin diario analítico"
#. module: account_statement_ext
#: model:ir.actions.act_window,name:account_statement_ext.act_bank_statement_from_profile
msgid "Open Statements"
msgstr "Abrir extractos"
#. module: account_statement_ext
#: code:addons/account_statement_ext/report/bank_statement_report.py:53
#, python-format
msgid "Page"
msgstr "Página"
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:36
msgid "Partenaire"
msgstr "Contrapartida"
#. module: account_statement_ext
#: field:account.bank.statement.line,period_id:0
msgid "Period"
msgstr "Periodo"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:526
#, python-format
msgid "Please ensure that minimal properties are set"
msgstr "Asegúrese por favor que las propiedades mínimas están establecidas"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:400
#, python-format
msgid "Please verify that an account is defined in the journal."
msgstr "Verifique por favor que hay una cuenta definida en el diario."
#. module: account_statement_ext
#: help:account.statement.profile,partner_id:0
msgid ""
"Put a partner if you want to have it on the commission move (and optionaly "
"on the counterpart of the intermediate/banking move if you tick the "
"corresponding checkbox)."
msgstr ""
"Ponga una empresa si quiere tenerla incluida en el apunte de comisiones (y "
"opcionalmente en la contrapartida de apunte bancaria si marca la "
"correspondiente casilla)."
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:34
msgid "Reference"
msgstr "Referencia"
#. module: account_statement_ext
#: field:account.statement.profile,sequence:0
msgid "Sequence"
msgstr "Secuencia"
#. module: account_statement_ext
#: view:account.statement.profile:0
msgid "Share a note..."
msgstr "Compartir una nota..."
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:442
#, python-format
msgid "Statement %s confirmed, journal items were created."
msgstr "Extracto %s confirmado. Se crearon los apuntes contables."
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_statement_profile
#, python-format
msgid "Statement Profile"
msgstr "Perfil de extracto"
#. module: account_statement_ext
#: field:account.statement.profile,message_summary:0
msgid "Summary"
msgstr "Resumen"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:411
#, python-format
msgid "The account entries lines are not in valid state."
msgstr "Los apuntes contables no están en un estado válido."
#. module: account_statement_ext
#: constraint:account.bank.statement:0
msgid "The journal and period chosen have to belong to the same company."
msgstr ""
"El diario y el periodo seleccionados tienen que pertenecer a la misma "
"compañía."
#. module: account_statement_ext
#: sql_constraint:account.statement.profile:0
msgid "The name of the bank statement must be unique !"
msgstr "El nombre del extracto bancario debe ser único."
#. module: account_statement_ext
#: help:account.statement.profile,balance_check:0
msgid ""
"Tick that box if you want OpenERP to control the start/end balance before "
"confirming a bank statement. If don't ticked, no balance control will be "
"done."
msgstr ""
"Marque esta casilla si quiere que el sistema controle el saldo inicial/final "
"antes de confirmar un extracto bancario. Si no está marcada, no se hará "
"ningún control de saldo."
#. module: account_statement_ext
#: help:account.statement.profile,force_partner_on_bank:0
msgid ""
"Tick that box if you want to use the credit institute partner in the "
"counterpart of the intermediate/banking move."
msgstr ""
"Marque esta casilla si quiere usar la empresa de la institución financiera "
"como contrapartida del apunte generado."
#. module: account_statement_ext
#: view:account.bank.statement:0
msgid "True"
msgstr "Verdadero"
#. module: account_statement_ext
#: field:account.statement.profile,message_unread:0
msgid "Unread Messages"
msgstr "Mensajes sin leer"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:419
#, python-format
msgid "You have to assign an analytic journal on the '%s' journal!"
msgstr "Tiene que asignar un diario analítico al diario '%s'."
#. module: account_statement_ext
#: constraint:account.statement.profile:0
msgid ""
"You need to put a partner if you tic the 'Force partner on bank move'!"
msgstr ""
"Necesita poner una empresa si ha marcado la casilla 'Forzar empresa en la "
"línea del extracto'."
#. module: account_statement_ext
#: code:addons/account_statement_ext/report/bank_statement_report.py:53
#, python-format
msgid "of"
msgstr "de"
#. module: account_statement_ext
#: view:account.bank.statement:0
msgid "{'invisible':[('balance_check','=',False)]}"
msgstr "{'invisible':[('balance_check','=',False)]}"

View File

@@ -1,360 +0,0 @@
# French translation for banking-addons
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
# This file is distributed under the same license as the banking-addons package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: banking-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2014-06-09 17:23+0000\n"
"PO-Revision-Date: 2014-06-09 17:27+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: French <fr@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-10 06:51+0000\n"
"X-Generator: Launchpad (build 17031)\n"
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_move
#, python-format
msgid "Account Entry"
msgstr "Écriture comptable"
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_voucher
#, python-format
msgid "Accounting Voucher"
msgstr ""
#. module: account_statement_ext
#: code:addons/account_statement_ext/report/bank_statement_report.py:37
#: code:addons/account_statement_ext/report/bank_statement_report.py:44
#, python-format
msgid "BORDEREAU DE REMISE DE CHEQUES"
msgstr "BORDEREAU DE REMISE DE CHEQUES"
#. module: account_statement_ext
#: field:account.bank.statement,balance_check:0
#: field:account.statement.profile,balance_check:0
msgid "Balance check"
msgstr "Activation contrôle du solde final"
#. module: account_statement_ext
#: field:account.bank.statement,profile_id:0
msgid "Bank Account Profile"
msgstr ""
#. module: account_statement_ext
#: code:_description:0
#: view:account.move.line:0
#: model:ir.actions.report.xml,name:account_statement_ext.report_bank_statement_webkit
#: model:ir.model,name:account_statement_ext.model_account_bank_statement
#, python-format
msgid "Bank Statement"
msgstr "Relevé bancaire"
#. module: account_statement_ext
#: field:account.statement.profile,bank_statement_ids:0
msgid "Bank Statement Imported"
msgstr "Relevé importé"
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_bank_statement_line
#, python-format
msgid "Bank Statement Line"
msgstr "Ligne de relevé bancaire"
#. module: account_statement_ext
#: field:account.statement.profile,bank_statement_prefix:0
msgid "Bank Statement Prefix"
msgstr "Préfixe du N° de Relevé"
#. module: account_statement_ext
#: model:ir.actions.act_window,name:account_statement_ext.action_treasury_statement_profile_tree
#: model:ir.ui.menu,name:account_statement_ext.menu_treasury_statement_profile_tree
msgid "Bank Statements Profile"
msgstr "Profil de relevé bancaire"
#. module: account_statement_ext
#: field:account.statement.profile,partner_id:0
msgid "Bank/Payment Office partner"
msgstr "Banque ou Organisme financier"
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:20
msgid "Bordereau"
msgstr "Bordereau"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:525
#, python-format
msgid "Can not determine account"
msgstr "Impossible de trouver le compte"
#. module: account_statement_ext
#: help:account.statement.profile,receivable_account_id:0
msgid ""
"Choose a receivable account to force the default debit/credit account (eg. "
"an intermediat bank account instead of default debitors)."
msgstr ""
#. module: account_statement_ext
#: field:account.statement.profile,commission_account_id:0
msgid "Commission account"
msgstr "Compte de commission"
#. module: account_statement_ext
#: field:account.statement.profile,commission_analytic_id:0
msgid "Commission analytic account"
msgstr "Compte analytique où affecter la commission"
#. module: account_statement_ext
#: field:account.statement.profile,company_id:0
msgid "Company"
msgstr ""
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:399
#, python-format
msgid "Configuration Error!"
msgstr ""
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:21
msgid "Date"
msgstr "Date"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:436
#, python-format
msgid "Error"
msgstr "Erreur"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:410
#, python-format
msgid "Error!"
msgstr ""
#. module: account_statement_ext
#: view:account.bank.statement:0
#: field:account.bank.statement,credit_partner_id:0
msgid "Financial Partner"
msgstr "Banque ou Organisme financier"
#. module: account_statement_ext
#: field:account.statement.profile,journal_id:0
msgid "Financial journal to use for transaction"
msgstr "Journal à utiliser pour cette écriture"
#. module: account_statement_ext
#: field:account.statement.profile,message_follower_ids:0
msgid "Followers"
msgstr ""
#. module: account_statement_ext
#: field:account.statement.profile,receivable_account_id:0
msgid "Force Receivable/Payable Account"
msgstr "Remplacer le compte client/fournisseur par défaut par"
#. module: account_statement_ext
#: field:account.statement.profile,force_partner_on_bank:0
msgid "Force partner on bank move"
msgstr "Indiquer un partenaire sur la ligne d'écriture de la banque"
#. module: account_statement_ext
#: help:account.statement.profile,sequence:0
msgid "Gives a sequence in lists, the first profile will be used as default"
msgstr ""
#. module: account_statement_ext
#: help:account.statement.profile,message_summary:0
msgid ""
"Holds the Chatter summary (number of messages, ...). This summary is "
"directly in html format in order to be inserted in kanban views."
msgstr ""
#. module: account_statement_ext
#: help:account.statement.profile,message_unread:0
msgid "If checked new messages require your attention."
msgstr ""
#. module: account_statement_ext
#: view:account.statement.profile:0
msgid "Import statement"
msgstr "Importation du relevé"
#. module: account_statement_ext
#: field:account.statement.profile,message_is_follower:0
msgid "Is a Follower"
msgstr ""
#. module: account_statement_ext
#: field:account.statement.profile,message_ids:0
msgid "Messages"
msgstr ""
#. module: account_statement_ext
#: help:account.statement.profile,message_ids:0
msgid "Messages and communication history"
msgstr ""
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:38
msgid "Montant"
msgstr "Montant"
#. module: account_statement_ext
#: field:account.statement.profile,name:0
msgid "Name"
msgstr "Nom"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:418
#, python-format
msgid "No Analytic Journal!"
msgstr ""
#. module: account_statement_ext
#: model:ir.actions.act_window,name:account_statement_ext.act_bank_statement_from_profile
msgid "Open Statements"
msgstr "Relevés ouverts"
#. module: account_statement_ext
#: code:addons/account_statement_ext/report/bank_statement_report.py:53
#, python-format
msgid "Page"
msgstr "Page"
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:36
msgid "Partenaire"
msgstr "Partenaire"
#. module: account_statement_ext
#: field:account.bank.statement.line,period_id:0
msgid "Period"
msgstr "Période"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:526
#, python-format
msgid "Please ensure that minimal properties are set"
msgstr "Veuillez vérifiez que les propriétés minimales sont bien paramétrées"
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:400
#, python-format
msgid "Please verify that an account is defined in the journal."
msgstr "Veuillez vérifier que ce compte est défini au niveau du journal."
#. module: account_statement_ext
#: help:account.statement.profile,partner_id:0
msgid ""
"Put a partner if you want to have it on the commission move (and optionaly "
"on the counterpart of the intermediate/banking move if you tick the "
"corresponding checkbox)."
msgstr ""
#. module: account_statement_ext
#: report:addons/account_statement_ext/report/bank_statement_report.mako:34
msgid "Reference"
msgstr "Référence"
#. module: account_statement_ext
#: field:account.statement.profile,sequence:0
msgid "Sequence"
msgstr ""
#. module: account_statement_ext
#: view:account.statement.profile:0
msgid "Share a note..."
msgstr ""
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:442
#, python-format
msgid "Statement %s confirmed, journal items were created."
msgstr ""
#. module: account_statement_ext
#: code:_description:0
#: model:ir.model,name:account_statement_ext.model_account_statement_profile
#, python-format
msgid "Statement Profile"
msgstr ""
#. module: account_statement_ext
#: field:account.statement.profile,message_summary:0
msgid "Summary"
msgstr ""
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:411
#, python-format
msgid "The account entries lines are not in valid state."
msgstr "Les écritures comptables ne sont pas équilibrées."
#. module: account_statement_ext
#: constraint:account.bank.statement:0
msgid "The journal and period chosen have to belong to the same company."
msgstr "Le journal et la période doivent appartenir à la même société."
#. module: account_statement_ext
#: sql_constraint:account.statement.profile:0
msgid "The name of the bank statement must be unique !"
msgstr ""
#. module: account_statement_ext
#: help:account.statement.profile,balance_check:0
msgid ""
"Tick that box if you want OpenERP to control the start/end balance before "
"confirming a bank statement. If don't ticked, no balance control will be "
"done."
msgstr ""
#. module: account_statement_ext
#: help:account.statement.profile,force_partner_on_bank:0
msgid ""
"Tick that box if you want to use the credit institute partner in the "
"counterpart of the intermediate/banking move."
msgstr ""
#. module: account_statement_ext
#: view:account.bank.statement:0
msgid "True"
msgstr ""
#. module: account_statement_ext
#: field:account.statement.profile,message_unread:0
msgid "Unread Messages"
msgstr ""
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:419
#, python-format
msgid "You have to assign an analytic journal on the '%s' journal!"
msgstr "Vous devez associer un journal analytique au journal comptable '%s'."
#. module: account_statement_ext
#: constraint:account.statement.profile:0
msgid ""
"You need to put a partner if you tic the 'Force partner on bank move'!"
msgstr ""
#. module: account_statement_ext
#: code:addons/account_statement_ext/report/bank_statement_report.py:53
#, python-format
msgid "of"
msgstr "de"
#. module: account_statement_ext
#: view:account.bank.statement:0
msgid "{'invisible':[('balance_check','=',False)]}"
msgstr ""

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<report auto="False"
id="report_bank_statement_webkit"
model="account.bank.statement"
name="bank_statement_webkit"
file="account_statement_ext/report/bank_statement_report.mako"
string="Bank Statement"
report_type="webkit"
webkit_header="account_statement_ext.bank_statement_landscape_header"
header="1"/>
<record id="action_print_bank_statement_webkit" model="ir.values">
<field name="name">Bank Statement</field>
<field name="key2">client_print_multi</field>
<field name="value_unpickle"
eval="'ir.actions.report.xml,' +str(ref('report_bank_statement_webkit'))"/>
<field name="key">action</field>
<field name="model">account.bank.statement</field>
</record>
</data>
</openerp>

View File

@@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import bank_statement_report

View File

@@ -1,70 +0,0 @@
## -*- coding: utf-8 -*-
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
${css}
</style>
</head>
<body>
<%!
def amount(text):
return text.replace('-', '&#8209;') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
%>
<%setLang(user.partner_id.lang)%>
%for statement in objects:
<div class="act_as_table data_table">
<div class="act_as_row labels">
<div class="act_as_cell">${_('Bordereau')}</div>
<div class="act_as_cell">${_('Date')}</div>
</div>
<div class="act_as_row">
<div class="act_as_cell">${ statement.name }</div>
<div class="act_as_cell">${ formatLang(statement.date,date=True) }</div>
</div>
</div>
<!-- we use div with css instead of table for tabular data because div do not cut rows at half at page breaks -->
<div class="act_as_table list_table" style="margin-top: 10px;">
<div class="act_as_thead">
<div class="act_as_row labels">
## date
<div class="act_as_cell first_column" style="width: 100px;">${_('Reference')}</div>
## period
<div class="act_as_cell" style="width: 175px;">${_('Partenaire')}</div>
## move
<div class="act_as_cell" style="width: 60px;">${_('Montant')}</div>
## journal
</div>
</div>
<% sum_statement = 0.0 %>
%for statementline in statement.line_ids:
<div class="act_as_tbody">
## curency code
<div class="act_as_cell">${statementline.name or '' }</div>
## currency balance
<div class="act_as_cell">${statementline.partner_id.name or '' }</div>
## currency balance cumulated
<div class="act_as_cell amount">${formatLang(statementline.amount) | amount }</div>
<% sum_statement += statementline.amount %>
</div>
%endfor
<div class="act_as_tbody">
## curency code
<div class="act_as_cell"></div>
## currency balance
<div class="act_as_cell">Total</div>
## currency balance cumulated
<div class="act_as_cell amount_total">${formatLang(sum_statement) }</div>
</div>
</div>
%endfor
</body>
</html>

View File

@@ -1,71 +0,0 @@
# -*- coding utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
#
# 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.report import report_sxw
from openerp.tools.translate import _
from openerp import pooler
from datetime import datetime
from openerp.addons.report_webkit import webkit_report
class BankStatementWebkit(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(BankStatementWebkit, self).__init__(cr, uid, name, context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
company = self.pool.get('res.users').browse(
self.cr, uid, uid, context=context).company_id
header_report_name = ' - '.join((_('BORDEREAU DE REMISE DE CHEQUES'),
company.name, company.currency_id.name))
footer_date_time = self.formatLang(str(datetime.today())[:19], date_time=True)
self.localcontext.update({
'cr': cr,
'uid': uid,
'get_bank_statement': self._get_bank_statement_data,
'report_name': _('BORDEREAU DE REMISE DE CHEQUES'),
'additional_args': [
('--header-font-name', 'Helvetica'),
('--footer-font-name', 'Helvetica'),
('--header-font-size', '10'),
('--footer-font-size', '6'),
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
('--footer-line',),
],
})
def _get_bank_statement_data(self, statement):
statement_obj = self.pool.get('account.bank.statement.line')
statement_line_ids = statement_obj.search(
self.cr,
self.uid,
[('statement_id', '=', statement.id)])
statement_lines = statement_obj.browse(
self.cr, self.uid, statement_line_ids)
return statement_lines
webkit_report.WebKitParser('report.bank_statement_webkit',
'account.bank.statement',
'addons/account_statement_ext/report/bank_statement_report.mako',
parser=BankStatementWebkit)

View File

@@ -1,180 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="bank_statement_landscape_header" model="ir.header_webkit">
<field name="footer_html"><![CDATA[
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<script>
function subst() {
var vars={};
var x=document.location.search.substring(1).split('&');
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
for(var i in x) {
var y = document.getElementsByClassName(x[i]);
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
}
}
</script>
</head>
<% import datetime %>
<body style="border:0; margin: 0;" onload="subst()">
<table style="border-top: 1px solid black; width: 1080px">
<tr style="border-collapse:collapse;">
<td style="text-align:left;font-size:10;width:350px;">${formatLang( str(datetime.datetime.today()), date_time=True)}</td>
<td style="text-align:center;font-size:10;width:350px;">${user.name}</td>
<td style="text-align:right;font-size:10;width:350px;">Page&nbsp;<span class="page"/></td>
<td style="text-align:left;font-size:10;width:30px">&nbsp;of&nbsp;<span class="topage"/></td>
</tr>
</table>
</body>
</html>]]></field>
<field name="orientation">Portrait</field>
<field name="format">A4</field>
<field name="html"><![CDATA[
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<script>
function subst() {
var vars={};
var x=document.location.search.substring(1).split('&');
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
for(var i in x) {
var y = document.getElementsByClassName(x[i]);
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
}
}
</script>
<style type="text/css">
${css}
</style>
</head>
<body style="border:0; margin: 0;" onload="subst()">
<table class="header" style="border-bottom: 0px solid black; width: 100%">
<tr>
<td style="text-align:left; font-size:11px; font-weight: bold;"><span style="text-transform:uppercase; font-size:12px;">${report_name}</span> - ${company.partner_id.name | entity} - ${company.currency_id.name | entity}</td>
</tr>
</table> ${_debug or ''|n} </body>
</html>]]>
</field>
<field eval="0.0" name="margin_top"/>
<field name="css"><![CDATA[
body, table, td, span, div {
font-family: Helvetica, Arial;
}
.act_as_table {
display: table;
}
.act_as_row {
display: table-row;
}
.act_as_cell {
display: table-cell;
}
.act_as_thead {
display: table-header-group;
}
.act_as_tbody {
display: table-row-group;
}
.act_as_tfoot {
display: table-footer-group;
}
.act_as_caption {
display: table-caption;
}
act_as_colgroup {
display: table-column-group;
}
.list_table, .data_table {
width: 720px;
table-layout: fixed
}
.bg, .act_as_row.labels {
background-color:#F0F0F0;
}
.list_table, .data_table, .list_table .act_as_row {
border-left:0px;
border-right:0px;
text-align:left;
font-size:9px;
padding-right:3px;
padding-left:3px;
padding-top:2px;
padding-bottom:2px;
border-collapse:collapse;
}
.list_table .act_as_row.labels, .list_table .act_as_row.initial_balance, .list_table .act_as_row.lines {
border-color:gray;
border-bottom:1px solid lightGrey;
}
.data_table .act_as_cell {
border: 1px solid lightGrey;
text-align: center;
}
.data_table .act_as_cell, .list_table .lines .act_as_cell {
word-wrap: break-word;
}
.nobreak {
word-wrap: normal;
}
.data_table .act_as_row.labels {
font-weight: bold;
}
.initial_balance .act_as_cell {
font-style:italic;
}
.account_title {
font-size:10px;
font-weight:bold;
page-break-after: avoid;
}
.act_as_cell.amount {
word-wrap:normal;
text-align:right;
}
.act_as_cell.amount_total {
word-wrap:normal;
text-align:right;
font-weight: bold;
}
.list_table .act_as_cell{
padding-left: 5px;
/* border-right:1px solid lightGrey; uncomment to active column lines */
}
.list_table .act_as_cell.first_column {
padding-left: 0px;
/* border-left:1px solid lightGrey; uncomment to active column lines */
}
.sep_left {
border-left: 1px solid lightGrey;
}
]]>
</field>
<field name="name">Bank Statement Landscape Header</field>
</record>
</data>
</openerp>

View File

@@ -1,3 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_bank_st_profile_user,account.statement.profile,model_account_statement_profile,account.group_account_user,1,1,0,0
access_account_bank_st_profile_manager,account.statement.profile,model_account_statement_profile,account.group_account_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_account_bank_st_profile_user account.statement.profile model_account_statement_profile account.group_account_user 1 1 0 0
3 access_account_bank_st_profile_manager account.statement.profile model_account_statement_profile account.group_account_manager 1 1 1 1

View File

@@ -1,10 +0,0 @@
<openerp>
<data noupdate="1">
<record id="account_bank_statement_profile_rule" model="ir.rule">
<field name="name">Bank statement profile multi-company</field>
<field name="model_id" ref="model_account_statement_profile"/>
<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

@@ -1,729 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Joel Grand-Guillaume
# Copyright 2011-2012 Camptocamp SA
#
# 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 openerp.addons.account.account_bank_statement as stat_mod
from openerp.osv.orm import Model
from openerp.osv import fields, osv
from openerp.tools.translate import _
# Monkey patch to fix bad write implementation...
def fixed_write(self, cr, uid, ids, vals, context=None):
""" Fix performance desing of original function
Ideally we should use a real PostgreSQL sequence or serial fields.
I will do it when I have time."""
res = super(stat_mod.account_bank_statement, self).write(cr, uid, ids,
vals, context=context)
if ids: # will be false for an new empty bank statement
cr.execute("UPDATE account_bank_statement_line"
" SET sequence = account_bank_statement_line.id + 1"
" where statement_id in %s", (tuple(ids),))
return res
stat_mod.account_bank_statement.write = fixed_write
class AccountStatementProfile(Model):
"""
A Profile will contain all infos related to the type of
bank statement, and related generated entries. It defines the
journal to use, the partner and commision account and so on.
"""
_name = "account.statement.profile"
_inherit = ['mail.thread']
_description = "Statement Profile"
_order = 'sequence'
_columns = {
'name': fields.char('Name', required=True),
'sequence': fields.integer('Sequence', help="Gives a sequence in lists, the first profile will be used as default"),
'partner_id': fields.many2one(
'res.partner',
'Bank/Payment Office partner',
help="Put a partner if you want to have it on the "
"commission move (and optionaly on the counterpart "
"of the intermediate/banking move if you tick the "
"corresponding checkbox)."),
'journal_id': fields.many2one(
'account.journal',
'Financial journal to use for transaction',
required=True),
'commission_account_id': fields.many2one(
'account.account',
'Commission account',
required=True),
'commission_analytic_id': fields.many2one(
'account.analytic.account',
'Commission analytic account'),
'receivable_account_id': fields.many2one(
'account.account',
'Force Receivable/Payable Account',
help="Choose a receivable account to force the default "
"debit/credit account (eg. an intermediat bank account "
"instead of default debitors)."),
'force_partner_on_bank': fields.boolean(
'Force partner on bank move',
help="Tick that box if you want to use the credit "
"institute partner in the counterpart of the "
"intermediate/banking move."),
'balance_check': fields.boolean(
'Balance check',
help="Tick that box if you want OpenERP to control "
"the start/end balance before confirming a bank statement. "
"If don't ticked, no balance control will be done."),
'bank_statement_prefix': fields.char('Bank Statement Prefix', size=32),
'bank_statement_ids': fields.one2many('account.bank.statement',
'profile_id',
'Bank Statement Imported'),
'company_id': fields.many2one('res.company', 'Company'),
}
def _check_partner(self, cr, uid, ids, context=None):
obj = self.browse(cr, uid, ids[0], context=context)
if obj.partner_id is False and obj.force_partner_on_bank:
return False
return True
_constraints = [
(_check_partner, "You need to put a partner if you tic the 'Force partner on bank move'!", []),
]
_sql_constraints = [
('name_uniq', 'unique (name, company_id)', 'The name of the bank statement must be unique !')
]
class AccountBankStatement(Model):
"""
We improve the bank statement class mostly for :
- Removing the period and compute it from the date of each line.
- Allow to remove the balance check depending on the chosen profile
- Report errors on confirmation all at once instead of crashing onr by one
- Add a profile notion that can change the generated entries on statement
confirmation.
For this, we had to override quite some long method and we'll need to maintain
them up to date. Changes are point up by '#Chg' comment.
"""
_inherit = "account.bank.statement"
def _default_period(self, cr, uid, context=None):
"""
Statement default period
"""
if context is None:
context = {}
period_obj = self.pool.get('account.period')
periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)
return periods and periods[0] or False
def _default_profile(self, cr, uid, context=None):
"""
Returns the default statement profile
Default profile is the one with the lowest sequence of user's company
:return profile_id or False
"""
if context is None:
context = {}
user_obj = self.pool.get('res.users')
profile_obj = self.pool.get('account.statement.profile')
user = user_obj.browse(cr, uid, uid, context=context)
profile_ids = profile_obj.search(cr, uid, [('company_id', '=', user.company_id.id)], context=context)
return profile_ids[0] if profile_ids else False
def _get_statement_from_profile(self, cr, uid, profile_ids, context=None):
"""Stored function field trigger.
Weirdness warning: we are in the class account.bank.statement, but
when the ORM calls this, self is an account.statement.profile.
Returns a list of account.bank.statement ids to recompute.
"""
triggered = []
for profile in self.browse(cr, uid, profile_ids, context=context):
triggered += [st.id for st in profile.bank_statement_ids]
return triggered
def _us(self, cr, uid, ids, context=None):
return ids
_columns = {
'profile_id': fields.many2one(
'account.statement.profile',
'Bank Account Profile',
required=True,
states={'draft': [('readonly', False)]}),
'credit_partner_id': fields.related(
'profile_id',
'partner_id',
type='many2one',
relation='res.partner',
string='Financial Partner',
store={
'account.bank.statement': (_us, ['profile_id'], 10),
'account.statement.profile': (
_get_statement_from_profile, ['partner_id'], 10),
},
readonly=True),
'balance_check': fields.related(
'profile_id',
'balance_check',
type='boolean',
string='Balance check',
store={
'account.bank.statement': (_us, ['profile_id'], 10),
'account.statement.profile': (
_get_statement_from_profile, ['balance_check'], 10),
},
readonly=True
),
'journal_id': fields.related(
'profile_id',
'journal_id',
type='many2one',
relation='account.journal',
string='Journal',
store={
'account.bank.statement': (_us, ['profile_id'], 10),
'account.statement.profile': (
_get_statement_from_profile, ['journal_id'], 10),
},
readonly=True),
'period_id': fields.many2one(
'account.period',
'Period',
required=False,
readonly=False,
invisible=True),
}
_defaults = {
'period_id': _default_period,
'profile_id': _default_profile,
}
def create(self, cr, uid, vals, context=None):
"""Need to pass the journal_id in vals anytime because of account.cash.statement
need it."""
if 'profile_id' in vals:
profile_obj = self.pool.get('account.statement.profile')
profile = profile_obj.browse(cr, uid, vals['profile_id'], context=context)
vals['journal_id'] = profile.journal_id.id
return super(AccountBankStatement, self
).create(cr, uid, vals, context=context)
def _get_period(self, cr, uid, date, context=None):
"""Return matching period for a date."""
if context is None:
context = {}
period_obj = self.pool.get('account.period')
local_context = context.copy()
local_context['account_period_prefer_normal'] = True
periods = period_obj.find(cr, uid, dt=date, context=local_context)
return periods and periods[0] or False
def _check_company_id(self, cr, uid, ids, context=None):
"""
Adapt this constraint method from the account module to reflect the
move of period_id to the statement line
"""
for statement in self.browse(cr, uid, ids, context=context):
# statement.company_id is a related store=True that for some
# reason doesn't work in YAML tests. As a workaround, I unwind it
# to statement.journal_id.company_id here.
if (statement.period_id and
statement.journal_id.company_id.id !=
statement.period_id.company_id.id):
return False
for line in statement.line_ids:
if (line.period_id and
statement.journal_id.company_id.id
!= line.period_id.company_id.id):
return False
return True
_constraints = [
(_check_company_id,
'The journal and period chosen have to belong to the same company.',
['journal_id', 'period_id']),
]
def _prepare_move(self, cr, uid, st_line, st_line_number, context=None):
"""Add the period_id from the statement line date to the move preparation.
Originaly, it was taken from the statement period_id
:param browse_record st_line: account.bank.statement.line record to
create the move from.
:param char st_line_number: will be used as the name of the generated account move
:return: dict of value to create() the account.move
"""
if context is None:
context = {}
res = super(AccountBankStatement, self
)._prepare_move(cr, uid, st_line, st_line_number,
context=context)
ctx = context.copy()
ctx['company_id'] = st_line.company_id.id
period_id = self._get_period(cr, uid, st_line.date, context=ctx)
res.update({'period_id': period_id})
return res
def _prepare_move_line_vals(
self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
amount_currency=False, account_id=False, analytic_id=False,
partner_id=False, context=None):
"""Add the period_id from the statement line date to the move preparation.
Originaly, it was taken from the statement period_id
:param browse_record st_line: account.bank.statement.line record to
create the move from.
:param int/long move_id: ID of the account.move to link the move line
:param float debit: debit amount of the move line
:param float credit: credit amount of the move line
:param int/long currency_id: ID of currency of the move line to create
:param float amount_currency: amount of the debit/credit expressed in the currency_id
:param int/long account_id: ID of the account to use in the move line if different
from the statement line account ID
:param int/long analytic_id: ID of analytic account to put on the move line
:param int/long partner_id: ID of the partner to put on the move line
:return: dict of value to create() the account.move.line
"""
if context is None:
context = {}
res = super(AccountBankStatement, self)._prepare_move_line_vals(
cr, uid, st_line, move_id, debit, credit,
currency_id=currency_id,
amount_currency=amount_currency,
account_id=account_id,
analytic_id=analytic_id,
partner_id=partner_id, context=context)
ctx = context.copy()
ctx['company_id'] = st_line.company_id.id
period_id = self._get_period(cr, uid, st_line.date, context=ctx)
res.update({'period_id': period_id})
return res
def _get_counter_part_partner(self, cr, uid, st_line, context=None):
"""
We change the move line generated from the lines depending on the profile:
- If partner_id is set and force_partner_on_bank is ticked, we'll let the partner of each line
for the debit line, but we'll change it on the credit move line for the choosen partner_id
=> This will ease the reconciliation process with the bank as the partner will match the bank
statement line
:param browse_record st_line: account.bank.statement.line record to
create the move from.
:return: int/long of the res.partner to use as counterpart
"""
bank_partner_id = super(AccountBankStatement, self
)._get_counter_part_partner(cr, uid, st_line,
context=context)
# get the right partner according to the chosen profile
if st_line.statement_id.profile_id.force_partner_on_bank:
bank_partner_id = st_line.statement_id.profile_id.partner_id.id
return bank_partner_id
def _get_st_number_period_profile(self, cr, uid, date, profile_id):
"""
Retrieve the name of bank statement from sequence, according to the period
corresponding to the date passed in args. Add a prefix if set in the profile.
:param: date: date of the statement used to compute the right period
:param: int/long: profile_id: the account.statement.profile ID from which to take the
bank_statement_prefix for the name
:return: char: name of the bank statement (st_number)
"""
year = self.pool.get('account.period').browse(
cr, uid, self._get_period(cr, uid, date)).fiscalyear_id.id
profile = self.pool.get('account.statement.profile').browse(cr, uid, profile_id)
c = {'fiscalyear_id': year}
obj_seq = self.pool.get('ir.sequence')
journal_sequence_id = (profile.journal_id.sequence_id and
profile.journal_id.sequence_id.id or False)
if journal_sequence_id:
st_number = obj_seq.next_by_id(cr, uid, journal_sequence_id, context=c)
else:
st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement', context=c)
if profile.bank_statement_prefix:
st_number = profile.bank_statement_prefix + st_number
return st_number
def button_confirm_bank(self, cr, uid, ids, context=None):
"""
Completely override the method in order to have
an error message which displays all the messages
instead of having them pop one by one.
We have to copy paste a big block of code, changing the error
stack + managing period from date.
TODO: Log the error in a bank statement field instead of using a popup!
"""
for st in self.browse(cr, uid, ids, context=context):
j_type = st.journal_id.type
company_currency_id = st.journal_id.company_id.currency_id.id
if not self.check_status_condition(cr, uid, st.state, journal_type=j_type):
continue
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
raise osv.except_osv(_('Configuration Error!'),
_('Please verify that an account is defined in the journal.'))
if not st.name == '/':
st_number = st.name
else:
# Begin Changes
st_number = self._get_st_number_period_profile(cr, uid, st.date, st.profile_id.id)
# End Changes
for line in st.move_line_ids:
if line.state != 'valid':
raise osv.except_osv(_('Error!'),
_('The account entries lines are not in valid state.'))
# begin changes
errors_stack = []
for st_line in st.line_ids:
try:
if st_line.analytic_account_id:
if not st.journal_id.analytic_journal_id:
raise osv.except_osv(_('No Analytic Journal!'),
_("You have to assign an analytic"
" journal on the '%s' journal!") % st.journal_id.name)
if not st_line.amount:
continue
st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
self.create_move_from_st_line(cr, uid, st_line.id,
company_currency_id,
st_line_number,
context)
except osv.except_osv, exc:
msg = "Line ID %s with ref %s had following error: %s" % (st_line.id, st_line.ref, exc.value)
errors_stack.append(msg)
except Exception, exc:
msg = "Line ID %s with ref %s had following error: %s" % (st_line.id, st_line.ref, str(exc))
errors_stack.append(msg)
if errors_stack:
msg = u"\n".join(errors_stack)
raise osv.except_osv(_('Error'), msg)
# end changes
self.write(cr, uid, [st.id],
{'name': st_number,
'balance_end_real': st.balance_end},
context=context)
body = _('Statement %s confirmed, journal items were created.') % st_number
self.message_post(cr, uid, [st.id],
body,
context=context)
return self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
def get_account_for_counterpart(self, cr, uid, amount, account_receivable, account_payable):
"""For backward compatibility."""
account_id, type = self.get_account_and_type_for_counterpart(cr, uid, amount,
account_receivable,
account_payable)
return account_id
def _compute_type_from_partner_profile(self, cr, uid, partner_id,
default_type, context=None):
"""Compute the statement line type
from partner profile (customer, supplier)"""
obj_partner = self.pool.get('res.partner')
part = obj_partner.browse(cr, uid, partner_id, context=context)
if part.supplier == part.customer:
return default_type
if part.supplier:
return 'supplier'
else:
return 'customer'
def _compute_type_from_amount(self, cr, uid, amount):
"""Compute the statement type based on amount"""
if amount in (None, False):
return 'general'
if amount < 0:
return 'supplier'
return 'customer'
def get_type_for_counterpart(self, cr, uid, amount, partner_id=False):
"""Give the amount and receive the type to use for the line.
The rules are:
- If the customer checkbox is checked on the found partner, type customer
- If the supplier checkbox is checked on the found partner, typewill be supplier
- If both checkbox are checked or none of them, it'll be based on the amount :
If amount is positif the type customer,
If amount is negativ, the type supplier
:param float: amount of the line
:param int/long: partner_id the partner id
:return: type as string: the default type to use: 'customer' or 'supplier'.
"""
s_line_type = self._compute_type_from_amount(cr, uid, amount)
if partner_id:
s_line_type = self._compute_type_from_partner_profile(cr, uid,
partner_id, s_line_type)
return s_line_type
def get_account_and_type_for_counterpart(self, cr, uid, amount, account_receivable,
account_payable, partner_id=False):
"""
Give the amount, payable and receivable account (that can be found using
get_default_pay_receiv_accounts method) and receive the one to use. This method
should be use when there is no other way to know which one to take.
The rules are:
- If the customer checkbox is checked on the found partner, type and account will be customer and receivable
- If the supplier checkbox is checked on the found partner, type and account will be supplier and payable
- If both checkbox are checked or none of them, it'll be based on the amount :
If amount is positive, the type and account will be customer and receivable,
If amount is negative, the type and account will be supplier and payable
Note that we return the payable or receivable account from agrs and not from the optional partner_id
given!
:param float: amount of the line
:param int/long: account_receivable the receivable account
:param int/long: account_payable the payable account
:param int/long: partner_id the partner id
:return: dict with [account_id as int/long,type as string]: the default account to be used by
statement line as the counterpart of the journal account depending on the amount and the type
as 'customer' or 'supplier'.
"""
account_id = False
ltype = self.get_type_for_counterpart(cr, uid, amount, partner_id=partner_id)
if ltype == 'supplier':
account_id = account_payable
else:
account_id = account_receivable
if not account_id:
raise osv.except_osv(
_('Can not determine account'),
_('Please ensure that minimal properties are set')
)
return [account_id, ltype]
def get_default_pay_receiv_accounts(self, cr, uid, context=None):
"""
We try to determine default payable/receivable accounts to be used as counterpart
from the company default propoerty. This is to be used if there is no otherway to
find the good one, or to find a default value that will be overriden by a completion
method (rules of account_statement_base_completion) afterwards.
:return: tuple of int/long ID that give account_receivable, account_payable based on
company default.
"""
property_obj = self.pool.get('ir.property')
account_receivable = property_obj.get(cr, uid, 'property_account_receivable',
'res.partner', context=context)
account_payable = property_obj.get(cr, uid, 'property_account_payable',
'res.partner', context=context)
return (account_receivable and account_receivable.id or False,
account_payable and account_payable.id or False)
def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
"""
Balance check depends on the profile. If no check for this profile is required,
return True and do nothing, otherwise call super.
:param int/long st_id: ID of the concerned account.bank.statement
:param char: journal_type that concern the bank statement
:return: True
"""
st = self.browse(cr, uid, st_id, context=context)
if st.balance_check:
return super(AccountBankStatement, self
).balance_check(cr, uid, st_id, journal_type,
context=context)
else:
return True
def onchange_imp_config_id(self, cr, uid, ids, profile_id, context=None):
"""
Compute values on the change of the profile.
:param: int/long: profile_id that changed
:return dict of dict with key = name of the field
"""
if not profile_id:
return {}
import_config = self.pool.get("account.statement.profile").browse(
cr, uid, profile_id, context=context)
journal_id = import_config.journal_id.id
return {'value': {'journal_id': journal_id,
'balance_check': import_config.balance_check}}
class AccountBankStatementLine(Model):
"""
Override to compute the period from the date of the line, add a method to retrieve
the values for a line from the profile. Override the on_change method to take care of
the profile when fullfilling the bank statement manually. Set the reference to 64
Char long instead 32.
"""
_inherit = "account.bank.statement.line"
def _get_period(self, cr, uid, context=None):
"""Return matching period for a date."""
if context is None:
context = {}
period_obj = self.pool['account.period']
date = context.get('date')
local_context = context.copy()
local_context['account_period_prefer_normal'] = True
try:
periods = period_obj.find(cr, uid, dt=date, context=local_context)
except osv.except_osv:
# if no period defined, we are certainly at installation time
return False
return periods and periods[0] or False
def _get_default_account(self, cr, uid, context=None):
return self.get_values_for_line(cr, uid, context=context)['account_id']
_columns = {
# Set them as required + 64 char instead of 32
'ref': fields.char('Reference', size=64, required=True),
'period_id': fields.many2one('account.period', 'Period', required=True),
}
_defaults = {
'period_id': _get_period,
'account_id': _get_default_account,
}
def get_values_for_line(self, cr, uid, profile_id=False, partner_id=False, line_type=False, amount=False, master_account_id=None, context=None):
"""
Return the account_id to be used in the line of a bank statement. It'll base the result as follow:
- If a receivable_account_id is set in the profile, return this value and type = general
# TODO
- Elif how_get_type_account is set to force_supplier or force_customer, will take respectively payable and type=supplier,
receivable and type=customer otherwise
# END TODO
- Elif line_type is given, take the partner receivable/payable property (payable if type=supplier, receivable
otherwise)
- Elif amount is given:
- If the customer checkbox is checked on the found partner, type and account will be customer and receivable
- If the supplier checkbox is checked on the found partner, type and account will be supplier and payable
- If both checkbox are checked or none of them, it'll be based on the amount :
If amount is positive, the type and account will be customer and receivable,
If amount is negative, the type and account will be supplier an payable
- Then, if no partner are given we look and take the property from the company so we always give a value
for account_id. Note that in that case, we return the receivable one.
:param int/long profile_id of the related bank statement
:param int/long partner_id of the line
:param char line_type: a value from: 'general', 'supplier', 'customer'
:param float: amount of the line
:return: A dict of value that can be passed directly to the write method of
the statement line:
{'partner_id': value,
'account_id' : value,
'type' : value,
...
}
"""
res = {}
obj_partner = self.pool.get('res.partner')
obj_stat = self.pool.get('account.bank.statement')
receiv_account = pay_account = account_id = False
# If profile has a receivable_account_id, we return it in any case
if master_account_id:
res['account_id'] = master_account_id
# We return general as default instead of get_type_for_counterpart
# for perfomance reasons as line_type is not a meaningfull value
# as account is forced
res['type'] = line_type if line_type else 'general'
return res
# To optimize we consider passing false means there is no account
# on profile
if profile_id and master_account_id is None:
profile = self.pool.get("account.statement.profile").browse(
cr, uid, profile_id, context=context)
if profile.receivable_account_id:
res['account_id'] = profile.receivable_account_id.id
# We return general as default instead of get_type_for_counterpart
# for perfomance reasons as line_type is not a meaningfull value
# as account is forced
res['type'] = line_type if line_type else 'general'
return res
# If no account is available on profile you have to do the lookup
# This can be quite a performance killer as we read ir.properity fields
if partner_id:
part = obj_partner.browse(cr, uid, partner_id, context=context)
part = part.commercial_partner_id
# When the method is called from bank statement completion,
# ensure that the line's partner is a commercial
# (accounting) entity
res['partner_id'] = part.id
pay_account = part.property_account_payable.id
receiv_account = part.property_account_receivable.id
# If no value, look on the default company property
if not pay_account or not receiv_account:
receiv_account, pay_account = obj_stat.get_default_pay_receiv_accounts(cr, uid, context=None)
account_id, comp_line_type = obj_stat.get_account_and_type_for_counterpart(cr, uid, amount,
receiv_account, pay_account,
partner_id=partner_id)
res['account_id'] = account_id if account_id else receiv_account
res['type'] = line_type if line_type else comp_line_type
return res
def onchange_partner_id(self, cr, uid, ids, partner_id, profile_id=None, context=None):
"""
Override of the basic method as we need to pass the profile_id in the on_change_type
call.
Moreover, we now call the get_account_and_type_for_counterpart method now to get the
type to use.
"""
obj_stat = self.pool.get('account.bank.statement')
if not partner_id:
return {}
line_type = obj_stat.get_type_for_counterpart(cr, uid, 0.0, partner_id=partner_id)
res_type = self.onchange_type(cr, uid, ids, partner_id, line_type, profile_id, context=context)
if res_type['value'] and res_type['value'].get('account_id', False):
return {'value': {'type': line_type,
'account_id': res_type['value']['account_id'],
'voucher_id': False}}
return {'value': {'type': line_type}}
def onchange_type(self, cr, uid, line_id, partner_id, line_type, profile_id, context=None):
"""
Keep the same features as in standard and call super. If an account is returned,
call the method to compute line values.
"""
res = super(AccountBankStatementLine, self
).onchange_type(cr, uid, line_id, partner_id,
line_type, context=context)
if 'account_id' in res['value']:
result = self.get_values_for_line(cr, uid,
profile_id=profile_id,
partner_id=partner_id,
line_type=line_type,
context=context)
if result:
res['value'].update({'account_id': result['account_id']})
return res

View File

@@ -1,160 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="statement_importer_view_form" model="ir.ui.view">
<field name="name">account.statement.profile.view</field>
<field name="model">account.statement.profile</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import statement">
<separator string="" colspan="4"/>
<field name="name" select="1" />
<field name="partner_id" select="1"/>
<field name="company_id" select="1" groups="base.group_multi_company"/>
<field name="journal_id" select="1"/>
<field name="commission_account_id" />
<field name="commission_analytic_id" />
<field name="receivable_account_id" />
<field name="force_partner_on_bank"/>
<field name="balance_check"/>
<field name="bank_statement_prefix"/>
<field name="message_ids" widget="mail_thread" placeholder="Share a note..." colspan="4"/>
</form>
</field>
</record>
<record id="statement_importer_view_tree" model="ir.ui.view">
<field name="name">account.statement.profile.view</field>
<field name="model">account.statement.profile</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Import statement">
<field name="name" />
<field name="partner_id" />
<field name="company_id" groups="base.group_multi_company"/>
<field name="journal_id" />
<field name="commission_account_id" />
<field name="commission_analytic_id" />
<field name="receivable_account_id" />
<field name="force_partner_on_bank"/>
<field name="balance_check"/>
</tree>
</field>
</record>
<record id="action_treasury_statement_profile_tree" model="ir.actions.act_window">
<field name="name">Bank Statements Profile</field>
<field name="res_model">account.statement.profile</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem string="Bank Statements Profile" action="action_treasury_statement_profile_tree" id="menu_treasury_statement_profile_tree" parent="account.menu_configuration_misc" sequence="30"/>
<record id="view_treasury_statement_search" model="ir.ui.view">
<field name="name">account.bank.statement.search</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_search"/>
<field name="arch" type="xml">
<xpath expr="/search/field[@name='name']" position="before">
<field name="id"/>
<field name="profile_id"/>
<field name="credit_partner_id"/>
<separator orientation="vertical"/>
</xpath>
<xpath expr="/search/field[@name='period_id']" position="replace">
</xpath>
<xpath expr="/search/group/filter[@string='Period']" position="replace">
<filter string="Financial Partner" context="{'group_by': 'credit_partner_id'}" icon="terp-partner"/>
</xpath>
</field>
</record>
<record id="view_treasury_statement_tree" model="ir.ui.view">
<field name="name">account.bank.statement.tree</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<xpath expr="/tree/field[@name='name']" position="before">
<field name="id"/>
</xpath>
<xpath expr="/tree/field[@name='name']" position="after">
<field name="profile_id"/>
</xpath>
<xpath expr="/tree/field[@name='period_id']" position="replace">
<field name="credit_partner_id"/>
</xpath>
</field>
</record>
<record id="view_treasury_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement.form</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="type">form</field>
<field name="arch" type="xml" >
<!-- Add before the group : profile and related infos -->
<label for="name" position="before">
<group>
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
<field name="balance_check" invisible="1"/>
</group>
</label>
<field name="journal_id" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<!-- Make balance visible or not depending on profile -->
<field name="balance_start" position="attributes">
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
</field>
<field name="balance_end_real" position="attributes">
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
</field>
<field name="balance_end_real" position="after">
<field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
</field>
<xpath expr="//field[@name='line_ids']/tree/field[@name='sequence']" position="after">
<field name="id" readonly="1" />
</xpath>
<xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
<field name="id" readonly="1" />
</xpath>
<!-- Adapt onchange signature -->
<xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="replace">
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
</xpath>
<xpath expr="//field[@name='line_ids']/form//field[@name='partner_id']" position="replace">
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
</xpath>
<xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace">
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
</xpath>
<!-- also set type hidden as it has no impact on reconciliation -->
<xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace">
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/>
</xpath>
</field>
</record>
<act_window id="act_bank_statement_from_profile"
name="Open Statements"
res_model="account.bank.statement"
src_model="account.statement.profile"
domain="[('profile_id','=',active_id),]"
view_type="form"/>
</data>
</openerp>

View File

@@ -1,78 +0,0 @@
-
In order to test the related fields in the profile, I first need to create a profile
-
!record {model: account.statement.profile, id: profile_test1}:
name: Bank EUR Profile
journal_id: account.bank_journal
commission_account_id: account.a_expense
company_id: base.main_company
partner_id: base.res_partner_1
journal_id: account.check_journal
balance_check: True
-
I create a second profile
-
!record {model: account.statement.profile, id: profile_test2}:
name: Second profile
journal_id: account.bank_journal
commission_account_id: account.a_expense
company_id: base.main_company
partner_id: base.res_partner_3
journal_id: account.bank_journal
balance_check: True
-
Now I create a statement.
-
!record {model: account.bank.statement, id: statement_test1}:
name: Statement 1
profile_id: profile_test1
company_id: base.main_company
-
Now I check that the related data come from the profile
-
!assert {model: account.bank.statement, id: statement_test1, string: Initial data should come from the profile}:
- balance_check is True
- credit_partner_id.id == _ref('base.res_partner_1')
- journal_id.id == _ref('account.check_journal')
-
Now I set the balance flag to False in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
balance_check: False
-
It should be false in the statement as well.
-
!assert {model: account.bank.statement, id: statement_test1, string: We should not check the balance}:
- balance_check is False
-
Now I change the journal in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
journal_id: account.cash_journal
-
The journal should propagate to the statement
-
!assert {model: account.bank.statement, id: statement_test1, string: The journal should be updated}:
- journal_id.id == _ref('account.cash_journal')
-
Now I change the partner in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
partner_id: base.res_partner_2
-
The partner should propagate to the statement
-
!assert {model: account.bank.statement, id: statement_test1, string: The partner should be updated}:
- credit_partner_id.id == _ref('base.res_partner_2')
-
Now I change the profile associated to the statement.
-
!record {model: account.bank.statement, id: statement_test1}:
profile_id: profile_test2
-
The statement should receive information from the new statement.
-
!assert {model: account.bank.statement, id: statement_test1, string: All information should be probagated from the new profile}:
- balance_check is True
- credit_partner_id.id == _ref('base.res_partner_3')
- journal_id.id == _ref('account.bank_journal')

View File

@@ -1,49 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Joel Grand-Guillaume
# Copyright 2011-2013 Camptocamp SA
#
# 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.orm import Model
class AccountVoucher(Model):
_inherit = 'account.voucher'
def _get_period(self, cr, uid, context=None):
"""If period not in context, take it from the move lines"""
if not context.get('period_id') and context.get('move_line_ids'):
res = self.pool.get('account.move.line').browse(
cr, uid, context.get('move_line_ids'), context=context)[0].period_id.id
context['period_id'] = res
elif context.get('date'):
periods = self.pool.get('account.period').find(
cr, uid, dt=context['date'], context=context)
if periods:
context['period_id'] = periods[0]
return super(AccountVoucher, self)._get_period(cr, uid, context)
def create(self, cr, uid, values, context=None):
"""If no period defined in values, ask it from moves."""
if context is None:
context = {}
if not values.get('period_id'):
ctx = dict(context, date=values.get('date'))
values['period_id'] = self._get_period(cr, uid, ctx)
return super(AccountVoucher, self).create(cr, uid, values, context)