[MRG] lp:banking-addons/bank-statement-reconcile-7.0 and remove conflicts

This commit is contained in:
Laurent Mignon (Acsone)
2014-05-16 17:19:54 +02:00
27 changed files with 469 additions and 84 deletions

View File

@@ -13,8 +13,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
"Language: \n" "Language: \n"
#. module: account_advanced_reconcile #. module: account_advanced_reconcile

View File

@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_advanced_reconcile_transaction_ref #. module: account_advanced_reconcile_transaction_ref
#: field:easy.reconcile.advanced.transaction_ref,partner_ids:0 #: field:easy.reconcile.advanced.transaction_ref,partner_ids:0

View File

@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_easy_reconcile #. module: account_easy_reconcile
#: code:addons/account_easy_reconcile/easy_reconcile_history.py:101 #: code:addons/account_easy_reconcile/easy_reconcile_history.py:101

View File

@@ -13,8 +13,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
"Language: \n" "Language: \n"
#. module: account_easy_reconcile #. module: account_easy_reconcile

View File

@@ -20,7 +20,7 @@
############################################################################## ##############################################################################
{'name': "Bank statement base completion", {'name': "Bank statement base completion",
'version': '1.0.2', 'version': '1.0.3',
'author': 'Camptocamp', 'author': 'Camptocamp',
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Finance', 'category': 'Finance',

View File

@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_statement_base_completion #. module: account_statement_base_completion
#: view:account.statement.completion.rule:0 #: view:account.statement.completion.rule:0

View File

@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_statement_base_completion #. module: account_statement_base_completion
#: view:account.statement.completion.rule:0 #: view:account.statement.completion.rule:0

View File

@@ -20,7 +20,7 @@
################################################################################# #################################################################################
from openerp.osv.orm import Model from openerp.osv.orm import Model
from openerp.osv import fields, osv from openerp.osv import fields
class res_partner(Model): class res_partner(Model):
@@ -32,7 +32,7 @@ class res_partner(Model):
_columns = { _columns = {
'bank_statement_label': fields.char('Bank Statement Label', size=100, 'bank_statement_label': fields.char('Bank Statement Label', size=100,
help="Enter the various label found on your bank statement separated by a ; If \ help="Enter the various label found on your bank statement separated by a ; If "
one of this label is include in the bank statement line, the partner will be automatically \ "one of this label is include in the bank statement line, the partner will be automatically "
filled (as long as you use this method/rules in your statement profile)."), "filled (as long as you use this method/rules in your statement profile)."),
} }

View File

@@ -24,16 +24,17 @@ import sys
import logging import logging
import simplejson import simplejson
import inspect import inspect
import datetime
import psycopg2 import psycopg2
from collections import defaultdict from collections import defaultdict
import re import re
from tools.translate import _ from openerp.tools.translate import _
from openerp.osv import osv, orm, fields from openerp.osv import osv, orm, fields
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from operator import attrgetter from operator import attrgetter
import datetime
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -256,7 +257,7 @@ class AccountStatementCompletionRule(orm.Model):
st_obj = self.pool.get('account.bank.statement.line') st_obj = self.pool.get('account.bank.statement.line')
res = {} res = {}
# As we have to iterate on each partner for each line, # As we have to iterate on each partner for each line,
# we memoize the pair to avoid #  we memoize the pair to avoid
# to redo computation for each line. # to redo computation for each line.
# Following code can be done by a single SQL query # Following code can be done by a single SQL query
# but this option is not really maintanable # but this option is not really maintanable
@@ -397,6 +398,8 @@ class AccountStatementLine(orm.Model):
"Auto-Completed", "Auto-Completed",
help="When this checkbox is ticked, the auto-completion " help="When this checkbox is ticked, the auto-completion "
"process/button will ignore this line."), "process/button will ignore this line."),
# Set account_id field as optional by removing required option.
'account_id': fields.many2one('account.account', 'Account'),
} }
_defaults = { _defaults = {
@@ -440,6 +443,25 @@ class AccountStatementLine(orm.Model):
keys.sort() keys.sort()
return keys return keys
def _prepare_insert(self, statement, cols):
""" Apply column formating to prepare data for SQL inserting
Return a copy of statement
"""
st_copy = statement
for k, col in st_copy.iteritems():
if k in cols:
st_copy[k] = self._columns[k]._symbol_set[1](col)
return st_copy
def _prepare_manyinsert(self, statement_store, cols):
""" Apply column formating to prepare multiple SQL inserts
Return a copy of statement_store
"""
values = []
for statement in statement_store:
values.append(self._prepare_insert(statement, cols))
return values
def _serialize_sparse_fields(self, cols, statement_store): def _serialize_sparse_fields(self, cols, statement_store):
""" Serialize sparse fields values in the target serialized field """ Serialize sparse fields values in the target serialized field
Return a copy of statement_store Return a copy of statement_store
@@ -469,6 +491,7 @@ class AccountStatementLine(orm.Model):
statement_line_obj.check_access_rule(cr, uid, [], 'create') statement_line_obj.check_access_rule(cr, uid, [], 'create')
statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True) statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
cols = self._get_available_columns(statement_store, include_serializable=True) cols = self._get_available_columns(statement_store, include_serializable=True)
statement_store = self._prepare_manyinsert(statement_store, cols)
tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols])) tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols]))
sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
try: try:
@@ -487,6 +510,7 @@ class AccountStatementLine(orm.Model):
from the ORM for records updating this kind of fields. from the ORM for records updating this kind of fields.
""" """
cols = self._get_available_columns([vals]) cols = self._get_available_columns([vals])
vals = self._prepare_insert(vals, cols)
tmp_vals = (', '.join(['%s = %%(%s)s' % (i, i) for i in cols])) tmp_vals = (', '.join(['%s = %%(%s)s' % (i, i) for i in cols]))
sql = "UPDATE account_bank_statement_line SET %s where id = %%(id)s;" % tmp_vals sql = "UPDATE account_bank_statement_line SET %s where id = %%(id)s;" % tmp_vals
try: try:
@@ -582,7 +606,7 @@ class AccountBankStatement(orm.Model):
st += ''.join(traceback.format_tb(trbk, 30)) st += ''.join(traceback.format_tb(trbk, 30))
_logger.error(st) _logger.error(st)
if res: if res:
#stat_line_obj.write(cr, uid, [line.id], vals, context=ctx) # stat_line_obj.write(cr, uid, [line.id], vals, context=ctx)
try: try:
stat_line_obj._update_line(cr, uid, res, context=context) stat_line_obj._update_line(cr, uid, res, context=context)
except Exception as exc: except Exception as exc:

