mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[MRG] lp:banking-addons/bank-statement-reconcile-7.0 and remove conflicts
This commit is contained in:
@@ -13,8 +13,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
"Language: \n"
|
||||
|
||||
#. module: account_advanced_reconcile
|
||||
|
||||
@@ -14,8 +14,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_advanced_reconcile_transaction_ref
|
||||
#: field:easy.reconcile.advanced.transaction_ref,partner_ids:0
|
||||
|
||||
@@ -14,8 +14,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_easy_reconcile
|
||||
#: code:addons/account_easy_reconcile/easy_reconcile_history.py:101
|
||||
|
||||
@@ -13,8 +13,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
"Language: \n"
|
||||
|
||||
#. module: account_easy_reconcile
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
##############################################################################
|
||||
|
||||
{'name': "Bank statement base completion",
|
||||
'version': '1.0.2',
|
||||
'version': '1.0.3',
|
||||
'author': 'Camptocamp',
|
||||
'maintainer': 'Camptocamp',
|
||||
'category': 'Finance',
|
||||
|
||||
@@ -14,8 +14,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_statement_base_completion
|
||||
#: view:account.statement.completion.rule:0
|
||||
|
||||
@@ -14,8 +14,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_statement_base_completion
|
||||
#: view:account.statement.completion.rule:0
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#################################################################################
|
||||
|
||||
from openerp.osv.orm import Model
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.osv import fields
|
||||
|
||||
|
||||
class res_partner(Model):
|
||||
@@ -32,7 +32,7 @@ class res_partner(Model):
|
||||
|
||||
_columns = {
|
||||
'bank_statement_label': fields.char('Bank Statement Label', size=100,
|
||||
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 \
|
||||
filled (as long as you use this method/rules in your statement profile)."),
|
||||
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 "
|
||||
"filled (as long as you use this method/rules in your statement profile)."),
|
||||
}
|
||||
|
||||
@@ -24,16 +24,17 @@ import sys
|
||||
import logging
|
||||
import simplejson
|
||||
import inspect
|
||||
import datetime
|
||||
|
||||
import psycopg2
|
||||
|
||||
from collections import defaultdict
|
||||
import re
|
||||
from tools.translate import _
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv import osv, orm, fields
|
||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from operator import attrgetter
|
||||
import datetime
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -397,6 +398,8 @@ class AccountStatementLine(orm.Model):
|
||||
"Auto-Completed",
|
||||
help="When this checkbox is ticked, the auto-completion "
|
||||
"process/button will ignore this line."),
|
||||
# Set account_id field as optional by removing required option.
|
||||
'account_id': fields.many2one('account.account', 'Account'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
@@ -440,6 +443,25 @@ class AccountStatementLine(orm.Model):
|
||||
keys.sort()
|
||||
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):
|
||||
""" Serialize sparse fields values in the target serialized field
|
||||
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_rights(cr, uid, 'create', raise_exception=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]))
|
||||
sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
|
||||
try:
|
||||
@@ -487,6 +510,7 @@ class AccountStatementLine(orm.Model):
|
||||
from the ORM for records updating this kind of fields.
|
||||
"""
|
||||
cols = self._get_available_columns([vals])
|
||||
vals = self._prepare_insert(vals, 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
|
||||
try:
|
||||
|
||||
@@ -14,8 +14,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_statement_base_import
|
||||
#: view:credit.statement.import:0
|
||||
|
||||
@@ -14,8 +14,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_statement_base_import
|
||||
#: view:credit.statement.import:0
|
||||
|
||||
@@ -95,7 +95,7 @@ class AccountStatementProfil(Model):
|
||||
return self.prepare_statement_lines_vals(*args, **kwargs)
|
||||
|
||||
def prepare_statement_lines_vals(
|
||||
self, cr, uid, parser_vals, account_payable, account_receivable,
|
||||
self, cr, uid, parser_vals,
|
||||
statement_id, context):
|
||||
"""
|
||||
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
|
||||
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
|
||||
:return: dict of vals that will be passed to create method of statement line.
|
||||
"""
|
||||
@@ -195,18 +193,13 @@ class AccountStatementProfil(Model):
|
||||
statement_vals,
|
||||
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:
|
||||
# Record every line in the bank statement
|
||||
statement_store = []
|
||||
for line in result_row_list:
|
||||
parser_vals = parser.get_st_line_vals(line)
|
||||
values = self.prepare_statement_lines_vals(
|
||||
cr, uid, parser_vals, account_payable, account_receivable, statement_id,
|
||||
cr, uid, parser_vals, statement_id,
|
||||
context)
|
||||
statement_store.append(values)
|
||||
# Hack to bypass ORM poor perfomance. Sob...
|
||||
@@ -251,11 +244,3 @@ class AccountStatementProfil(Model):
|
||||
raise osv.except_osv(_("Statement import error"),
|
||||
_("The statement cannot be created: %s") % st)
|
||||
return statement_id
|
||||
|
||||
|
||||
class AccountBankStatementLine(Model):
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
_columns = {
|
||||
'account_id': fields.many2one('account.account', 'Account'),
|
||||
}
|
||||
|
||||
25
account_statement_completion_label/__init__.py
Normal file
25
account_statement_completion_label/__init__.py
Normal 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
|
||||
|
||||
49
account_statement_completion_label/__openerp__.py
Normal file
49
account_statement_completion_label/__openerp__.py
Normal 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,
|
||||
}
|
||||
|
||||
33
account_statement_completion_label/partner.py
Normal file
33
account_statement_completion_label/partner.py
Normal 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'),
|
||||
}
|
||||
33
account_statement_completion_label/partner_view.xml
Normal file
33
account_statement_completion_label/partner_view.xml
Normal 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>
|
||||
@@ -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
|
||||
|
14
account_statement_completion_label/security/ir_rule.xml
Normal file
14
account_statement_completion_label/security/ir_rule.xml
Normal 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>
|
||||
|
||||
154
account_statement_completion_label/statement.py
Normal file
154
account_statement_completion_label/statement.py
Normal 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'}
|
||||
79
account_statement_completion_label/statement_view.xml
Normal file
79
account_statement_completion_label/statement_view.xml
Normal 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>
|
||||
@@ -20,7 +20,7 @@
|
||||
##############################################################################
|
||||
|
||||
{'name': "Bank statement extension and profiles",
|
||||
'version': '1.3.5',
|
||||
'version': '1.3.6',
|
||||
'author': 'Camptocamp',
|
||||
'maintainer': 'Camptocamp',
|
||||
'category': 'Finance',
|
||||
|
||||
@@ -22,7 +22,7 @@ from openerp.report import report_sxw
|
||||
from openerp.tools.translate import _
|
||||
from openerp import pooler
|
||||
from datetime import datetime
|
||||
from report_webkit import webkit_report
|
||||
from openerp.addons.report_webkit import webkit_report
|
||||
|
||||
|
||||
class BankStatementWebkit(report_sxw.rml_parse):
|
||||
|
||||
@@ -537,31 +537,15 @@ class AccountBankStatement(Model):
|
||||
:return: tuple of int/long ID that give account_receivable, account_payable based on
|
||||
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(
|
||||
cr, uid, property_ids, context=context):
|
||||
if erp_property.fields_id.name == 'property_account_receivable':
|
||||
account_receivable = erp_property.value_reference.id
|
||||
elif erp_property.fields_id.name == 'property_account_payable':
|
||||
account_payable = erp_property.value_reference.id
|
||||
return account_receivable, account_payable
|
||||
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):
|
||||
"""
|
||||
|
||||
@@ -99,10 +99,6 @@
|
||||
<field name="arch" type="xml" >
|
||||
|
||||
<!-- 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">
|
||||
<group>
|
||||
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
|
||||
@@ -110,7 +106,11 @@
|
||||
</group>
|
||||
</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">
|
||||
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
|
||||
</field>
|
||||
@@ -128,7 +128,7 @@
|
||||
<xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
|
||||
<field name="id" readonly="1" />
|
||||
</xpath>
|
||||
# Adapt onchange signature
|
||||
<!-- 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>
|
||||
@@ -139,7 +139,7 @@
|
||||
<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
|
||||
<!-- 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>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
##############################################################################
|
||||
|
||||
{'name': "Bank statement OFX import",
|
||||
'version': '1.0',
|
||||
'version': '1.0.1',
|
||||
'author': 'Servicios Tecnológicos Avanzados - Pedro M. Baeza',
|
||||
'maintainer': 'Pedro M. Baeza',
|
||||
'category': 'Finance',
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
# 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 datetime
|
||||
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.account_statement_base_import.parser import BankStatementImportParser
|
||||
|
||||
try:
|
||||
import ofxparse
|
||||
except:
|
||||
|
||||
@@ -13,8 +13,8 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-03 06:52+0000\n"
|
||||
"X-Generator: Launchpad (build 16985)\n"
|
||||
"X-Launchpad-Export-Date: 2014-05-13 06:34+0000\n"
|
||||
"X-Generator: Launchpad (build 17002)\n"
|
||||
|
||||
#. module: account_statement_regex_account_completion
|
||||
#: field:account.statement.completion.rule,regex:0
|
||||
|
||||
Reference in New Issue
Block a user