View File

@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_statement_base_import #. module: account_statement_base_import
#: view:credit.statement.import:0 #: view:credit.statement.import:0

View File

@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_statement_base_import #. module: account_statement_base_import
#: view:credit.statement.import:0 #: view:credit.statement.import:0

View File

@@ -95,7 +95,7 @@ class AccountStatementProfil(Model):
return self.prepare_statement_lines_vals(*args, **kwargs) return self.prepare_statement_lines_vals(*args, **kwargs)
def prepare_statement_lines_vals( def prepare_statement_lines_vals(
self, cr, uid, parser_vals, account_payable, account_receivable, self, cr, uid, parser_vals,
statement_id, context): statement_id, context):
""" """
Hook to build the values of a line from the parser returned values. At Hook to build the values of a line from the parser returned values. At
@@ -104,8 +104,6 @@ class AccountStatementProfil(Model):
:param dict of vals from parser for account.bank.statement.line (called by :param dict of vals from parser for account.bank.statement.line (called by
parser.get_st_line_vals) parser.get_st_line_vals)
:param int/long account_payable: ID of the receivable account to use
:param int/long account_receivable: ID of the payable account to use
:param int/long statement_id: ID of the concerned account.bank.statement :param int/long statement_id: ID of the concerned account.bank.statement
:return: dict of vals that will be passed to create method of statement line. :return: dict of vals that will be passed to create method of statement line.
""" """
@@ -195,18 +193,13 @@ class AccountStatementProfil(Model):
statement_vals, statement_vals,
context=context) context=context)
if profile.receivable_account_id:
account_receivable = account_payable = profile.receivable_account_id.id
else:
account_receivable, account_payable = statement_obj.get_default_pay_receiv_accounts(
cr, uid, context)
try: try:
# Record every line in the bank statement # Record every line in the bank statement
statement_store = [] statement_store = []
for line in result_row_list: for line in result_row_list:
parser_vals = parser.get_st_line_vals(line) parser_vals = parser.get_st_line_vals(line)
values = self.prepare_statement_lines_vals( values = self.prepare_statement_lines_vals(
cr, uid, parser_vals, account_payable, account_receivable, statement_id, cr, uid, parser_vals, statement_id,
context) context)
statement_store.append(values) statement_store.append(values)
# Hack to bypass ORM poor perfomance. Sob... # Hack to bypass ORM poor perfomance. Sob...
@@ -251,11 +244,3 @@ class AccountStatementProfil(Model):
raise osv.except_osv(_("Statement import error"), raise osv.except_osv(_("Statement import error"),
_("The statement cannot be created: %s") % st) _("The statement cannot be created: %s") % st)
return statement_id return statement_id
class AccountBankStatementLine(Model):
_inherit = "account.bank.statement.line"
_columns = {
'account_id': fields.many2one('account.account', 'Account'),
}

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# account_statement_completion_label for OpenERP
# Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
# @author Benoît GUILLOT <benoit.guillot@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 partner
from . import statement

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# account_statement_completion_label for OpenERP
# Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
# @author Benoît GUILLOT <benoit.guillot@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': 'Bank statement completion from label',
'version': '0.1',
'category': 'Generic Modules/Others',
'license': 'AGPL-3',
'description': """
Improve the basic rule "Match from statement line label (based on partner field 'Bank Statement Label')" provided by the
Bank statement base completion module. The goal is to match the label field from the bank statement line with a partner and
an account.
For this, you have to create your record in the new class account.statement.label where you can link the label you want with a
partner and an account.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
'depends': ['account_statement_base_completion'],
'data': [
'partner_view.xml',
'statement_view.xml',
'security/ir.model.access.csv',
'security/ir_rule.xml',
],
'demo': [],
'installable': True,
'active': False,
}

View File

@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# account_statement_completion_label for OpenERP
# Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
# @author Benoît GUILLOT <benoit.guillot@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
class res_partner(orm.Model):
_inherit = "res.partner"
_columns = {
'bank_statement_label': fields.one2many('account.statement.label',
'partner_id',
'Bank Statement Label'),
}

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
account_statement_completion_label for OpenERP
Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
@author Sébastien BEAU <sebastien.beau@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="bk_view_partner_form" model="ir.ui.view">
<field name="name">account_bank_statement_import.view.partner.form</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="priority">20</field>
<field name="inherit_id" ref="account_statement_base_completion.bk_view_partner_form"/>
<field name="arch" type="xml">
<field name="bank_statement_label" position="replace">
<group groups="account.group_account_invoice" colspan="4">
<field name="bank_statement_label" colspan="4">
<tree string="Statement Label" editable="top">
<field name="label"/>
<field name="account_id"/>
<field name="profile_id"/>
</tree>
</field>
</group>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_statement_label_user,account.statement.label,model_account_statement_label,account.group_account_user,1,0,0,0
access_account_statement_label_manager,account.statement.label,model_account_statement_label,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_statement_label_user account.statement.label model_account_statement_label account.group_account_user 1 0 0 0
3 access_account_statement_label_manager account.statement.label model_account_statement_label account.group_account_manager 1 1 1 1

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="label_rule" model="ir.rule">
<field name="name">Multicompany label</field>
<field ref="model_account_statement_label" name="model_id"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="global" eval="True"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,154 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# account_statement_completion_label for OpenERP
# Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
# @author Benoît GUILLOT <benoit.guillot@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 collections import defaultdict
from openerp.addons.account_statement_base_completion.statement import ErrorTooManyPartner
class ErrorTooManyLabel(Exception):
"""
New Exception definition that is raised when more than one label is matched
by the completion rule.
"""
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class AccountBankSatement(orm.Model):
"""
We add a basic button and stuff to support the auto-completion
of the bank statement once line have been imported or manually fullfill.
"""
_inherit = "account.bank.statement"
def open_completion_label(self, cr, uid, ids, context=None):
return {
'name': 'Statement Label',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.statement.label',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': False,
}
class AccountStatementCompletionRule(orm.Model):
_inherit = "account.statement.completion.rule"
def get_from_label_and_partner_field(self, cr, uid, st_line, context=None):
"""
Match the partner and the account based on the name field of the
statement line and the table account.statement.label.
If more than one statement label matched, raise the ErrorTooManylabel
error.
:param int line_id: id of the concerned account.bank.statement.line
:return:
A dict of value that can be passed directly to the write method of
the statement line or {}
{'partner_id': value,
'account_id': value,
...}
"""
st_obj = self.pool.get('account.bank.statement')
statement = st_obj.browse(cr, uid, st_line['statement_id'][0],
context=context)
res = {}
if not context.get('label_memorizer'):
context['label_memorizer'] = defaultdict(list)
for line in statement.line_ids:
cr.execute("""
SELECT l.partner_id,
l.account_id
FROM account_statement_label as l,
account_bank_statement as s
LEFT JOIN
account_bank_statement_line as st_l
ON
st_l.statement_id = s.id
WHERE
st_l.name ~* l.label
AND
l.profile_id = s.profile_id
AND
st_l.id = %s
""", (line.id,))
for partner, account in cr.fetchall():
context['label_memorizer'][line.id].append({'partner_id': partner,
'account_id': account})
if st_line['id'] in context['label_memorizer']:
label_info = context['label_memorizer'][st_line['id']]
if len(label_info) > 1:
raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by '
'more than one statement label.') %
(st_line['name'], st_line['ref']))
if label_info[0]['partner_id']:
res['partner_id'] = label_info[0]['partner_id']
res['account_id'] = label_info[0]['account_id']
return res
class AccountStatementLabel(orm.Model):
"""Create a new class to map an account statement label to a partner
and a specific account
"""
_name = "account.statement.label"
_description = "Account Statement Label"
_columns = {
'partner_id': fields.many2one('res.partner', 'Partner'),
'label': fields.char('Bank Statement Label', size=100),
'account_id': fields.many2one('account.account', 'Account',
required = True,
help='Account corresponding to the label '
'for a given partner'),
'company_id': fields.related('account_id', 'company_id',
type='many2one',
relation='res.company',
string='Company',
store=True,
readonly=True),
'profile_id': fields.many2one('account.statement.profile',
'Account Profile'),
}
_defaults = {
'company_id': lambda s,cr,uid,c:
s.pool.get('res.company')._company_default_get(cr, uid,
'account.statement.label',
context=c),
}
_sql_constraints = [
('profile_label_unique', 'unique (label, profile_id, company_id)',
'You cannot have similar label for the same profile and company'),
]
def save_and_close_label(self, cr, uid, ids, context=None):
return {'type': 'ir.actions.act_window_close'}

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
account_statement_completion_label for OpenERP
Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
@author Benoît GUILLOT <benoit.guillot@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="bank_statement_view_form" model="ir.ui.view">
<field name="name">account_statement_completion_label.bank_statement.view_form</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="arch" type="xml">
<data>
<xpath expr="/form/sheet/div[@name='import_buttons']" position="after">
<button name="open_completion_label" string="Open Completion Labels"
states='draft,open' type="object" colspan="1"/>
</xpath>
</data>
</field>
</record>
<record id="statement_label_view_form" model="ir.ui.view">
<field name="name">account.statement.label.view</field>
<field name="model">account.statement.label</field>
<field name="arch" type="xml">
<form string="Statement Label">
<field name="label"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="profile_id"/>
<field name="company_id"/>
</form>
</field>
</record>
<record id="statement_label_view_tree" model="ir.ui.view">
<field name="name">account.statement.label.view</field>
<field name="model">account.statement.label</field>
<field name="arch" type="xml">
<tree string="Statement Label">
<field name="label"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="profile_id"/>
</tree>
</field>
</record>
<record id="statement_label_view_search" model="ir.ui.view">
<field name="name">account.statement.label.search</field>
<field name="model">account.statement.label</field>
<field name="arch" type="xml">
<search string="Search Statement Label" >
<field name="label"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="profile_id"/>
</search>
</field>
</record>
<record id="action_statement_label_tree" model="ir.actions.act_window">
<field name="name">Account Statement Label</field>
<field name="res_model">account.statement.label</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="statement_label_view_search"/>
</record>
<menuitem string="Statement Label" action="action_statement_label_tree"
id="menu_action_statement_label_tree_menu" parent="account.menu_configuration_misc"
sequence="40"/>
</data>
</openerp>

View File

@@ -20,7 +20,7 @@
############################################################################## ##############################################################################
{'name': "Bank statement extension and profiles", {'name': "Bank statement extension and profiles",
'version': '1.3.5', 'version': '1.3.6',
'author': 'Camptocamp', 'author': 'Camptocamp',
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Finance', 'category': 'Finance',

View File

@@ -22,7 +22,7 @@ from openerp.report import report_sxw
from openerp.tools.translate import _ from openerp.tools.translate import _
from openerp import pooler from openerp import pooler
from datetime import datetime from datetime import datetime
from report_webkit import webkit_report from openerp.addons.report_webkit import webkit_report
class BankStatementWebkit(report_sxw.rml_parse): class BankStatementWebkit(report_sxw.rml_parse):

View File

@@ -112,7 +112,7 @@ class AccountStatementProfile(Model):
_constraints = [ _constraints = [
(_check_partner, "You need to put a partner if you tic the 'Force partner on bank move'!", []), (_check_partner, "You need to put a partner if you tic the 'Force partner on bank move'!", []),
] ]
_sql_constraints = [ _sql_constraints = [
('name_uniq', 'unique (name, company_id)', 'The name of the bank statement must be unique !') ('name_uniq', 'unique (name, company_id)', 'The name of the bank statement must be unique !')
] ]
@@ -434,7 +434,7 @@ class AccountBankStatement(Model):
if errors_stack: if errors_stack:
msg = u"\n".join(errors_stack) msg = u"\n".join(errors_stack)
raise osv.except_osv(_('Error'), msg) raise osv.except_osv(_('Error'), msg)
#end changes # end changes
self.write(cr, uid, [st.id], self.write(cr, uid, [st.id],
{'name': st_number, {'name': st_number,
'balance_end_real': st.balance_end}, 'balance_end_real': st.balance_end},
@@ -537,31 +537,15 @@ class AccountBankStatement(Model):
:return: tuple of int/long ID that give account_receivable, account_payable based on :return: tuple of int/long ID that give account_receivable, account_payable based on
company default. company default.
""" """
account_receivable = False
account_payable = False
property_obj = self.pool.get('ir.property')
model_fields_obj = self.pool.get('ir.model.fields')
model_fields_ids = model_fields_obj.search(
cr,
uid,
[('name', 'in', ['property_account_receivable',
'property_account_payable']),
('model', '=', 'res.partner')],
context=context
)
property_ids = property_obj.search(cr,
uid,
[('fields_id', 'in', model_fields_ids),
('res_id', '=', False)],
context=context)
for erp_property in property_obj.browse( property_obj = self.pool.get('ir.property')
cr, uid, property_ids, context=context): account_receivable = property_obj.get(cr, uid, 'property_account_receivable',
if erp_property.fields_id.name == 'property_account_receivable': 'res.partner', context=context)
account_receivable = erp_property.value_reference.id account_payable = property_obj.get(cr, uid, 'property_account_payable',
elif erp_property.fields_id.name == 'property_account_payable': 'res.partner', context=context)
account_payable = erp_property.value_reference.id
return account_receivable, account_payable 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): def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
""" """

View File

@@ -96,13 +96,9 @@
<field name="model">account.bank.statement</field> <field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/> <field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml" >
<!-- Add before the group : profile and related infos --> <!-- Add before the group : profile and related infos -->
<field name="journal_id" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<label for="name" position="before"> <label for="name" position="before">
<group> <group>
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/> <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
@@ -110,7 +106,11 @@
</group> </group>
</label> </label>
# Make balance visible or not depending on profile <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"> <field name="balance_start" position="attributes">
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute> <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
</field> </field>
@@ -128,7 +128,7 @@
<xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before"> <xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
<field name="id" readonly="1" /> <field name="id" readonly="1" />
</xpath> </xpath>
# Adapt onchange signature <!-- Adapt onchange signature -->
<xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="replace"> <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)]"/> <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
</xpath> </xpath>
@@ -139,7 +139,7 @@
<xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace"> <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)"/> <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
</xpath> </xpath>
# also set type hidden as it has no impact on reconciliation <!-- also set type hidden as it has no impact on reconciliation -->
<xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace"> <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"/> <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/>
</xpath> </xpath>

View File

@@ -21,7 +21,7 @@
############################################################################## ##############################################################################
{'name': "Bank statement OFX import", {'name': "Bank statement OFX import",
'version': '1.0', 'version': '1.0.1',
'author': 'Servicios Tecnológicos Avanzados - Pedro M. Baeza', 'author': 'Servicios Tecnológicos Avanzados - Pedro M. Baeza',
'maintainer': 'Pedro M. Baeza', 'maintainer': 'Pedro M. Baeza',
'category': 'Finance', 'category': 'Finance',
@@ -36,7 +36,7 @@
Allows to import OFX (Open Financial Exchange) statement files, using Allows to import OFX (Open Financial Exchange) statement files, using
*account_statement_base_import* generic inheritance mechanism to import *account_statement_base_import* generic inheritance mechanism to import
statements. statements.
It requires ofxparse library to work. It requires ofxparse library to work.
""", """,
'website': 'http://www.serviciosbaeza.com', 'website': 'http://www.serviciosbaeza.com',

View File

@@ -18,11 +18,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
from openerp.tools.translate import _
from account_statement_base_import.parser import BankStatementImportParser
import tempfile import tempfile
import datetime import datetime
from openerp.tools.translate import _
from openerp.addons.account_statement_base_import.parser import BankStatementImportParser
try: try:
import ofxparse import ofxparse
except: except:

View File

@@ -13,8 +13,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n" "X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
"X-Generator: Launchpad (build 16985)\n" "X-Generator: Launchpad (build 17002)\n"
#. module: account_statement_regex_account_completion #. module: account_statement_regex_account_completion
#: field:account.statement.completion.rule,regex:0 #: field:account.statement.completion.rule,regex:0