banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #00660
[Merge] lp:~camptocamp/banking-addons/bank-statement-reconcile_vre into lp:banking-addons/bank-statement-reconcile-61
Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/banking-addons/bank-statement-reconcile_vre into lp:banking-addons/bank-statement-reconcile-61.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
For more details, see:
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile_vre/+merge/168363
This fix prevent account_advanced_reconcile to crash if ref in the move is not set
--
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile_vre/+merge/168363
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~camptocamp/banking-addons/bank-statement-reconcile_vre into lp:banking-addons/bank-statement-reconcile-61.
=== modified file 'account_advanced_reconcile/__openerp__.py'
--- account_advanced_reconcile/__openerp__.py 2012-11-28 13:22:22 +0000
+++ account_advanced_reconcile/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -30,8 +30,6 @@
'description': """
Advanced reconciliation methods for the module account_easy_reconcile.
-account_easy_reconcile, which is a dependency, is available in the branch: lp:account-extra-addons
-
In addition to the features implemented in account_easy_reconcile, which are:
- reconciliation facilities for big volume of transactions
- setup different profiles of reconciliation by account
@@ -39,31 +37,31 @@
- this module is also a base to create others reconciliation methods
which can plug in the profiles
- a profile a reconciliation can be run manually or by a cron
- - monitoring of reconcilation runs with a few logs
+ - monitoring of reconcilation runs with an history
It implements a basis to created advanced reconciliation methods in a few lines
of code.
Typically, such a method can be:
- - Reconcile entries if the partner and the ref are equal
- - Reconcile entries if the partner is equal and the ref is the same than ref
- or name
- - Reconcile entries if the partner is equal and the ref match with a pattern
+ - Reconcile Journal items if the partner and the ref are equal
+ - Reconcile Journal items if the partner is equal and the ref
+ is the same than ref or name
+ - Reconcile Journal items if the partner is equal and the ref
+ match with a pattern
And they allows:
- Reconciliations with multiple credit / multiple debit lines
- Partial reconciliations
- Write-off amount as well
-A method is already implemented in this module, it matches on entries:
- * Partner
- * Ref on credit move lines should be case insensitive equals to the ref or
+A method is already implemented in this module, it matches on items:
+ - Partner
+ - Ref on credit move lines should be case insensitive equals to the ref or
the name of the debit move line
The base class to find the reconciliations is built to be as efficient as
possible.
-
So basically, if you have an invoice with 3 payments (one per month), the first
month, it will partial reconcile the debit move line with the first payment, the second
month, it will partial reconcile the debit move line with 2 first payments,
@@ -75,9 +73,7 @@
""",
'website': 'http://www.camptocamp.com',
- 'init_xml': [],
- 'update_xml': ['easy_reconcile_view.xml'],
- 'demo_xml': [],
+ 'data': ['easy_reconcile_view.xml'],
'test': [],
'images': [],
'installable': True,
=== modified file 'account_advanced_reconcile/advanced_reconciliation.py'
--- account_advanced_reconcile/advanced_reconciliation.py 2012-08-06 10:06:26 +0000
+++ account_advanced_reconcile/advanced_reconciliation.py 2013-06-10 07:05:32 +0000
@@ -19,14 +19,13 @@
#
##############################################################################
-from openerp.osv.orm import TransientModel
-
-
-class easy_reconcile_advanced_ref(TransientModel):
+from openerp.osv import orm
+
+
+class easy_reconcile_advanced_ref(orm.TransientModel):
_name = 'easy.reconcile.advanced.ref'
_inherit = 'easy.reconcile.advanced'
- _auto = True # False when inherited from AbstractModel
def _skip_line(self, cr, uid, rec, move_line, context=None):
"""
@@ -115,6 +114,5 @@
:yield: matchers as tuple ('matcher key', value(s))
"""
yield ('partner_id', move_line['partner_id'])
- yield ('ref', (move_line['ref'].lower().strip(),
+ yield ('ref', ((move_line['ref'] or '').lower().strip(),
move_line['name'].lower().strip()))
-
=== modified file 'account_advanced_reconcile/base_advanced_reconciliation.py'
--- account_advanced_reconcile/base_advanced_reconciliation.py 2012-08-06 10:06:26 +0000
+++ account_advanced_reconcile/base_advanced_reconciliation.py 2013-06-10 07:05:32 +0000
@@ -19,21 +19,17 @@
#
##############################################################################
-from itertools import groupby, product
-from operator import itemgetter
-from openerp.osv.orm import Model, AbstractModel, TransientModel
-from openerp.osv import fields
-
-
-class easy_reconcile_advanced(AbstractModel):
+from itertools import product
+from openerp.osv import orm
+
+
+class easy_reconcile_advanced(orm.AbstractModel):
_name = 'easy.reconcile.advanced'
_inherit = 'easy.reconcile.base'
def _query_debit(self, cr, uid, rec, context=None):
- """Select all move (debit>0) as candidate. Optional choice on invoice
- will filter with an inner join on the related moves.
- """
+ """Select all move (debit>0) as candidate. """
select = self._select(rec)
sql_from = self._from(rec)
where, params = self._where(rec)
@@ -47,9 +43,7 @@
return cr.dictfetchall()
def _query_credit(self, cr, uid, rec, context=None):
- """Select all move (credit>0) as candidate. Optional choice on invoice
- will filter with an inner join on the related moves.
- """
+ """Select all move (credit>0) as candidate. """
select = self._select(rec)
sql_from = self._from(rec)
where, params = self._where(rec)
@@ -176,9 +170,9 @@
"""
mkey, mvalue = matcher
omkey, omvalue = opposite_matcher
- assert mkey == omkey, "A matcher %s is compared with a matcher %s, " \
- " the _matchers and _opposite_matchers are probably wrong" % \
- (mkey, omkey)
+ assert mkey == omkey, ("A matcher %s is compared with a matcher %s, "
+ " the _matchers and _opposite_matchers are probably wrong" %
+ (mkey, omkey))
if not isinstance(mvalue, (list, tuple)):
mvalue = mvalue,
if not isinstance(omvalue, (list, tuple)):
@@ -186,7 +180,13 @@
return easy_reconcile_advanced._compare_matcher_values(mkey, mvalue, omvalue)
def _compare_opposite(self, cr, uid, rec, move_line, opposite_move_line,
- matchers, context=None):
+ matchers, context=None):
+ """ Iterate over the matchers of the move lines vs opposite move lines
+ and if they all match, return True.
+
+ If all the matchers match for a move line and an opposite move line,
+ they are candidate for a reconciliation.
+ """
opp_matchers = self._opposite_matchers(cr, uid, rec, opposite_move_line,
context=context)
for matcher in matchers:
@@ -216,14 +216,15 @@
:return: list of matching lines
"""
matchers = self._matchers(cr, uid, rec, move_line, context=context)
- return [op for op in opposite_move_lines if \
- self._compare_opposite(cr, uid, rec, move_line, op, matchers, context=context)]
+ return [op for op in opposite_move_lines if
+ self._compare_opposite(
+ cr, uid, rec, move_line, op, matchers, context=context)]
def _action_rec(self, cr, uid, rec, context=None):
credit_lines = self._query_credit(cr, uid, rec, context=context)
debit_lines = self._query_debit(cr, uid, rec, context=context)
return self._rec_auto_lines_advanced(
- cr, uid, rec, credit_lines, debit_lines, context=context)
+ cr, uid, rec, credit_lines, debit_lines, context=context)
def _skip_line(self, cr, uid, rec, move_line, context=None):
"""
@@ -234,9 +235,7 @@
return False
def _rec_auto_lines_advanced(self, cr, uid, rec, credit_lines, debit_lines, context=None):
- if context is None:
- context = {}
-
+ """ Advanced reconciliation main loop """
reconciled_ids = []
partial_reconciled_ids = []
reconcile_groups = []
@@ -271,4 +270,3 @@
partial_reconciled_ids += reconcile_group_ids
return reconciled_ids, partial_reconciled_ids
-
=== modified file 'account_advanced_reconcile/easy_reconcile.py'
--- account_advanced_reconcile/easy_reconcile.py 2012-06-20 14:10:01 +0000
+++ account_advanced_reconcile/easy_reconcile.py 2013-06-10 07:05:32 +0000
@@ -19,10 +19,10 @@
#
##############################################################################
-from openerp.osv.orm import Model
-
-
-class account_easy_reconcile_method(Model):
+from openerp.osv import orm
+
+
+class account_easy_reconcile_method(orm.Model):
_inherit = 'account.easy.reconcile.method'
@@ -31,7 +31,6 @@
_get_all_rec_method(cr, uid, context=context)
methods += [
('easy.reconcile.advanced.ref',
- 'Advanced. Partner and Ref.'),
+ 'Advanced. Partner and Ref.'),
]
return methods
-
=== modified file 'account_advanced_reconcile/easy_reconcile_view.xml'
--- account_advanced_reconcile/easy_reconcile_view.xml 2012-06-27 07:58:32 +0000
+++ account_advanced_reconcile/easy_reconcile_view.xml 2013-06-10 07:05:32 +0000
@@ -4,13 +4,12 @@
<record id="view_easy_reconcile_form" model="ir.ui.view">
<field name="name">account.easy.reconcile.form</field>
<field name="model">account.easy.reconcile</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_easy_reconcile.account_easy_reconcile_form"/>
<field name="arch" type="xml">
<page name="information" position="inside">
<group colspan="2" col="2">
<separator colspan="4" string="Advanced. Partner and Ref"/>
- <label string="Match multiple debit vs multiple credit entries. Allow partial reconcilation.
+ <label string="Match multiple debit vs multiple credit entries. Allow partial reconciliation.
The lines should have the partner, the credit entry ref. is matched vs the debit entry ref. or name." colspan="4"/>
</group>
</page>
=== modified file 'account_advanced_reconcile/i18n/fr.po'
--- account_advanced_reconcile/i18n/fr.po 2012-12-13 13:57:29 +0000
+++ account_advanced_reconcile/i18n/fr.po 2013-06-10 07:05:32 +0000
@@ -1,18 +1,19 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
-# * account_advanced_reconcile
+# * account_advanced_reconcile
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-07 12:34+0000\n"
-"PO-Revision-Date: 2012-11-07 12:34+0000\n"
-"Last-Translator: <>\n"
+"POT-Creation-Date: 2013-01-04 08:25+0000\n"
+"PO-Revision-Date: 2013-01-04 09:27+0100\n"
+"Last-Translator: Guewen Baconnier <guewen.baconnier@xxxxxxxxxxxxxx>\n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
+"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: account_advanced_reconcile
@@ -33,12 +34,6 @@
msgstr "Méthode de lettrage pour le module account_easy_reconcile"
#. module: account_advanced_reconcile
-#: field:easy.reconcile.advanced,date_base_on:0
-#: field:easy.reconcile.advanced.ref,date_base_on:0
-msgid "Date of reconcilation"
-msgstr "Date de lettrage"
-
-#. module: account_advanced_reconcile
#: field:easy.reconcile.advanced,journal_id:0
#: field:easy.reconcile.advanced.ref,journal_id:0
msgid "Journal"
@@ -51,6 +46,11 @@
msgstr "Compte de produit"
#. module: account_advanced_reconcile
+#: view:account.easy.reconcile:0
+msgid "Match multiple debit vs multiple credit entries. Allow partial reconciliation. The lines should have the partner, the credit entry ref. is matched vs the debit entry ref. or name."
+msgstr "Le Lettrage peut s'effectuer sur plusieurs écritures de débit et crédit. Le Lettrage partiel est autorisé. Les écritures doivent avoir le même partenaire et la référence sur les écritures de crédit doit se retrouver dans la référence ou la description sur les écritures de débit."
+
+#. module: account_advanced_reconcile
#: field:easy.reconcile.advanced,filter:0
#: field:easy.reconcile.advanced.ref,filter:0
msgid "Filter"
@@ -62,9 +62,10 @@
msgstr "Avancé. Partenaire et Réf."
#. module: account_advanced_reconcile
-#: view:account.easy.reconcile:0
-msgid "Match multiple debit vs multiple credit entries. Allow partial reconcilation. The lines should have the partner, the credit entry ref. is matched vs the debit entry ref. or name."
-msgstr "Le Lettrage peut s'effectuer sur plusieurs écritures de débit et crédit. Le Lettrage partiel est autorisé. Les écritures doivent avoir le même partenaire et la référence sur les écritures de crédit doit se retrouver dans la référence ou la description sur les écritures de débit."
+#: field:easy.reconcile.advanced,date_base_on:0
+#: field:easy.reconcile.advanced.ref,date_base_on:0
+msgid "Date of reconciliation"
+msgstr "Date de lettrage"
#. module: account_advanced_reconcile
#: model:ir.model,name:account_advanced_reconcile.model_easy_reconcile_advanced
=== modified file 'account_easy_reconcile/__openerp__.py'
--- account_easy_reconcile/__openerp__.py 2013-03-12 12:11:33 +0000
+++ account_easy_reconcile/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -20,12 +20,19 @@
##############################################################################
{
+<<<<<<< TREE
"name" : "Easy Reconcile",
"version" : "1.1",
"depends" : ["account",
"base_scheduler_creator"
],
"author" : "Akretion,Camptocamp",
+=======
+ "name": "Easy Reconcile",
+ "version": "1.3.0",
+ "depends": ["account"],
+ "author": "Akretion,Camptocamp",
+>>>>>>> MERGE-SOURCE
"description": """
Easy Reconcile
==============
@@ -44,13 +51,13 @@
reconciliation methods which can plug in the profiles
- a profile a reconciliation can be run manually or by a cron
- monitoring of reconciliation runs with an history
- which keep track of the reconciled entries
+ which keep track of the reconciled Journal items
2 simple reconciliation methods are integrated
in this module, the simple reconciliations works
on 2 lines (1 debit / 1 credit) and do not allow
partial reconcilation, they also match on 1 key,
-partner or entry name.
+partner or Journal item name.
You may be interested to install also the
``account_advanced_reconciliation`` module.
@@ -58,14 +65,13 @@
allows multiple lines and partial.
""",
- "website" : "http://www.akretion.com/",
- "category" : "Finance",
- "init_xml" : [],
- "demo_xml" : [],
- "update_xml" : [
- "easy_reconcile.xml",
- "easy_reconcile_history_view.xml",
- ],
+ "website": "http://www.akretion.com/",
+ "category": "Finance",
+ "demo_xml": [],
+ "data": ["easy_reconcile.xml",
+ "easy_reconcile_history_view.xml",
+ "security/ir_rule.xml",
+ "security/ir.model.access.csv"],
'license': 'AGPL-3',
"auto_install": False,
"installable": True,
=== modified file 'account_easy_reconcile/base_reconciliation.py'
--- account_easy_reconcile/base_reconciliation.py 2012-11-01 16:12:50 +0000
+++ account_easy_reconcile/base_reconciliation.py 2013-06-10 07:05:32 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright 2012 Camptocamp SA (Guewen Baconnier)
+# Copyright 2012-2013 Camptocamp SA (Guewen Baconnier)
# Copyright (C) 2010 Sébastien Beau
#
# This program is free software: you can redistribute it and/or modify
@@ -19,29 +19,29 @@
#
##############################################################################
-from openerp.osv.orm import AbstractModel
-from openerp.osv import fields
+from openerp.osv import fields, orm
from operator import itemgetter, attrgetter
-class easy_reconcile_base(AbstractModel):
+class easy_reconcile_base(orm.AbstractModel):
"""Abstract Model for reconciliation methods"""
_name = 'easy.reconcile.base'
_inherit = 'easy.reconcile.options'
- _auto = True # restore property set to False by AbstractModel
_columns = {
- 'account_id': fields.many2one('account.account', 'Account', required=True),
- 'partner_ids': fields.many2many('res.partner',
- string="Restrict on partners"),
+ 'account_id': fields.many2one(
+ 'account.account', 'Account', required=True),
+ 'partner_ids': fields.many2many(
+ 'res.partner', string="Restrict on partners"),
# other columns are inherited from easy.reconcile.options
}
def automatic_reconcile(self, cr, uid, ids, context=None):
- """
- :return: list of reconciled ids, list of partially reconciled entries
+ """ Reconciliation method called from the view.
+
+ :return: list of reconciled ids, list of partially reconciled items
"""
if isinstance(ids, (int, long)):
ids = [ids]
@@ -50,14 +50,15 @@
return self._action_rec(cr, uid, rec, context=context)
def _action_rec(self, cr, uid, rec, context=None):
- """Must be inherited to implement the reconciliation
+ """ Must be inherited to implement the reconciliation
+
:return: list of reconciled ids
"""
raise NotImplementedError
def _base_columns(self, rec):
- """Mandatory columns for move lines queries
- An extra column aliased as `key` should be defined
+ """ Mandatory columns for move lines queries
+ An extra column aliased as ``key`` should be defined
in each query."""
aml_cols = (
'id',
@@ -104,7 +105,7 @@
return where, params
def _below_writeoff_limit(self, cr, uid, rec, lines,
- writeoff_limit, context=None):
+ writeoff_limit, context=None):
precision = self.pool.get('decimal.precision').precision_get(
cr, uid, 'Account')
keys = ('debit', 'credit')
@@ -119,7 +120,8 @@
writeoff_amount = round(debit - credit, precision)
return bool(writeoff_limit >= abs(writeoff_amount)), debit, credit
- def _get_rec_date(self, cr, uid, rec, lines, based_on='end_period_last_credit', context=None):
+ def _get_rec_date(self, cr, uid, rec, lines,
+ based_on='end_period_last_credit', context=None):
period_obj = self.pool.get('account.period')
def last_period(mlines):
@@ -155,12 +157,14 @@
""" Try to reconcile given lines
:param list lines: list of dict of move lines, they must at least
- contain values for : id, debit, credit
+ contain values for : id, debit, credit
:param boolean allow_partial: if True, partial reconciliation will be
- created, otherwise only Full reconciliation will be created
- :return: tuple of boolean values, first item is wether the the entries
- have been reconciled or not, the second is wether the reconciliation
- is full (True) or partial (False)
+ created, otherwise only Full
+ reconciliation will be created
+ :return: tuple of boolean values, first item is wether the items
+ have been reconciled or not,
+ the second is wether the reconciliation is full (True)
+ or partial (False)
"""
if context is None:
context = {}
@@ -168,8 +172,6 @@
ml_obj = self.pool.get('account.move.line')
writeoff = rec.write_off
- keys = ('debit', 'credit')
-
line_ids = [l['id'] for l in lines]
below_writeoff, sum_debit, sum_credit = self._below_writeoff_limit(
cr, uid, rec, lines, writeoff, context=context)
@@ -204,4 +206,3 @@
return True, False
return False, False
-
=== modified file 'account_easy_reconcile/easy_reconcile.py'
--- account_easy_reconcile/easy_reconcile.py 2013-01-03 15:27:55 +0000
+++ account_easy_reconcile/easy_reconcile.py 2013-06-10 07:05:32 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright 2012 Camptocamp SA (Guewen Baconnier)
+# Copyright 2012-2013 Camptocamp SA (Guewen Baconnier)
# Copyright (C) 2010 Sébastien Beau
#
# This program is free software: you can redistribute it and/or modify
@@ -19,19 +19,18 @@
#
##############################################################################
-import time
-from openerp.osv.orm import Model, AbstractModel
-from openerp.osv import fields
+from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
-class easy_reconcile_options(AbstractModel):
- """Options of a reconciliation profile, columns
- shared by the configuration of methods and by the
- reconciliation wizards. This allows decoupling
- of the methods with the wizards and allows to
- launch the wizards alone
+class easy_reconcile_options(orm.AbstractModel):
+ """Options of a reconciliation profile
+
+ Columns shared by the configuration of methods
+ and by the reconciliation wizards.
+ This allows decoupling of the methods and the
+ wizards and allows to launch the wizards alone
"""
_name = 'easy.reconcile.options'
@@ -46,12 +45,16 @@
_columns = {
'write_off': fields.float('Write off allowed'),
- 'account_lost_id': fields.many2one('account.account', 'Account Lost'),
- 'account_profit_id': fields.many2one('account.account', 'Account Profit'),
- 'journal_id': fields.many2one('account.journal', 'Journal'),
- 'date_base_on': fields.selection(_get_rec_base_date,
+ 'account_lost_id': fields.many2one(
+ 'account.account', 'Account Lost'),
+ 'account_profit_id': fields.many2one(
+ 'account.account', 'Account Profit'),
+ 'journal_id': fields.many2one(
+ 'account.journal', 'Journal'),
+ 'date_base_on': fields.selection(
+ _get_rec_base_date,
required=True,
- string='Date of reconcilation'),
+ string='Date of reconciliation'),
'filter': fields.char('Filter', size=128),
}
@@ -61,13 +64,12 @@
}
-class account_easy_reconcile_method(Model):
+class account_easy_reconcile_method(orm.Model):
_name = 'account.easy.reconcile.method'
_description = 'reconcile method for account_easy_reconcile'
_inherit = 'easy.reconcile.options'
- _auto = True # restore property set to False by AbstractModel
_order = 'sequence'
@@ -82,11 +84,24 @@
return self._get_all_rec_method(cr, uid, context=None)
_columns = {
- 'name': fields.selection(_get_rec_method, 'Type', size=128, required=True),
- 'sequence': fields.integer('Sequence', required=True,
- help="The sequence field is used to order the reconcile method"),
- 'task_id': fields.many2one('account.easy.reconcile', 'Task',
- required=True, ondelete='cascade'),
+ 'name': fields.selection(
+ _get_rec_method, 'Type', required=True),
+ 'sequence': fields.integer(
+ 'Sequence',
+ required=True,
+ help="The sequence field is used to order "
+ "the reconcile method"),
+ 'task_id': fields.many2one(
+ 'account.easy.reconcile',
+ string='Task',
+ required=True,
+ ondelete='cascade'),
+ 'company_id': fields.related('task_id','company_id',
+ relation='res.company',
+ type='many2one',
+ string='Company',
+ store=True,
+ readonly=True),
}
_defaults = {
@@ -94,8 +109,11 @@
}
def init(self, cr):
- """ Migration stuff, name is not anymore methods names
- but models name"""
+ """ Migration stuff
+
+ Name is not anymore methods names but the name
+ of the model which does the reconciliation
+ """
cr.execute("""
UPDATE account_easy_reconcile_method
SET name = 'easy.reconcile.simple.partner'
@@ -108,7 +126,7 @@
""")
-class account_easy_reconcile(Model):
+class account_easy_reconcile(orm.Model):
_name = 'account.easy.reconcile'
_description = 'account easy reconcile'
@@ -147,17 +165,22 @@
return result
_columns = {
- 'name': fields.char('Name', size=64, required=True),
- 'account': fields.many2one('account.account', 'Account', required=True),
- 'reconcile_method': fields.one2many('account.easy.reconcile.method', 'task_id', 'Method'),
- 'unreconciled_count': fields.function(_get_total_unrec,
- type='integer', string='Unreconciled Entries'),
- 'reconciled_partial_count': fields.function(_get_partial_rec,
- type='integer', string='Partially Reconciled Entries'),
+ 'name': fields.char('Name', required=True),
+ 'account': fields.many2one(
+ 'account.account', 'Account', required=True),
+ 'reconcile_method': fields.one2many(
+ 'account.easy.reconcile.method', 'task_id', 'Method'),
+ 'unreconciled_count': fields.function(
+ _get_total_unrec, type='integer', string='Unreconciled Items'),
+ 'reconciled_partial_count': fields.function(
+ _get_partial_rec,
+ type='integer',
+ string='Partially Reconciled Items'),
'history_ids': fields.one2many(
'easy.reconcile.history',
'easy_reconcile_id',
- string='History'),
+ string='History',
+ readonly=True),
'last_history':
fields.function(
_last_history,
@@ -165,16 +188,18 @@
type='many2one',
relation='easy.reconcile.history',
readonly=True),
+ 'company_id': fields.many2one('res.company', 'Company'),
}
def _prepare_run_transient(self, cr, uid, rec_method, context=None):
return {'account_id': rec_method.task_id.account.id,
'write_off': rec_method.write_off,
- 'account_lost_id': rec_method.account_lost_id and \
- rec_method.account_lost_id.id,
- 'account_profit_id': rec_method.account_profit_id and \
- rec_method.account_profit_id.id,
- 'journal_id': rec_method.journal_id and rec_method.journal_id.id,
+ 'account_lost_id': (rec_method.account_lost_id and
+ rec_method.account_lost_id.id),
+ 'account_profit_id': (rec_method.account_profit_id and
+ rec_method.account_profit_id.id),
+ 'journal_id': (rec_method.journal_id and
+ rec_method.journal_id.id),
'date_base_on': rec_method.date_base_on,
'filter': rec_method.filter}
@@ -190,8 +215,6 @@
res = cr.fetchall()
return [row[0] for row in res]
- if context is None:
- context = {}
for rec in self.browse(cr, uid, ids, context=context):
all_ml_rec_ids = []
all_ml_partial_ids = []
@@ -200,7 +223,8 @@
rec_model = self.pool.get(method.name)
auto_rec_id = rec_model.create(
cr, uid,
- self._prepare_run_transient(cr, uid, method, context=context),
+ self._prepare_run_transient(
+ cr, uid, method, context=context),
context=context)
ml_rec_ids, ml_partial_ids = rec_model.automatic_reconcile(
@@ -224,6 +248,7 @@
context=context)
return True
+<<<<<<< TREE
def _no_history(self, cr, uid, rec, context=None):
""" Raise an `osv.except_osv` error, supposed to
be called when there is no history on the reconciliation
@@ -234,6 +259,18 @@
_('There is no history of reconciled '
'entries on the task: %s.') % rec.name)
+=======
+ def _no_history(self, cr, uid, rec, context=None):
+ """ Raise an `osv.except_osv` error, supposed to
+ be called when there is no history on the reconciliation
+ task.
+ """
+ raise osv.except_osv(
+ _('Error'),
+ _('There is no history of reconciled '
+ 'items on the task: %s.') % rec.name)
+
+>>>>>>> MERGE-SOURCE
def last_history_reconcile(self, cr, uid, rec_id, context=None):
""" Get the last history record for this reconciliation profile
and return the action which opens move lines reconciled
=== modified file 'account_easy_reconcile/easy_reconcile.xml'
--- account_easy_reconcile/easy_reconcile.xml 2012-12-20 11:05:28 +0000
+++ account_easy_reconcile/easy_reconcile.xml 2013-06-10 07:05:32 +0000
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
@@ -7,52 +7,64 @@
<field name="name">account.easy.reconcile.form</field>
<field name="priority">20</field>
<field name="model">account.easy.reconcile</field>
- <field name="type">form</field>
<field name="arch" type="xml">
- <form string="Automatic Easy Reconcile">
- <separator colspan="4" string="Task Information" />
- <field name="name" select="1"/>
- <field name="account"/>
- <field name="unreconciled_count"/>
- <field name="reconciled_partial_count"/>
- <separator colspan="4" string="Reconcile Method" />
- <notebook colspan="4">
- <page name="methods" string="Configuration">
- <field name="reconcile_method" colspan = "4" nolabel="1"/>
- <button icon="gtk-ok" name="run_reconcile" colspan="4"
- string="Start Auto Reconcilation" type="object"/>
- <button icon="STOCK_JUMP_TO" name="last_history_reconcile" colspan="2"
- string="Display items reconciled on the last run" type="object"/>
- <button icon="STOCK_JUMP_TO" name="last_history_partial" colspan="2"
- string="Display items partially reconciled on the last run"
- type="object"/>
- </page>
- <page name="history" string="History">
- <field name="history_ids" nolabel="1">
- <tree string="Automatic Easy Reconcile History">
- <field name="date"/>
- <!-- display the count of lines -->
- <field name="reconcile_line_ids"/>
- <button icon="STOCK_JUMP_TO" name="open_reconcile"
- string="Go to reconciled items" type="object"/>
- <!-- display the count of lines -->
- <field name="partial_line_ids"/>
- <button icon="STOCK_JUMP_TO" name="open_partial"
- string="Go to partially reconciled items" type="object"/>
- </tree>
- </field>
- </page>
- <page name="information" string="Information">
- <separator colspan="4" string="Simple. Amount and Name"/>
- <label string="Match one debit line vs one credit line. Do not allow partial reconcilation.
+ <form string="Automatic Easy Reconcile" version="7.0">
+ <header>
+ <button name="run_reconcile" class="oe_highlight"
+ string="Start Auto Reconciliation" type="object"/>
+ <button icon="STOCK_JUMP_TO" name="last_history_reconcile"
+ class="oe_highlight"
+ string="Display items reconciled on the last run"
+ type="object"/>
+ <button icon="STOCK_JUMP_TO" name="last_history_partial"
+ class="oe_highlight"
+ string="Display items partially reconciled on the last run"
+ type="object"/>
+ </header>
+ <sheet>
+ <separator colspan="4" string="Profile Information" />
+ <group>
+ <group>
+ <field name="name" select="1"/>
+ <field name="account"/>
+ <field name="company_id" groups="base.group_multi_company"/>
+ </group>
+ <group>
+ <field name="unreconciled_count"/>
+ <field name="reconciled_partial_count"/>
+ </group>
+ </group>
+ <notebook colspan="4">
+ <page name="methods" string="Configuration">
+ <field name="reconcile_method" colspan = "4" nolabel="1"/>
+ </page>
+ <page name="history" string="History">
+ <field name="history_ids" nolabel="1">
+ <tree string="Automatic Easy Reconcile History">
+ <field name="date"/>
+ <button icon="STOCK_JUMP_TO" name="open_reconcile"
+ string="Go to reconciled items" type="object"/>
+ <button icon="STOCK_JUMP_TO" name="open_partial"
+ string="Go to partially reconciled items" type="object"/>
+ </tree>
+ </field>
+ </page>
+ <page name="information" string="Information">
+ <separator colspan="4" string="Simple. Amount and Name"/>
+ <label string="Match one debit line vs one credit line. Do not allow partial reconciliation.
The lines should have the same amount (with the write-off) and the same name to be reconciled." colspan="4"/>
- <separator colspan="4" string="Simple. Amount and Name"/>
- <label string="Match one debit line vs one credit line. Do not allow partial reconcilation.
+ <separator colspan="4" string="Simple. Amount and Partner"/>
+ <label string="Match one debit line vs one credit line. Do not allow partial reconciliation.
The lines should have the same amount (with the write-off) and the same partner to be reconciled." colspan="4"/>
- </page>
- </notebook>
+ <separator colspan="4" string="Simple. Amount and Reference"/>
+ <label string="Match one debit line vs one credit line. Do not allow partial reconciliation.
+The lines should have the same amount (with the write-off) and the same reference to be reconciled." colspan="4"/>
+
+ </page>
+ </notebook>
+ </sheet>
</form>
</field>
</record>
@@ -61,11 +73,11 @@
<field name="name">account.easy.reconcile.tree</field>
<field name="priority">20</field>
<field name="model">account.easy.reconcile</field>
- <field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Automatic Easy Reconcile">
<field name="name"/>
<field name="account"/>
+ <field name="company_id" groups="base.group_multi_company"/>
<field name="unreconciled_count"/>
<field name="reconciled_partial_count"/>
<button icon="gtk-ok" name="run_reconcile" colspan="4"
@@ -85,16 +97,25 @@
<field name="res_model">account.easy.reconcile</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
+ <field name="help" type="html">
+ <p class="oe_view_nocontent_create">
+ Click to add a reconciliation profile.
+ </p><p>
+ A reconciliation profile specifies, for one account, how
+ the entries should be reconciled.
+ You can select one or many reconciliation methods which will
+ be run sequentially to match the entries between them.
+ </p>
+ </field>
</record>
-<!-- account.easy.reconcile.method view -->
+ <!-- account.easy.reconcile.method view -->
<record id="account_easy_reconcile_method_form" model="ir.ui.view">
<field name="name">account.easy.reconcile.method.form</field>
<field name="priority">20</field>
<field name="model">account.easy.reconcile.method</field>
- <field name="type">form</field>
<field name="arch" type="xml">
<form string="Automatic Easy Reconcile Method">
<field name="sequence"/>
@@ -104,7 +125,6 @@
<field name="account_profit_id" attrs="{'required':[('write_off','>',0)]}"/>
<field name="journal_id" attrs="{'required':[('write_off','>',0)]}"/>
<field name="date_base_on"/>
- <field name="filter" groups="base.group_extended"/>
</form>
</field>
</record>
@@ -113,8 +133,7 @@
<field name="name">account.easy.reconcile.method.tree</field>
<field name="priority">20</field>
<field name="model">account.easy.reconcile.method</field>
- <field name="type">tree</field>
- <field name="arch" type="xml">
+ <field name="arch" type="xml">
<tree editable="top" string="Automatic Easy Reconcile Method">
<field name="sequence"/>
<field name="name"/>
@@ -123,14 +142,15 @@
<field name="account_profit_id" attrs="{'required':[('write_off','>',0)]}"/>
<field name="journal_id" attrs="{'required':[('write_off','>',0)]}"/>
<field name="date_base_on"/>
- <field name="filter"/>
</tree>
</field>
</record>
-<!-- menu item -->
+ <!-- menu item -->
- <menuitem action="action_account_easy_reconcile" id="menu_easy_reconcile" parent="account.periodical_processing_reconciliation"/>
+ <menuitem action="action_account_easy_reconcile"
+ id="menu_easy_reconcile"
+ parent="account.periodical_processing_reconciliation"/>
</data>
</openerp>
=== modified file 'account_easy_reconcile/easy_reconcile_history.py'
--- account_easy_reconcile/easy_reconcile_history.py 2012-12-20 10:15:12 +0000
+++ account_easy_reconcile/easy_reconcile_history.py 2013-06-10 07:05:32 +0000
@@ -81,6 +81,13 @@
relation='account.move.line',
readonly=True,
multi='lines'),
+ 'company_id': fields.related('easy_reconcile_id','company_id',
+ relation='res.company',
+ type='many2one',
+ string='Company',
+ store=True,
+ readonly=True),
+
}
def _open_move_lines(self, cr, uid, history_id, rec_type='full', context=None):
=== modified file 'account_easy_reconcile/easy_reconcile_history_view.xml'
--- account_easy_reconcile/easy_reconcile_history_view.xml 2012-12-19 15:40:41 +0000
+++ account_easy_reconcile/easy_reconcile_history_view.xml 2013-06-10 07:05:32 +0000
@@ -5,7 +5,6 @@
<record id="view_easy_reconcile_history_search" model="ir.ui.view">
<field name="name">easy.reconcile.history.search</field>
<field name="model">easy.reconcile.history</field>
- <field name="type">search</field>
<field name="arch" type="xml">
<search string="Automatic Easy Reconcile History">
<filter icon="terp-go-today" string="Today"
@@ -34,44 +33,45 @@
<record id="easy_reconcile_history_form" model="ir.ui.view">
<field name="name">easy.reconcile.history.form</field>
- <field name="priority">16</field>
<field name="model">easy.reconcile.history</field>
- <field name="type">form</field>
<field name="arch" type="xml">
- <form string="Automatic Easy Reconcile History">
- <field name="easy_reconcile_id"/>
- <field name="date"/>
- <group colspan="2" col="2">
- <separator colspan="2" string="Reconcilations"/>
- <field name="reconcile_ids" nolabel="1"/>
- </group>
- <group colspan="2" col="2">
- <separator colspan="2" string="Partial Reconcilations"/>
- <field name="reconcile_partial_ids" nolabel="1"/>
- </group>
- <group col="2" colspan="4">
- <button icon="STOCK_JUMP_TO" name="open_reconcile" string="Go to reconciled items" type="object"/>
- <button icon="STOCK_JUMP_TO" name="open_partial" string="Go to partially reconciled items" type="object"/>
- </group>
+ <form string="Automatic Easy Reconcile History" version="7.0">
+ <header>
+ <button name="open_reconcile"
+ string="Go to reconciled items"
+ icon="STOCK_JUMP_TO" type="object"/>
+ <button name="open_partial"
+ string="Go to partially reconciled items"
+ icon="STOCK_JUMP_TO" type="object"/>
+ </header>
+ <sheet>
+ <group>
+ <field name="easy_reconcile_id"/>
+ <field name="date"/>
+ <field name="company_id" groups="base.group_multi_company"/>
+ </group>
+ <group col="2">
+ <separator colspan="2" string="Reconciliations"/>
+ <field name="reconcile_ids" nolabel="1"/>
+ </group>
+ <group col="2">
+ <separator colspan="2" string="Partial Reconciliations"/>
+ <field name="reconcile_partial_ids" nolabel="1"/>
+ </group>
+ </sheet>
</form>
</field>
</record>
<record id="easy_reconcile_history_tree" model="ir.ui.view">
<field name="name">easy.reconcile.history.tree</field>
- <field name="priority">16</field>
<field name="model">easy.reconcile.history</field>
- <field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Automatic Easy Reconcile History">
<field name="easy_reconcile_id"/>
<field name="date"/>
- <!-- display the count of lines -->
- <field name="reconcile_line_ids"/>
<button icon="STOCK_JUMP_TO" name="open_reconcile"
string="Go to reconciled items" type="object"/>
- <!-- display the count of lines -->
- <field name="partial_line_ids"/>
<button icon="STOCK_JUMP_TO" name="open_partial"
string="Go to partially reconciled items" type="object"/>
</tree>
=== modified file 'account_easy_reconcile/i18n/fr.po'
--- account_easy_reconcile/i18n/fr.po 2013-03-12 12:11:33 +0000
+++ account_easy_reconcile/i18n/fr.po 2013-06-10 07:05:32 +0000
@@ -6,45 +6,73 @@
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-20 08:54+0000\n"
-"PO-Revision-Date: 2012-11-07 12:59+0000\n"
-"Last-Translator: <>\n"
+"POT-Creation-Date: 2013-01-04 08:39+0000\n"
+"PO-Revision-Date: 2013-01-04 09:55+0100\n"
+"Last-Translator: Guewen Baconnier <guewen.baconnier@xxxxxxxxxxxxxx>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
+"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: account_easy_reconcile
-#: code:addons/account_easy_reconcile/easy_reconcile_history.py:103
+#: code:addons/account_easy_reconcile/easy_reconcile_history.py:101
+#: view:easy.reconcile.history:0
+#: field:easy.reconcile.history,reconcile_ids:0
+#, python-format
msgid "Reconciliations"
msgstr "Lettrages"
#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
+#: view:easy.reconcile.history:0
+msgid "Automatic Easy Reconcile History"
+msgstr "Historique des lettrages automatisés"
+
+#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
msgid "Information"
msgstr "Information"
#. module: account_easy_reconcile
-#: view:account.easy.reconcile:0 view:easy.reconcile.history:0
-msgid "Automatic Easy Reconcile History"
-msgstr "Historique des lettrages automatisés"
-
-#. module: account_easy_reconcile
-#: view:account.easy.reconcile:0 view:easy.reconcile.history:0
+#: view:account.easy.reconcile:0
+#: view:easy.reconcile.history:0
msgid "Go to partially reconciled items"
msgstr "Voir les entrées partiellement lettrées"
#. module: account_easy_reconcile
+#: help:account.easy.reconcile.method,sequence:0
+msgid "The sequence field is used to order the reconcile method"
+msgstr "La séquence détermine l'ordre des méthodes de lettrage"
+
+#. module: account_easy_reconcile
#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_history
msgid "easy.reconcile.history"
msgstr "easy.reconcile.history"
#. module: account_easy_reconcile
-#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_simple_name
-msgid "easy.reconcile.simple.name"
-msgstr "easy.reconcile.simple.name"
+#: model:ir.actions.act_window,help:account_easy_reconcile.action_account_easy_reconcile
+msgid ""
+"<p class=\"oe_view_nocontent_create\">\n"
+" Click to add a reconciliation profile.\n"
+" </p><p>\n"
+" A reconciliation profile specifies, for one account, how\n"
+" the entries should be reconciled.\n"
+" You can select one or many reconciliation methods which will\n"
+" be run sequentially to match the entries between them.\n"
+" </p>\n"
+" "
+msgstr ""
+"<p class=\"oe_view_nocontent_create\">\n"
+" Cliquez pour ajouter un profil de lettrage.\n"
+" </p><p>\n"
+" Un profil de lettrage spécifie, pour un compte, comment\n"
+" les écritures doivent être lettrées.\n"
+" Vous pouvez sélectionner une ou plusieurs méthodes de lettrage\n"
+" qui seront lancées successivement pour identifier les écritures\n"
+" devant être lettrées. </p>\n"
+" "
#. module: account_easy_reconcile
#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_options
@@ -57,14 +85,9 @@
msgstr "Grouper par..."
#. module: account_easy_reconcile
-#: view:account.easy.reconcile:0
-msgid "Task Information"
-msgstr "Information sur la tâche"
-
-#. module: account_easy_reconcile
-#: view:account.easy.reconcile:0
-msgid "Reconcile Method"
-msgstr "Méthode de lettrage"
+#: field:account.easy.reconcile,unreconciled_count:0
+msgid "Unreconciled Items"
+msgstr "Écritures non lettrées"
#. module: account_easy_reconcile
#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_base
@@ -72,6 +95,16 @@
msgstr "easy.reconcile.base"
#. module: account_easy_reconcile
+#: field:easy.reconcile.history,reconcile_line_ids:0
+msgid "Reconciled Items"
+msgstr "Écritures lettrées"
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile,reconcile_method:0
+msgid "Method"
+msgstr "Méthode"
+
+#. module: account_easy_reconcile
#: view:easy.reconcile.history:0
msgid "7 Days"
msgstr "7 jours"
@@ -82,29 +115,51 @@
msgstr "Lettrage automatisé"
#. module: account_easy_reconcile
+#: field:easy.reconcile.history,date:0
+msgid "Run date"
+msgstr "Date de lancement"
+
+#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
+msgid "Match one debit line vs one credit line. Do not allow partial reconciliation. The lines should have the same amount (with the write-off) and the same reference to be reconciled."
+msgstr "Lettre un débit avec un crédit ayant le même montant et la même référence. Le lettrage ne peut être partiel (écriture d'ajustement en cas d'écart)."
+
+#. module: account_easy_reconcile
#: model:ir.actions.act_window,name:account_easy_reconcile.act_easy_reconcile_to_history
msgid "History Details"
msgstr "Détails de l'historique"
#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
-msgid ""
-"Match one debit line vs one credit line. Do not allow partial reconcilation. "
-"The lines should have the same amount (with the write-off) and the same name "
-"to be reconciled."
-msgstr ""
-"Lettre un débit avec un crédit ayant le même montant et la même description. "
-"Le lettrage ne peut être partiel (écriture d'ajustement en cas d'écart)."
-
-#. module: account_easy_reconcile
-#: view:account.easy.reconcile:0
msgid "Display items reconciled on the last run"
msgstr "Voir les entrées lettrées au dernier lettrage"
#. module: account_easy_reconcile
-#: model:ir.model,name:account_easy_reconcile.model_account_easy_reconcile_method
-msgid "reconcile method for account_easy_reconcile"
-msgstr "Méthode de lettrage"
+#: field:account.easy.reconcile.method,name:0
+msgid "Type"
+msgstr "Type"
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile.method,journal_id:0
+#: field:easy.reconcile.base,journal_id:0
+#: field:easy.reconcile.options,journal_id:0
+#: field:easy.reconcile.simple,journal_id:0
+#: field:easy.reconcile.simple.name,journal_id:0
+#: field:easy.reconcile.simple.partner,journal_id:0
+#: field:easy.reconcile.simple.reference,journal_id:0
+msgid "Journal"
+msgstr "Journal"
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile.method,account_profit_id:0
+#: field:easy.reconcile.base,account_profit_id:0
+#: field:easy.reconcile.options,account_profit_id:0
+#: field:easy.reconcile.simple,account_profit_id:0
+#: field:easy.reconcile.simple.name,account_profit_id:0
+#: field:easy.reconcile.simple.partner,account_profit_id:0
+#: field:easy.reconcile.simple.reference,account_profit_id:0
+msgid "Account Profit"
+msgstr "Compte de profits"
#. module: account_easy_reconcile
#: view:easy.reconcile.history:0
@@ -117,6 +172,15 @@
msgstr "Simple. Montant et description"
#. module: account_easy_reconcile
+#: field:easy.reconcile.base,partner_ids:0
+#: field:easy.reconcile.simple,partner_ids:0
+#: field:easy.reconcile.simple.name,partner_ids:0
+#: field:easy.reconcile.simple.partner,partner_ids:0
+#: field:easy.reconcile.simple.reference,partner_ids:0
+msgid "Restrict on partners"
+msgstr "Filtrer sur des partenaires"
+
+#. module: account_easy_reconcile
#: model:ir.actions.act_window,name:account_easy_reconcile.action_account_easy_reconcile
#: model:ir.ui.menu,name:account_easy_reconcile.menu_easy_reconcile
msgid "Easy Automatic Reconcile"
@@ -133,54 +197,162 @@
msgstr "Date"
#. module: account_easy_reconcile
+#: field:account.easy.reconcile,last_history:0
+msgid "Last History"
+msgstr "Dernier historique"
+
+#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
msgid "Configuration"
msgstr "Configuration"
#. module: account_easy_reconcile
+#: field:account.easy.reconcile,reconciled_partial_count:0
+#: field:easy.reconcile.history,partial_line_ids:0
+msgid "Partially Reconciled Items"
+msgstr "Écritures partiellement lettrées"
+
+#. module: account_easy_reconcile
#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_simple_partner
msgid "easy.reconcile.simple.partner"
msgstr "easy.reconcile.simple.partner"
#. module: account_easy_reconcile
+#: field:account.easy.reconcile.method,write_off:0
+#: field:easy.reconcile.base,write_off:0
+#: field:easy.reconcile.options,write_off:0
+#: field:easy.reconcile.simple,write_off:0
+#: field:easy.reconcile.simple.name,write_off:0
+#: field:easy.reconcile.simple.partner,write_off:0
+#: field:easy.reconcile.simple.reference,write_off:0
+msgid "Write off allowed"
+msgstr "Écart autorisé"
+
+#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
msgid "Automatic Easy Reconcile"
msgstr "Lettrage automatisé"
#. module: account_easy_reconcile
+#: field:account.easy.reconcile,account:0
+#: field:easy.reconcile.base,account_id:0
+#: field:easy.reconcile.simple,account_id:0
+#: field:easy.reconcile.simple.name,account_id:0
+#: field:easy.reconcile.simple.partner,account_id:0
+#: field:easy.reconcile.simple.reference,account_id:0
+msgid "Account"
+msgstr "Compte"
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile.method,task_id:0
+msgid "Task"
+msgstr "Tâche"
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile,name:0
+msgid "Name"
+msgstr "Nom"
+
+#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
+msgid "Simple. Amount and Partner"
+msgstr "Simple. Montant et partenaire"
+
+#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
msgid "Start Auto Reconcilation"
msgstr "Lancer le lettrage automatisé"
#. module: account_easy_reconcile
+#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_simple_name
+msgid "easy.reconcile.simple.name"
+msgstr "easy.reconcile.simple.name"
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile.method,filter:0
+#: field:easy.reconcile.base,filter:0
+#: field:easy.reconcile.options,filter:0
+#: field:easy.reconcile.simple,filter:0
+#: field:easy.reconcile.simple.name,filter:0
+#: field:easy.reconcile.simple.partner,filter:0
+#: field:easy.reconcile.simple.reference,filter:0
+msgid "Filter"
+msgstr "Filtre"
+
+#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
+msgid "Match one debit line vs one credit line. Do not allow partial reconciliation. The lines should have the same amount (with the write-off) and the same partner to be reconciled."
+msgstr "Lettre un débit avec un crédit ayant le même montant et le même partenaire. Le lettrage ne peut être partiel (écriture d'ajustement en cas d'écart)."
+
+#. module: account_easy_reconcile
+#: field:easy.reconcile.history,easy_reconcile_id:0
+msgid "Reconcile Profile"
+msgstr "Profil de réconciliation"
+
+#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
+msgid "Start Auto Reconciliation"
+msgstr "Lancer le lettrage automatisé"
+
+#. module: account_easy_reconcile
+#: code:addons/account_easy_reconcile/easy_reconcile.py:250
+#, python-format
+msgid "Error"
+msgstr "Erreur"
+
+#. module: account_easy_reconcile
+#: code:addons/account_easy_reconcile/easy_reconcile.py:251
+#, python-format
+msgid "There is no history of reconciled items on the task: %s."
+msgstr "Il n'y a pas d'historique d'écritures lettrées sur la tâche: %s."
+
+#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
+msgid "Match one debit line vs one credit line. Do not allow partial reconciliation. The lines should have the same amount (with the write-off) and the same name to be reconciled."
+msgstr "Lettre un débit avec un crédit ayant le même montant et la même description. Le lettrage ne peut être partiel (écriture d'ajustement en cas d'écart)."
+
+#. module: account_easy_reconcile
+#: field:account.easy.reconcile.method,account_lost_id:0
+#: field:easy.reconcile.base,account_lost_id:0
+#: field:easy.reconcile.options,account_lost_id:0
+#: field:easy.reconcile.simple,account_lost_id:0
+#: field:easy.reconcile.simple.name,account_lost_id:0
+#: field:easy.reconcile.simple.partner,account_lost_id:0
+#: field:easy.reconcile.simple.reference,account_lost_id:0
+msgid "Account Lost"
+msgstr "Compte de pertes"
+
+#. module: account_easy_reconcile
#: view:easy.reconcile.history:0
msgid "Reconciliation Profile"
msgstr "Profil de réconciliation"
#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
+#: field:account.easy.reconcile,history_ids:0
msgid "History"
msgstr "Historique"
#. module: account_easy_reconcile
-#: view:account.easy.reconcile:0 view:easy.reconcile.history:0
+#: view:account.easy.reconcile:0
+#: view:easy.reconcile.history:0
msgid "Go to reconciled items"
msgstr "Voir les entrées lettrées"
#. module: account_easy_reconcile
+#: view:account.easy.reconcile:0
+msgid "Profile Information"
+msgstr "Information sur le profil"
+
+#. module: account_easy_reconcile
#: view:account.easy.reconcile.method:0
msgid "Automatic Easy Reconcile Method"
msgstr "Méthode de lettrage automatisé"
#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
-msgid ""
-"Match one debit line vs one credit line. Do not allow partial reconcilation. "
-"The lines should have the same amount (with the write-off) and the same "
-"partner to be reconciled."
-msgstr ""
-"Lettre un débit avec un crédit ayant le même montant et le même partenaire. "
-"Le lettrage ne peut être partiel (écriture d'ajustement en cas d'écart)."
+msgid "Simple. Amount and Reference"
+msgstr "Simple. Montant et référence"
#. module: account_easy_reconcile
#: view:account.easy.reconcile:0
@@ -188,9 +360,9 @@
msgstr "Afficher les entrées partiellement lettrées au dernier lettrage"
#. module: account_easy_reconcile
-#: view:easy.reconcile.history:0
-msgid "Partial Reconcilations"
-msgstr "Lettrages partiels"
+#: field:account.easy.reconcile.method,sequence:0
+msgid "Sequence"
+msgstr "Séquence"
#. module: account_easy_reconcile
#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_simple
@@ -203,11 +375,30 @@
msgstr "Lettrages des 7 derniers jours"
#. module: account_easy_reconcile
-#: code:addons/account_easy_reconcile/easy_reconcile_history.py:106
+#: field:account.easy.reconcile.method,date_base_on:0
+#: field:easy.reconcile.base,date_base_on:0
+#: field:easy.reconcile.options,date_base_on:0
+#: field:easy.reconcile.simple,date_base_on:0
+#: field:easy.reconcile.simple.name,date_base_on:0
+#: field:easy.reconcile.simple.partner,date_base_on:0
+#: field:easy.reconcile.simple.reference,date_base_on:0
+msgid "Date of reconciliation"
+msgstr "Date de lettrage"
+
+#. module: account_easy_reconcile
+#: code:addons/account_easy_reconcile/easy_reconcile_history.py:104
+#: view:easy.reconcile.history:0
+#: field:easy.reconcile.history,reconcile_partial_ids:0
+#, python-format
msgid "Partial Reconciliations"
msgstr "Lettrages partiels"
#. module: account_easy_reconcile
+#: model:ir.model,name:account_easy_reconcile.model_account_easy_reconcile_method
+msgid "reconcile method for account_easy_reconcile"
+msgstr "Méthode de lettrage"
+
+#. module: account_easy_reconcile
#: model:ir.model,name:account_easy_reconcile.model_easy_reconcile_simple_reference
msgid "easy.reconcile.simple.reference"
msgstr "easy.reconcile.simple.reference"
@@ -217,5 +408,18 @@
msgid "account easy reconcile"
msgstr "Lettrage automatisé"
+#~ msgid "Unreconciled Entries"
+#~ msgstr "Écritures non lettrées"
+
+#, fuzzy
+#~ msgid "Partially Reconciled Entries"
+#~ msgstr "Lettrages partiels"
+
+#~ msgid "Task Information"
+#~ msgstr "Information sur la tâche"
+
+#~ msgid "Reconcile Method"
+#~ msgstr "Méthode de lettrage"
+
#~ msgid "Log"
#~ msgstr "Historique"
=== added file 'account_easy_reconcile/security/ir_rule.xml'
--- account_easy_reconcile/security/ir_rule.xml 1970-01-01 00:00:00 +0000
+++ account_easy_reconcile/security/ir_rule.xml 2013-06-10 07:05:32 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="1">
+ <record id="easy_reconcile_rule" model="ir.rule">
+ <field name="name">Easy reconcile multi-company</field>
+ <field name="model_id" ref="model_account_easy_reconcile"/>
+ <field name="global" eval="True"/>
+ <field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
+ </record>
+
+ <record id="easy_reconcile_history_rule" model="ir.rule">
+ <field name="name">Easy reconcile history multi-company</field>
+ <field name="model_id" ref="model_easy_reconcile_history"/>
+ <field name="global" eval="True"/>
+ <field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
+ </record>
+
+ <record id="easy_reconcile_method_rule" model="ir.rule">
+ <field name="name">Easy reconcile method multi-company</field>
+ <field name="model_id" ref="model_account_easy_reconcile_method"/>
+ <field name="global" eval="True"/>
+ <field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
+ </record>
+ </data>
+</openerp>
=== modified file 'account_easy_reconcile/simple_reconciliation.py'
--- account_easy_reconcile/simple_reconciliation.py 2012-11-01 16:14:03 +0000
+++ account_easy_reconcile/simple_reconciliation.py 2013-06-10 07:05:32 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright 2012 Camptocamp SA (Guewen Baconnier)
+# Copyright 2012-2013 Camptocamp SA (Guewen Baconnier)
# Copyright (C) 2010 Sébastien Beau
#
# This program is free software: you can redistribute it and/or modify
@@ -41,7 +41,7 @@
count = 0
res = []
while (count < len(lines)):
- for i in range(count+1, len(lines)):
+ for i in xrange(count+1, len(lines)):
writeoff_account_id = False
if lines[count][self._key_field] != lines[i][self._key_field]:
break
@@ -94,7 +94,6 @@
_name = 'easy.reconcile.simple.name'
_inherit = 'easy.reconcile.simple'
- _auto = True # False when inherited from AbstractModel
# has to be subclassed
# field name used as key for matching the move lines
@@ -105,17 +104,16 @@
_name = 'easy.reconcile.simple.partner'
_inherit = 'easy.reconcile.simple'
- _auto = True # False when inherited from AbstractModel
# has to be subclassed
# field name used as key for matching the move lines
_key_field = 'partner_id'
+
class easy_reconcile_simple_reference(TransientModel):
_name = 'easy.reconcile.simple.reference'
_inherit = 'easy.reconcile.simple'
- _auto = True # False when inherited from AbstractModel
# has to be subclassed
# field name used as key for matching the move lines
=== modified file 'account_statement_base_completion/__init__.py'
--- account_statement_base_completion/__init__.py 2012-06-22 15:45:50 +0000
+++ account_statement_base_completion/__init__.py 2013-06-10 07:05:32 +0000
@@ -20,4 +20,4 @@
##############################################################################
import statement
-import partner
\ No newline at end of file
+import partner
=== modified file 'account_statement_base_completion/__openerp__.py'
--- account_statement_base_completion/__openerp__.py 2012-07-31 14:29:55 +0000
+++ account_statement_base_completion/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,7 +24,7 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
- 'complexity': 'normal', #easy, normal, expert
+ 'complexity': 'normal',
'depends': ['account_statement_ext'],
'description': """
The goal of this module is to improve the basic bank statement, help dealing with huge volume of
@@ -52,6 +52,10 @@
You can use it with our account_advanced_reconcile module to automatize the reconciliation process.
+
+ TODO: The rules that look for invoices to find out the partner should take back the payable / receivable
+ account from there directly instead of retrieving it from partner properties !
+
""",
'website': 'http://www.camptocamp.com',
'init_xml': [],
@@ -67,5 +71,4 @@
'images': [],
'auto_install': False,
'license': 'AGPL-3',
- 'active': False,
}
=== modified file 'account_statement_base_completion/data.xml'
--- account_statement_base_completion/data.xml 2012-06-26 09:21:35 +0000
+++ account_statement_base_completion/data.xml 2013-06-10 07:05:32 +0000
@@ -7,7 +7,7 @@
<field name="sequence">60</field>
<field name="function_to_call">get_from_label_and_partner_field</field>
</record>
-
+
<record id="bank_statement_completion_rule_3" model="account.statement.completion.rule">
<field name="name">Match from line label (based on partner name)</field>
<field name="sequence">70</field>
@@ -26,7 +26,12 @@
<field name="function_to_call">get_from_ref_and_invoice</field>
</record>
-
-
+ <record id="bank_statement_completion_rule_5" model="account.statement.completion.rule">
+ <field name="name">Match from line reference (based on Invoice Supplier number)</field>
+ <field name="sequence">45</field>
+ <field name="function_to_call">get_from_ref_and_supplier_invoice</field>
+ </record>
+
+
</data>
</openerp>
=== modified file 'account_statement_base_completion/partner.py'
--- account_statement_base_completion/partner.py 2012-06-20 14:10:01 +0000
+++ account_statement_base_completion/partner.py 2013-06-10 07:05:32 +0000
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
#################################################################################
# #
# Copyright (C) 2011 Akretion & Camptocamp
@@ -19,9 +19,11 @@
# #
#################################################################################
-from osv import fields, osv
-
-class res_partner(osv.osv):
+from openerp.osv.orm import Model
+from openerp.osv import fields, osv
+
+
+class res_partner(Model):
"""
Add a bank label on the partner so that we can use it to match
this partner when we found this in a statement line.
@@ -29,10 +31,8 @@
_inherit = 'res.partner'
_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 \
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)."),
}
-
-res_partner()
=== modified file 'account_statement_base_completion/statement.py'
--- account_statement_base_completion/statement.py 2012-12-13 13:57:29 +0000
+++ account_statement_base_completion/statement.py 2013-06-10 07:05:32 +0000
@@ -18,14 +18,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
+# TODO replace customer supplier by package constant
+import traceback
+import sys
+import logging
+
+from collections import defaultdict
+import re
from tools.translate import _
-import netsvc
-logger = netsvc.Logger()
-from openerp.osv.orm import Model, fields
-from openerp.osv import fields, osv
-from operator import itemgetter, attrgetter
+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__)
+
+
class ErrorTooManyPartner(Exception):
"""
New Exception definition that is raised when more than one partner is matched by
@@ -33,233 +41,338 @@
"""
def __init__(self, value):
self.value = value
+
def __str__(self):
return repr(self.value)
-
-class AccountStatementProfil(Model):
+ def __repr__(self):
+ return repr(self.value)
+
+
+class AccountStatementProfil(orm.Model):
"""
Extend the class to add rules per profile that will match at least the partner,
but it could also be used to match other values as well.
"""
-
+
_inherit = "account.statement.profile"
-
- _columns={
- # @Akretion : For now, we don't implement this features, but this would probably be there:
+
+ _columns = {
+ # @Akretion: For now, we don't implement this features, but this would probably be there:
# 'auto_completion': fields.text('Auto Completion'),
# 'transferts_account_id':fields.many2one('account.account', 'Transferts Account'),
- # => You can implement it in a module easily, we design it with your needs in mind
- # as well !
-
- 'rule_ids':fields.many2many('account.statement.completion.rule',
+ # => You can implement it in a module easily, we design it with your needs in mind
+ # as well!
+
+ 'rule_ids': fields.many2many(
+ 'account.statement.completion.rule',
string='Related statement profiles',
- rel='as_rul_st_prof_rel',
- ),
+ rel='as_rul_st_prof_rel'),
}
-
- def find_values_from_rules(self, cr, uid, id, line_id, context=None):
+
+ def _get_callable(self, cr, uid, profile, context=None):
+ if isinstance(profile, (int, long)):
+ prof = self.browse(cr, uid, profile, context=context)
+ else:
+ prof = profile
+ # We need to respect the sequence order
+ sorted_array = sorted(prof.rule_ids, key=attrgetter('sequence'))
+ return tuple((x.function_to_call for x in sorted_array))
+
+ def _find_values_from_rules(self, cr, uid, calls, line, context=None):
"""
- This method will execute all related rules, in their sequence order,
+ This method will execute all related rules, in their sequence order,
to retrieve all the values returned by the first rules that will match.
-
- :param int/long line_id: id of the concerned account.bank.statement.line
+ :param calls: list of lookup function name available in rules
+ :param dict line: read 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,
-
+ 'account_id: value,
+
...}
"""
- if not context:
- context={}
- res = {}
+ if context is None:
+ context = {}
+ if not calls:
+ calls = self._get_callable(cr, uid, line['profile_id'], context=context)
rule_obj = self.pool.get('account.statement.completion.rule')
- profile = self.browse(cr, uid, id, context=context)
- # We need to respect the sequence order
- sorted_array = sorted(profile.rule_ids, key=attrgetter('sequence'))
- for rule in sorted_array:
- method_to_call = getattr(rule_obj, rule.function_to_call)
- result = method_to_call(cr,uid,line_id,context)
+
+ for call in calls:
+ method_to_call = getattr(rule_obj, call)
+ result = method_to_call(cr, uid, line, context)
if result:
+ result['already_completed'] = True
return result
- return res
-
-
-class AccountStatementCompletionRule(Model):
+ return None
+
+
+class AccountStatementCompletionRule(orm.Model):
"""
This will represent all the completion method that we can have to
fullfill the bank statement lines. You'll be able to extend them in you own module
and choose those to apply for every statement profile.
The goal of a rule is to fullfill at least the partner of the line, but
- if possible also the reference because we'll use it in the reconciliation
+ if possible also the reference because we'll use it in the reconciliation
process. The reference should contain the invoice number or the SO number
or any reference that will be matched by the invoice accounting move.
"""
-
+
_name = "account.statement.completion.rule"
_order = "sequence asc"
-
+
def _get_functions(self, cr, uid, context=None):
"""
List of available methods for rules. Override this to add you own.
"""
return [
- ('get_from_ref_and_invoice', 'From line reference (based on invoice number)'),
+ ('get_from_ref_and_invoice', 'From line reference (based on customer invoice number)'),
+ ('get_from_ref_and_supplier_invoice', 'From line reference (based on supplier invoice number)'),
('get_from_ref_and_so', 'From line reference (based on SO number)'),
('get_from_label_and_partner_field', 'From line label (based on partner field)'),
- ('get_from_label_and_partner_name', 'From line label (based on partner name)'),
- ]
-
- _columns={
+ ('get_from_label_and_partner_name', 'From line label (based on partner name)')]
+
+ _columns = {
'sequence': fields.integer('Sequence', help="Lower means parsed first."),
'name': fields.char('Name', size=128),
- 'profile_ids': fields.many2many('account.statement.profile',
- rel='as_rul_st_prof_rel',
+ 'profile_ids': fields.many2many(
+ 'account.statement.profile',
+ rel='as_rul_st_prof_rel',
string='Related statement profiles'),
'function_to_call': fields.selection(_get_functions, 'Method'),
}
-
- def get_from_ref_and_invoice(self, cursor, uid, line_id, context=None):
- """
- Match the partner based on the invoice number and the reference of the statement
- line. Then, call the generic get_values_for_line method to complete other values.
- If more than one partner matched, raise the ErrorTooManyPartner error.
-
- :param int/long 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.line')
- st_line = st_obj.browse(cursor,uid,line_id)
+
+ def _find_invoice(self, cr, uid, st_line, inv_type, context=None):
+ """Find invoice related to statement line"""
+ inv_obj = self.pool.get('account.invoice')
+ if inv_type == 'supplier':
+ type_domain = ('in_invoice', 'in_refund')
+ number_field = 'supplier_invoice_number'
+ elif inv_type == 'customer':
+ type_domain = ('out_invoice', 'out_refund')
+ number_field = 'number'
+ else:
+ raise osv.except_osv(_('System error'),
+ _('Invalid invoice type for completion: %') % inv_type)
+
+ inv_id = inv_obj.search(cr, uid,
+ [(number_field, '=', st_line['ref'].strip()),
+ ('type', 'in', type_domain)],
+ context=context)
+ if inv_id:
+ if len(inv_id) == 1:
+ inv = inv_obj.browse(cr, uid, inv_id[0], context=context)
+ else:
+ raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more '
+ 'than one partner while looking on %s invoices') %
+ (st_line['name'], st_line['ref'], inv_type))
+ return inv
+ return False
+
+ def _from_invoice(self, cr, uid, line, inv_type, context):
+ """Populate statement line values"""
+ if not inv_type in ('supplier', 'customer'):
+ raise osv.except_osv(_('System error'),
+ _('Invalid invoice type for completion: %') % inv_type)
res = {}
- if st_line:
- inv_obj = self.pool.get('account.invoice')
- inv_id = inv_obj.search(cursor, uid, [('number', '=', st_line.ref)])
- if inv_id:
- if inv_id and len(inv_id) == 1:
- inv = inv_obj.browse(cursor, uid, inv_id[0])
- res['partner_id'] = inv.partner_id.id
- elif inv_id and len(inv_id) > 1:
- raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than one partner.')%(st_line.name,st_line.ref))
- st_vals = st_obj.get_values_for_line(cursor, uid, profile_id = st_line.statement_id.profile_id.id,
- partner_id = res.get('partner_id',False), line_type = st_line.type, amount = st_line.amount, context = context)
- res.update(st_vals)
+ inv = self._find_invoice(cr, uid, line, inv_type, context=context)
+ if inv:
+ res = {'partner_id': inv.partner_id.id,
+ 'account_id': inv.account_id.id,
+ 'type': inv_type}
+ override_acc = line['master_account_id']
+ if override_acc:
+ res['account_id'] = override_acc
return res
- def get_from_ref_and_so(self, cursor, uid, line_id, context=None):
- """
- Match the partner based on the SO number and the reference of the statement
- line. Then, call the generic get_values_for_line method to complete other values.
- If more than one partner matched, raise the ErrorTooManyPartner error.
-
- :param int/long 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,
-
+ # Should be private but data are initialised with no update XML
+ def get_from_ref_and_supplier_invoice(self, cr, uid, line, context=None):
+ """
+ Match the partner based on the invoice supplier invoice number and the reference of the statement
+ line. Then, call the generic get_values_for_line method to complete other values.
+ If more than one partner matched, raise the ErrorTooManyPartner error.
+
+ :param dict line: read 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,
+
+ ...}
+ """
+ return self._from_invoice(cr, uid, line, 'supplier', context=context)
+
+ # Should be private but data are initialised with no update XML
+ def get_from_ref_and_invoice(self, cr, uid, line, context=None):
+ """
+ Match the partner based on the invoice number and the reference of the statement
+ line. Then, call the generic get_values_for_line method to complete other values.
+ If more than one partner matched, raise the ErrorTooManyPartner error.
+
+ :param dict line: read 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,
+ ...}
+ """
+ return self._from_invoice(cr, uid, line, 'customer', context=context)
+
+ # Should be private but data are initialised with no update XML
+ def get_from_ref_and_so(self, cr, uid, st_line, context=None):
+ """
+ Match the partner based on the SO number and the reference of the statement
+ line. Then, call the generic get_values_for_line method to complete other values.
+ If more than one partner matched, raise the ErrorTooManyPartner error.
+
+ :param int/long st_line: read 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.line')
- st_line = st_obj.browse(cursor,uid,line_id)
res = {}
if st_line:
so_obj = self.pool.get('sale.order')
- so_id = so_obj.search(cursor, uid, [('name', '=', st_line.ref)])
+ so_id = so_obj.search(cr,
+ uid,
+ [('name', '=', st_line['ref'])],
+ context=context)
if so_id:
if so_id and len(so_id) == 1:
- so = so_obj.browse(cursor, uid, so_id[0])
+ so = so_obj.browse(cr, uid, so_id[0], context=context)
res['partner_id'] = so.partner_id.id
elif so_id and len(so_id) > 1:
- raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than one partner.')%(st_line.name,st_line.ref))
- st_vals = st_obj.get_values_for_line(cursor, uid, profile_id = st_line.statement_id.profile_id.id,
- partner_id = res.get('partner_id',False), line_type = st_line.type, amount = st_line.amount, context = context)
+ raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more '
+ 'than one partner while looking on SO by ref.') %
+ (st_line['name'], st_line['ref']))
+ st_vals = st_obj.get_values_for_line(cr,
+ uid,
+ profile_id=st_line['profile_id'],
+ master_account_id=st_line['master_account_id'],
+ partner_id=res.get('partner_id', False),
+ line_type='customer',
+ amount=st_line['amount'] if st_line['amount'] else 0.0,
+ context=context)
res.update(st_vals)
return res
-
- def get_from_label_and_partner_field(self, cursor, uid, line_id, context=None):
+ # Should be private but data are initialised with no update XML
+ def get_from_label_and_partner_field(self, cr, uid, st_line, context=None):
"""
Match the partner based on the label field of the statement line
and the text defined in the 'bank_statement_label' field of the partner.
- Remember that we can have values separated with ; Then, call the generic
+ Remember that we can have values separated with ; Then, call the generic
get_values_for_line method to complete other values.
If more than one partner matched, raise the ErrorTooManyPartner error.
- :param int/long line_id: id of the concerned account.bank.statement.line
+ :param dict st_line: read 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,
-
+ 'account_id': value,
+
...}
"""
partner_obj = self.pool.get('res.partner')
st_obj = self.pool.get('account.bank.statement.line')
- st_line = st_obj.browse(cursor,uid,line_id)
res = {}
- compt = 0
- if st_line:
- ids = partner_obj.search(cursor, uid, [['bank_statement_label', '!=', False]], context=context)
- for partner in partner_obj.browse(cursor, uid, ids, context=context):
- for partner_label in partner.bank_statement_label.split(';'):
- if partner_label in st_line.label:
- compt += 1
- res['partner_id'] = partner.id
- if compt > 1:
- raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than one partner.')%(st_line.name,st_line.ref))
- if res:
- st_vals = st_obj.get_values_for_line(cursor, uid, profile_id = st_line.statement_id.profile_id.id,
- partner_id = res.get('partner_id',False), line_type = st_line.type, amount = st_line.amount, context = context)
- res.update(st_vals)
+ # As we have to iterate on each partner for each line,
+ # we memoize the pair to avoid
+ # to redo computation for each line.
+ # Following code can be done by a single SQL query
+ # but this option is not really maintanable
+ if not context.get('label_memoizer'):
+ context['label_memoizer'] = defaultdict(list)
+ partner_ids = partner_obj.search(cr,
+ uid,
+ [('bank_statement_label', '!=', False)])
+ line_ids = context.get('line_ids', [])
+ for partner in partner_obj.browse(cr, uid, partner_ids, context=context):
+ vals = '|'.join(re.escape(x.strip()) for x in partner.bank_statement_label.split(';'))
+ or_regex = ".*%s.*" % vals
+ sql = ("SELECT id from account_bank_statement_line"
+ " WHERE id in %s"
+ " AND name ~* %s")
+ cr.execute(sql, (line_ids, or_regex))
+ pairs = cr.fetchall()
+ for pair in pairs:
+ context['label_memoizer'][pair[0]].append(partner)
+
+ if st_line['id'] in context['label_memoizer']:
+ found_partner = context['label_memoizer'][st_line['id']]
+ if len(found_partner) > 1:
+ msg = (_('Line named "%s" (Ref:%s) was matched by '
+ 'more than one partner while looking on partner label: %s') %
+ (st_line['name'], st_line['ref'], ','.join([x.name for x in found_partner])))
+ raise ErrorTooManyPartner(msg)
+ res['partner_id'] = found_partner[0].id
+ st_vals = st_obj.get_values_for_line(cr,
+ uid,
+ profile_id=st_line['profile_id'],
+ master_account_id=st_line['master_account_id'],
+ partner_id=found_partner[0].id,
+ line_type=False,
+ amount=st_line['amount'] if st_line['amount'] else 0.0,
+ context=context)
+ res.update(st_vals)
return res
- def get_from_label_and_partner_name(self, cursor, uid, line_id, context=None):
+ def get_from_label_and_partner_name(self, cr, uid, st_line, context=None):
"""
Match the partner based on the label field of the statement line
and the name of the partner.
Then, call the generic get_values_for_line method to complete other values.
If more than one partner matched, raise the ErrorTooManyPartner error.
- :param int/long line_id: id of the concerned account.bank.statement.line
+ :param dict st_line: read 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,
-
+ 'account_id': value,
+
...}
"""
- # This Method has not been tested yet !
res = {}
+ # We memoize allowed partner
+ if not context.get('partner_memoizer'):
+ context['partner_memoizer'] = tuple(self.pool['res.partner'].search(cr, uid, []))
+ if not context['partner_memoizer']:
+ return res
st_obj = self.pool.get('account.bank.statement.line')
- st_line = st_obj.browse(cursor,uid,line_id)
- if st_line:
- sql = "SELECT id FROM res_partner WHERE name ~* %s"
- pattern = ".*%s.*" % st_line.label
- cursor.execute(sql, (pattern,))
- result = cursor.fetchall()
- if len(result) > 1:
- raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than one partner.')%(st_line.name,st_line.ref))
- for id in result[0]:
- res['partner_id'] = id
- if res:
- st_vals = st_obj.get_values_for_line(cursor, uid, profile_id = st_line.statement_id.profile_id.id,
- partner_id = res.get('partner_id',False), line_type = st_line.type, amount = st_line.amount, context = context)
- res.update(st_vals)
+ sql = "SELECT id FROM res_partner WHERE name ~* %s and id in %s"
+ pattern = ".*%s.*" % re.escape(st_line['name'])
+ cr.execute(sql, (pattern, context['partner_memoizer']))
+ result = cr.fetchall()
+ if not result:
+ return res
+ if len(result) > 1:
+ raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more '
+ 'than one partner while looking on partner by name') %
+ (st_line['name'], st_line['ref']))
+ res['partner_id'] = result[0][0]
+ st_vals = st_obj.get_values_for_line(cr,
+ uid,
+ profile_id=st_line['porfile_id'],
+ master_account_id=st_line['master_account_id'],
+ partner_id=res['partner_id'],
+ line_type=False,
+ amount=st_line['amount'] if st_line['amount'] else 0.0,
+ context=context)
+ res.update(st_vals)
return res
-
-
-class AccountStatementLine(Model):
+
+
+class AccountStatementLine(orm.Model):
"""
Add sparse field on the statement line to allow to store all the
bank infos that are given by a bank/office. You can then add you own in your
@@ -270,23 +383,29 @@
"""
_inherit = "account.bank.statement.line"
- _columns={
- 'additionnal_bank_fields' : fields.serialized('Additionnal infos from bank',
- help="Used by completion and import system. Adds every field that is present in your bank/office \
- statement file"),
- 'label': fields.sparse(type='char', string='Label',
- serialization_field='additionnal_bank_fields',
- help="Generiy field to store a label given from the bank/office on which we can \
- base the default/standard providen rule."),
- 'already_completed': fields.boolean("Auto-Completed",
- help="When this checkbox is ticked, the auto-completion process/button will ignore this line."),
+ _columns = {
+ 'additionnal_bank_fields': fields.serialized(
+ 'Additionnal infos from bank',
+ help="Used by completion and import system. Adds every field that "
+ "is present in your bank/office statement file"),
+ 'label': fields.sparse(
+ type='char',
+ string='Label',
+ serialization_field='additionnal_bank_fields',
+ help="Generic field to store a label given from the "
+ "bank/office on which we can base the default/standard "
+ "providen rule."),
+ 'already_completed': fields.boolean(
+ "Auto-Completed",
+ help="When this checkbox is ticked, the auto-completion "
+ "process/button will ignore this line."),
}
+
_defaults = {
'already_completed': False,
}
-
-
- def get_line_values_from_rules(self, cr, uid, ids, context=None):
+
+ def _get_line_values_from_rules(self, cr, uid, line, rules, context=None):
"""
We'll try to find out the values related to the line based on rules setted on
the profile.. We will ignore line for which already_completed is ticked.
@@ -294,31 +413,20 @@
:return:
A dict of dict value that can be passed directly to the write method of
the statement line or {}. The first dict has statement line ID as a key:
- {117009: {'partner_id': 100997, 'account_id': 489L}}
+ {117009: {'partner_id': 100997, 'account_id': 489L}}
"""
profile_obj = self.pool.get('account.statement.profile')
- st_obj = self.pool.get('account.bank.statement.line')
- res={}
- errors_stack = []
- for line in self.browse(cr,uid, ids, context):
- if not line.already_completed:
- try:
- # Take the default values
- res[line.id] = st_obj.get_values_for_line(cr, uid, profile_id = line.statement_id.profile_id.id,
- line_type = line.type, amount = line.amount, context = context)
- # Ask the rule
- vals = profile_obj.find_values_from_rules(cr, uid, line.statement_id.profile_id.id, line.id, context)
- # Merge the result
- res[line.id].update(vals)
- except ErrorTooManyPartner, exc:
- msg = "Line ID %s had following error: %s" % (line.id, exc.value)
- errors_stack.append(msg)
- if errors_stack:
- msg = u"\n".join(errors_stack)
- raise ErrorTooManyPartner(msg)
- return res
-
-class AccountBankSatement(Model):
+ if line.get('already_completed'):
+ return {}
+ # Ask the rule
+ vals = profile_obj._find_values_from_rules(cr, uid, rules, line, context)
+ if vals:
+ vals['id'] = line['id']
+ return vals
+ return {}
+
+
+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.
@@ -328,61 +436,92 @@
_columns = {
'completion_logs': fields.text('Completion Log', readonly=True),
}
-
+
def write_completion_log(self, cr, uid, stat_id, error_msg, number_imported, context=None):
"""
Write the log in the completion_logs field of the bank statement to let the user
know what have been done. This is an append mode, so we don't overwrite what
already recoded.
-
+
:param int/long stat_id: ID of the account.bank.statement
:param char error_msg: Message to add
:number_imported int/long: Number of lines that have been completed
- :return : True
-
+ :return True
"""
- error_log = ""
- user_name = self.pool.get('res.users').read(cr, uid, uid, ['name'])['name']
- log = self.read(cr, uid, stat_id, ['completion_logs'], context=context)['completion_logs']
- log_line = log and log.split("\n") or []
- completion_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- if error_msg:
- error_log = error_msg
- log_line[0:0] = [completion_date + ' : '
- + _("Bank Statement ID %s has %s lines completed by %s") %(stat_id, number_imported, user_name)
- + "\n" + error_log + "-------------" + "\n"]
- log = "\n".join(log_line)
- self.write(cr, uid, [stat_id], {'completion_logs' : log}, context=context)
- logger.notifyChannel('Bank Statement Completion', netsvc.LOG_INFO,
- "Bank Statement ID %s has %s lines completed"%(stat_id, number_imported))
+ user_name = self.pool.get('res.users').read(cr, uid, uid,
+ ['name'], context=context)['name']
+
+ log = self.read(cr, uid, stat_id, ['completion_logs'],
+ context=context)['completion_logs']
+ log = log if log else ""
+
+ completion_date = datetime.datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT)
+ message = (_("%s Bank Statement ID %s has %s lines completed by %s \n%s\n%s\n") %
+ (completion_date, stat_id, number_imported, user_name, error_msg, log))
+ self.write(cr, uid, [stat_id], {'completion_logs': message}, context=context)
+
+ body = (_('Statement ID %s auto-completed for %s lines completed') %
+ (stat_id, number_imported)),
+ self.message_post(cr, uid,
+ [stat_id],
+ body=body,
+ context=context)
return True
-
+
def button_auto_completion(self, cr, uid, ids, context=None):
"""
Complete line with values given by rules and tic the already_completed
- checkbox so we won't compute them again unless the user untick them !
+ checkbox so we won't compute them again unless the user untick them!
"""
- if not context:
- context={}
- stat_line_obj = self.pool.get('account.bank.statement.line')
- msg = ""
+ if context is None:
+ context = {}
+ stat_line_obj = self.pool['account.bank.statement.line']
+ profile_obj = self.pool.get('account.statement.profile')
compl_lines = 0
+ stat_line_obj.check_access_rule(cr, uid, [], 'create')
+ stat_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
for stat in self.browse(cr, uid, ids, context=context):
+ msg_lines = []
ctx = context.copy()
- for line in stat.line_ids:
- res = {}
+ ctx['line_ids'] = tuple((x.id for x in stat.line_ids))
+ b_profile = stat.profile_id
+ rules = profile_obj._get_callable(cr, uid, b_profile, context=context)
+ profile_id = b_profile.id # Only for perfo even it gains almost nothing
+ master_account_id = b_profile.receivable_account_id
+ master_account_id = master_account_id.id if master_account_id else False
+ res = False
+ for line in stat_line_obj.read(cr, uid, ctx['line_ids']):
try:
- res = stat_line_obj.get_line_values_from_rules(cr, uid, [line.id], context=ctx)
+ # performance trick
+ line['master_account_id'] = master_account_id
+ line['profile_id'] = profile_id
+ res = stat_line_obj._get_line_values_from_rules(cr, uid, line,
+ rules, context=ctx)
if res:
compl_lines += 1
except ErrorTooManyPartner, exc:
- msg += exc.value + "\n"
+ msg_lines.append(repr(exc))
except Exception, exc:
- msg += exc.value + "\n"
- # vals = res and res.keys() or False
+ msg_lines.append(repr(exc))
+ error_type, error_value, trbk = sys.exc_info()
+ st = "Error: %s\nDescription: %s\nTraceback:" % (error_type.__name__, error_value)
+ st += ''.join(traceback.format_tb(trbk, 30))
+ _logger.error(st)
if res:
- vals = res[line.id]
- vals['already_completed'] = True
- stat_line_obj.write(cr, uid, line.id, vals, context=ctx)
- self.write_completion_log(cr, uid, stat.id, msg, compl_lines, context=context)
+ #stat_line_obj.write(cr, uid, [line.id], vals, context=ctx)
+ try:
+ stat_line_obj._update_line(cr, uid, res, context=context)
+ except Exception as exc:
+ msg_lines.append(repr(exc))
+ error_type, error_value, trbk = sys.exc_info()
+ st = "Error: %s\nDescription: %s\nTraceback:" % (error_type.__name__, error_value)
+ st += ''.join(traceback.format_tb(trbk, 30))
+ _logger.error(st)
+ # we can commit as it is not needed to be atomic
+ # commiting here adds a nice perfo boost
+ if not compl_lines % 500:
+ cr.commit()
+ msg = u'\n'.join(msg_lines)
+ self.write_completion_log(cr, uid, stat.id,
+ msg, compl_lines, context=context)
return True
=== modified file 'account_statement_base_completion/statement_view.xml'
--- account_statement_base_completion/statement_view.xml 2012-08-02 12:46:12 +0000
+++ account_statement_base_completion/statement_view.xml 2013-06-10 07:05:32 +0000
@@ -10,21 +10,21 @@
<field name="type">form</field>
<field name="arch" type="xml">
<data>
- <xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='sequence']" position="after">
+ <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='sequence']" position="after">
<separator colspan="4" string="Importation related infos"/>
<field name="label" />
<field name="already_completed" />
</xpath>
- <xpath expr="/form/group[2]" position="attributes">
- <attribute name="col">10</attribute>
- </xpath>
+ <!-- <xpath expr="/form/group[2]" position="attributes">
+ <attribute name="col">10</attribute>
+ </xpath> -->
- <xpath expr="/form/group/field[@name='balance_end']" position="after">
+ <xpath expr="/form/sheet/div[@name='import_buttons']" position="after">
<button name="button_auto_completion" string="Auto Completion" states='draft,open' type="object" colspan="1"/>
</xpath>
- <xpath expr="/form/notebook/page[@string='Journal Entries']" position="after">
+ <xpath expr="/form/sheet/notebook/page[@string='Transactions']" position="after">
<page string="Completion Logs" attrs="{'invisible':[('completion_logs','=',False)]}">
<field name="completion_logs" colspan="4" nolabel="1" attrs="{'invisible':[('completion_logs','=',False)]}"/>
</page>
@@ -40,7 +40,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<data>
- <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after">
+ <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after">
<field name="already_completed" />
</xpath>
</data>
=== modified file 'account_statement_base_import/__init__.py'
--- account_statement_base_import/__init__.py 2012-06-20 14:10:01 +0000
+++ account_statement_base_import/__init__.py 2013-06-10 07:05:32 +0000
@@ -20,4 +20,4 @@
##############################################################################
import parser
import wizard
-import statement
\ No newline at end of file
+import statement
=== modified file 'account_statement_base_import/__openerp__.py'
--- account_statement_base_import/__openerp__.py 2012-08-02 12:46:12 +0000
+++ account_statement_base_import/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,8 +24,11 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
- 'complexity': 'normal', #easy, normal, expert
- 'depends': ['account_statement_ext','account_statement_base_completion'],
+ 'complexity': 'normal',
+ 'depends': [
+ 'account_statement_ext',
+ 'account_statement_base_completion'
+ ],
'description': """
This module brings basic methods and fields on bank statement to deal with
the importation of different bank and offices. A generic abstract method is defined and an
@@ -35,6 +38,8 @@
a standard .csv or .xls file (you'll find it in the 'data' folder). It respects the profile
(provided by the accouhnt_statement_ext module) to pass the entries. That means,
you'll have to choose a file format for each profile.
+ In order to achieve this it uses the `xlrd` Python module which you will need to install
+ separately in your environment.
This module can handle a commission taken by the payment office and has the following format:
@@ -53,16 +58,13 @@
""",
'website': 'http://www.camptocamp.com',
- 'init_xml': [],
- 'update_xml': [
+ 'data': [
"wizard/import_statement_view.xml",
"statement_view.xml",
],
- 'demo_xml': [],
'test': [],
'installable': True,
'images': [],
'auto_install': False,
'license': 'AGPL-3',
- 'active': False,
}
=== modified file 'account_statement_base_import/parser/__init__.py'
--- account_statement_base_import/parser/__init__.py 2012-06-20 14:10:01 +0000
+++ account_statement_base_import/parser/__init__.py 2013-06-10 07:05:32 +0000
@@ -22,4 +22,4 @@
from parser import new_bank_statement_parser
from parser import BankStatementImportParser
import file_parser
-import generic_file_parser
\ No newline at end of file
+import generic_file_parser
=== modified file 'account_statement_base_import/parser/file_parser.py'
--- account_statement_base_import/parser/file_parser.py 2012-11-26 10:23:58 +0000
+++ account_statement_base_import/parser/file_parser.py 2013-06-10 07:05:32 +0000
@@ -17,8 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
from openerp.tools.translate import _
+from openerp.osv.osv import except_osv
import tempfile
import datetime
from parser import BankStatementImportParser
@@ -28,17 +28,19 @@
except:
raise Exception(_('Please install python lib xlrd'))
+
class FileParser(BankStatementImportParser):
"""
Generic abstract class for defining parser for .csv or .xls file format.
"""
-
- def __init__(self, parse_name, keys_to_validate=[], ftype='csv', convertion_dict=None, header=None, *args, **kwargs):
+
+ def __init__(self, parse_name, keys_to_validate=None, ftype='csv', conversion_dict=None,
+ header=None, *args, **kwargs):
"""
:param char: parse_name : The name of the parser
:param list: keys_to_validate : contain the key that need to be present in the file
:param char ftype: extension of the file (could be csv or xls)
- :param: convertion_dict : keys and type to convert of every column in the file like
+ :param: conversion_dict : keys and type to convert of every column in the file like
{
'ref': unicode,
'label': unicode,
@@ -48,18 +50,19 @@
}
:param list: header : specify header fields if the csv file has no header
"""
-
+
super(FileParser, self).__init__(parse_name, *args, **kwargs)
if ftype in ('csv', 'xls'):
self.ftype = ftype
else:
- raise Exception(_('Invalide file type %s. please use csv or xls') % (ftype))
- self.keys_to_validate = keys_to_validate
- self.convertion_dict = convertion_dict
+ raise except_osv(_('User Error'),
+ _('Invalid file type %s. Please use csv or xls') % ftype)
+ self.keys_to_validate = keys_to_validate if keys_to_validate is not None else []
+ self.conversion_dict = conversion_dict
self.fieldnames = header
- self._datemode = 0 # used only for xls documents,
- # 0 means Windows mode (1900 based dates).
- # Set in _parse_xls, from the contents of the file
+ self._datemode = 0 # used only for xls documents,
+ # 0 means Windows mode (1900 based dates).
+ # Set in _parse_xls, from the contents of the file
def _custom_format(self, *args, **kwargs):
"""
@@ -78,7 +81,7 @@
Launch the parsing through .csv or .xls depending on the
given ftype
"""
-
+
res = None
if self.ftype == 'csv':
res = self._parse_csv()
@@ -98,7 +101,8 @@
parsed_cols = self.result_row_list[0].keys()
for col in self.keys_to_validate:
if col not in parsed_cols:
- raise Exception(_('Column %s not present in file') % (col))
+ raise except_osv(_('Invalid data'),
+ _('Column %s not present in file') % col)
return True
def _post(self, *args, **kwargs):
@@ -108,7 +112,6 @@
self.result_row_list = self._cast_rows(*args, **kwargs)
return True
-
def _parse_csv(self):
"""
:return: list of dict from csv file (line/rows)
@@ -116,7 +119,7 @@
csv_file = tempfile.NamedTemporaryFile()
csv_file.write(self.filebuffer)
csv_file.flush()
- with open(csv_file.name, 'rU') as fobj:
+ with open(csv_file.name, 'rU') as fobj:
reader = UnicodeDictReader(fobj, fieldnames=self.fieldnames)
return list(reader)
@@ -128,17 +131,13 @@
wb_file.write(self.filebuffer)
# We ensure that cursor is at beginig of file
wb_file.seek(0)
- wb = xlrd.open_workbook(wb_file.name)
- self._datemode = wb.datemode
- sheet = wb.sheet_by_index(0)
- header = sheet.row_values(0)
- res = []
- for rownum in range(1, sheet.nrows):
- res.append(dict(zip(header, sheet.row_values(rownum))))
- try:
- wb_file.close()
- except Exception, e:
- pass #file is allready closed
+ with xlrd.open_workbook(wb_file.name) as wb:
+ self._datemode = wb.datemode
+ sheet = wb.sheet_by_index(0)
+ header = sheet.row_values(0)
+ res = []
+ for rownum in range(1, sheet.nrows):
+ res.append(dict(zip(header, sheet.row_values(rownum))))
return res
def _from_csv(self, result_set, conversion_rules):
@@ -149,11 +148,30 @@
for line in result_set:
for rule in conversion_rules:
if conversion_rules[rule] == datetime.datetime:
- date_string = line[rule].split(' ')[0]
- line[rule] = datetime.datetime.strptime(date_string,
- '%Y-%m-%d')
+ try:
+ date_string = line[rule].split(' ')[0]
+ line[rule] = datetime.datetime.strptime(date_string,
+ '%Y-%m-%d')
+ except ValueError as err:
+ raise except_osv(_("Date format is not valid."),
+ _(" It should be YYYY-MM-DD for column: %s"
+ " value: %s \n \n"
+ " \n Please check the line with ref: %s"
+ " \n \n Detail: %s") % (rule,
+ line.get(rule, _('Missing')),
+ line.get('ref', line),
+ repr(err)))
else:
- line[rule] = conversion_rules[rule](line[rule])
+ try:
+ line[rule] = conversion_rules[rule](line[rule])
+ except Exception as err:
+ raise except_osv(_('Invalid data'),
+ _("Value %s of column %s is not valid."
+ "\n Please check the line with ref %s:"
+ "\n \n Detail: %s") % (line.get(rule, _('Missing')),
+ rule,
+ line.get('ref', line),
+ repr(err)))
return result_set
def _from_xls(self, result_set, conversion_rules):
@@ -164,17 +182,37 @@
for line in result_set:
for rule in conversion_rules:
if conversion_rules[rule] == datetime.datetime:
- t_tuple = xlrd.xldate_as_tuple(line[rule], self._datemode)
- line[rule] = datetime.datetime(*t_tuple)
+ try:
+ t_tuple = xlrd.xldate_as_tuple(line[rule], self._datemode)
+ line[rule] = datetime.datetime(*t_tuple)
+ except Exception as err:
+ raise except_osv(_("Date format is not valid"),
+ _("Please modify the cell formatting to date format"
+ " for column: %s"
+ " value: %s"
+ "\n Please check the line with ref: %s"
+ "\n \n Detail: %s") % (rule,
+ line.get(rule, _('Missing')),
+ line.get('ref', line),
+ repr(err)))
else:
- line[rule] = conversion_rules[rule](line[rule])
+ try:
+ line[rule] = conversion_rules[rule](line[rule])
+ except Exception as err:
+ raise except_osv(_('Invalid data'),
+ _("Value %s of column %s is not valid."
+ "\n Please check the line with ref %s:"
+ "\n \n Detail: %s") % (line.get(rule, _('Missing')),
+ rule,
+ line.get('ref', line),
+ repr(err)))
return result_set
def _cast_rows(self, *args, **kwargs):
"""
- Convert the self.result_row_list using the self.convertion_dict providen.
+ Convert the self.result_row_list using the self.conversion_dict providen.
We call here _from_xls or _from_csv depending on the self.ftype variable.
"""
- func = getattr(self, '_from_%s'%(self.ftype))
- res = func(self.result_row_list, self.convertion_dict)
+ func = getattr(self, '_from_%s' % self.ftype)
+ res = func(self.result_row_list, self.conversion_dict)
return res
=== modified file 'account_statement_base_import/parser/generic_file_parser.py'
--- account_statement_base_import/parser/generic_file_parser.py 2012-06-20 14:10:01 +0000
+++ account_statement_base_import/parser/generic_file_parser.py 2013-06-10 07:05:32 +0000
@@ -23,31 +23,37 @@
import csv
import tempfile
import datetime
-# from . import file_parser
from file_parser import FileParser
try:
import xlrd
except:
raise Exception(_('Please install python lib xlrd'))
+
+def float_or_zero(val):
+ """ Conversion function used to manage
+ empty string into float usecase"""
+ return float(val) if val else 0.0
+
+
class GenericFileParser(FileParser):
"""
Standard parser that use a define format in csv or xls to import into a
- bank statement. This is mostely an example of how to proceed to create a new
+ bank statement. This is mostely an example of how to proceed to create a new
parser, but will also be useful as it allow to import a basic flat file.
"""
-
+
def __init__(self, parse_name, ftype='csv'):
- convertion_dict = {
+ conversion_dict = {
'ref': unicode,
'label': unicode,
'date': datetime.datetime,
- 'amount': float,
- 'commission_amount': float
+ 'amount': float_or_zero,
+ 'commission_amount': float_or_zero
}
# Order of cols does not matter but first row of the file has to be header
keys_to_validate = ['ref', 'label', 'date', 'amount', 'commission_amount']
- super(GenericFileParser,self).__init__(parse_name, keys_to_validate=keys_to_validate, ftype=ftype, convertion_dict=convertion_dict)
+ super(GenericFileParser, self).__init__(parse_name, keys_to_validate=keys_to_validate, ftype=ftype, conversion_dict=conversion_dict)
@classmethod
def parser_for(cls, parser_name):
@@ -60,7 +66,7 @@
def get_st_line_vals(self, line, *args, **kwargs):
"""
This method must return a dict of vals that can be passed to create
- method of statement line in order to record it. It is the responsibility
+ method of statement line in order to record it. It is the responsibility
of every parser to give this dict of vals, so each one can implement his
own way of recording the lines.
:param: line: a dict of vals that represent a line of result_row_list
@@ -77,14 +83,12 @@
In this generic parser, the commission is given for every line, so we store it
for each one.
"""
- return {
- 'name': line.get('label', line.get('ref','/')),
- 'date': line.get('date', datetime.datetime.now().date()),
- 'amount': line.get('amount', 0.0),
- 'ref': line.get('ref','/'),
- 'label': line.get('label',''),
- 'commission_amount': line.get('commission_amount', 0.0),
- }
+ return {'name': line.get('label', line.get('ref', '/')),
+ 'date': line.get('date', datetime.datetime.now().date()),
+ 'amount': line.get('amount', 0.0),
+ 'ref': line.get('ref', '/'),
+ 'label': line.get('label', ''),
+ 'commission_amount': line.get('commission_amount', 0.0)}
def _post(self, *args, **kwargs):
"""
@@ -93,10 +97,6 @@
res = super(GenericFileParser, self)._post(*args, **kwargs)
val = 0.0
for row in self.result_row_list:
- val += row.get('commission_amount',0.0)
+ val += row.get('commission_amount', 0.0)
self.commission_global_amount = val
return res
-
-
-
-
=== modified file 'account_statement_base_import/parser/parser.py'
--- account_statement_base_import/parser/parser.py 2012-11-23 16:27:24 +0000
+++ account_statement_base_import/parser/parser.py 2013-06-10 07:05:32 +0000
@@ -21,6 +21,7 @@
import base64
import csv
+
def UnicodeDictReader(utf8_data, **kwargs):
sniffer = csv.Sniffer()
pos = utf8_data.tell()
@@ -31,6 +32,7 @@
for row in csv_reader:
yield dict([(key, unicode(value, 'utf-8')) for key, value in row.iteritems()])
+
class BankStatementImportParser(object):
"""
Generic abstract class for defining parser for different files and
@@ -38,7 +40,7 @@
own. If your file is a .csv or .xls format, you should consider inheirt
from the FileParser instead.
"""
-
+
def __init__(self, parser_name, *args, **kwargs):
# The name of the parser as it will be called
self.parser_name = parser_name
@@ -50,7 +52,7 @@
# Concatenate here the global commission taken by the bank/office
# for this statement.
self.commission_global_amount = None
-
+
@classmethod
def parser_for(cls, parser_name):
"""
@@ -58,17 +60,17 @@
return the good class from his name.
"""
return False
-
+
def _decode_64b_stream(self):
"""
Decode self.filebuffer in base 64 and override it
"""
self.filebuffer = base64.b64decode(self.filebuffer)
return True
-
+
def _format(self, decode_base_64=True, **kwargs):
"""
- Decode into base 64 if asked and Format the given filebuffer by calling
+ Decode into base 64 if asked and Format the given filebuffer by calling
_custom_format method.
"""
if decode_base_64:
@@ -83,43 +85,40 @@
"""
return NotImplementedError
-
def _pre(self, *args, **kwargs):
"""
- Implement a method in your parser to make a pre-treatment on datas before parsing
+ Implement a method in your parser to make a pre-treatment on datas before parsing
them, like concatenate stuff, and so... Work on self.filebuffer
"""
return NotImplementedError
def _parse(self, *args, **kwargs):
"""
- Implement a method in your parser to save the result of parsing self.filebuffer
+ Implement a method in your parser to save the result of parsing self.filebuffer
in self.result_row_list instance property.
"""
return NotImplementedError
-
+
def _validate(self, *args, **kwargs):
"""
Implement a method in your parser to validate the self.result_row_list instance
property and raise an error if not valid.
"""
return NotImplementedError
-
+
def _post(self, *args, **kwargs):
"""
Implement a method in your parser to make some last changes on the result of parsing
- the datas, like converting dates, computing commission, ...
+ the datas, like converting dates, computing commission, ...
Work on self.result_row_list and put the commission global amount if any
in the self.commission_global_amount one.
"""
return NotImplementedError
-
-
def get_st_line_vals(self, line, *args, **kwargs):
"""
- Implement a method in your parser that must return a dict of vals that can be
- passed to create method of statement line in order to record it. It is the responsibility
+ Implement a method in your parser that must return a dict of vals that can be
+ passed to create method of statement line in order to record it. It is the responsibility
of every parser to give this dict of vals, so each one can implement his
own way of recording the lines.
:param: line: a dict of vals that represent a line of result_row_list
@@ -133,17 +132,17 @@
}
"""
return NotImplementedError
-
+
def get_st_line_commision(self, *args, **kwargs):
"""
This is called by the importation method to create the commission line in
the bank statement. We will always create one line for the commission in the
- bank statement, but it could be computated from a value of each line, or given
+ bank statement, but it could be computated from a value of each line, or given
in a single line for the whole file.
return: float of the whole commission (self.commission_global_amount)
"""
return self.commission_global_amount
-
+
def parse(self, filebuffer, *args, **kwargs):
"""
This will be the method that will be called by wizard, button and so
@@ -151,7 +150,7 @@
that need to be define for each parser.
Return:
[] of rows as {'key':value}
-
+
Note: The row_list must contain only value that are present in the account.
bank.statement.line object !!!
"""
@@ -165,7 +164,8 @@
self._validate(*args, **kwargs)
self._post(*args, **kwargs)
return self.result_row_list
-
+
+
def itersubclasses(cls, _seen=None):
"""
itersubclasses(cls)
@@ -179,7 +179,7 @@
>>> class C(A): pass
>>> class D(B,C): pass
>>> class E(D): pass
- >>>
+ >>>
>>> for cls in itersubclasses(A):
... print(cls.__name__)
B
@@ -193,10 +193,11 @@
if not isinstance(cls, type):
raise TypeError('itersubclasses must be called with '
'new-style classes, not %.100r' % cls)
- if _seen is None: _seen = set()
+ if _seen is None:
+ _seen = set()
try:
subs = cls.__subclasses__()
- except TypeError: # fails only when cls is type
+ except TypeError: # fails only when cls is type
subs = cls.__subclasses__(cls)
for sub in subs:
if sub not in _seen:
@@ -204,7 +205,8 @@
yield sub
for sub in itersubclasses(sub, _seen):
yield sub
-
+
+
def new_bank_statement_parser(parser_name, *args, **kwargs):
"""
Return an instance of the good parser class base on the providen name
@@ -215,4 +217,3 @@
if cls.parser_for(parser_name):
return cls(parser_name, *args, **kwargs)
raise ValueError
-
=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py 2012-09-25 08:05:34 +0000
+++ account_statement_base_import/statement.py 2013-06-10 07:05:32 +0000
@@ -18,65 +18,62 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
-from tools.translate import _
+import sys
+import traceback
+
+import psycopg2
+
+from openerp.tools.translate import _
import datetime
-import netsvc
-logger = netsvc.Logger()
-from openerp.osv.orm import Model, fields
+from openerp.osv.orm import Model
from openerp.osv import fields, osv
-# from account_statement_base_import.parser.file_parser import FileParser
from parser import new_bank_statement_parser
-import sys
-import traceback
+
class AccountStatementProfil(Model):
_inherit = "account.statement.profile"
-
-
+
def get_import_type_selection(self, cr, uid, context=None):
"""
Has to be inherited to add parser
"""
return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')]
-
-
+
_columns = {
- 'launch_import_completion': fields.boolean("Launch completion after import",
- help="Tic that box to automatically launch the completion on each imported\
- file using this profile."),
+ 'launch_import_completion': fields.boolean(
+ "Launch completion after import",
+ help="Tic that box to automatically launch the completion "
+ "on each imported file using this profile."),
'last_import_date': fields.datetime("Last Import Date"),
- 'rec_log': fields.text('log', readonly=True),
- 'import_type': fields.selection(get_import_type_selection, 'Type of import', required=True,
- help = "Choose here the method by which you want to import bank statement for this profile."),
-
+ # we remove deprecated as it floods logs in standard/warning level sob...
+ 'rec_log': fields.text('log', readonly=True), # Deprecated
+ 'import_type': fields.selection(
+ get_import_type_selection,
+ 'Type of import',
+ required=True,
+ help="Choose here the method by which you want to import bank"
+ "statement for this profile."),
+
}
-
+
def write_logs_after_import(self, cr, uid, ids, statement_id, num_lines, context):
"""
- Write the log in the logger + in the log field of the profile to report the user about
- what has been done.
-
+ Write the log in the logger
+
:param int/long statement_id: ID of the concerned account.bank.statement
:param int/long num_lines: Number of line that have been parsed
:return: True
"""
- if type(ids) is int:
- ids = [ids]
- for id in ids:
- log = self.read(cr, uid, id, ['rec_log'], context=context)['rec_log']
- log_line = log and log.split("\n") or []
- import_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- log_line[0:0] = [import_date + ' : '
- + _("Bank Statement ID %s have been imported with %s lines ") %(statement_id, num_lines)]
- log = "\n".join(log_line)
- self.write(cr, uid, id, {'rec_log' : log, 'last_import_date':import_date}, context=context)
- logger.notifyChannel('Bank Statement Import', netsvc.LOG_INFO,
- "Bank Statement ID %s have been imported with %s lines "%(statement_id, num_lines))
+ self.message_post(cr,
+ uid,
+ ids,
+ body=_('Statement ID %s have been imported with %s lines.') %
+ (statement_id, num_lines),
+ context=context)
return True
-
- def prepare_global_commission_line_vals(self, cr, uid, parser,
- result_row_list, profile, statement_id, context):
+
+ def prepare_global_commission_line_vals(
+ self, cr, uid, parser, result_row_list, profile, statement_id, context):
"""
Prepare the global commission line if there is one. The global
commission is computed by by calling the get_st_line_commision
@@ -86,7 +83,7 @@
:param: browse_record of the current parser
:param: result_row_list: [{'key':value}]
:param: profile: browserecord of account.statement.profile
- :param: statement_id : int/long of the current importing statement ID
+ :param: statement_id: int/long of the current importing statement ID
:param: context: global context
return: dict of vals that will be passed to create method of statement line.
"""
@@ -95,9 +92,8 @@
partner_id = profile.partner_id and profile.partner_id.id or False
commission_account_id = profile.commission_account_id and profile.commission_account_id.id or False
commission_analytic_id = profile.commission_analytic_id and profile.commission_analytic_id.id or False
- statement_line_obj = self.pool.get('account.bank.statement.line')
comm_values = {
- 'name': 'IN '+ _('Commission line'),
+ 'name': 'IN ' + _('Commission line'),
'date': datetime.datetime.now().date(),
'amount': parser.get_st_line_commision(),
'partner_id': partner_id,
@@ -106,118 +102,150 @@
'account_id': commission_account_id,
'ref': 'commission',
'analytic_account_id': commission_analytic_id,
- # !! We set the already_completed so auto-completion will not update those values !
+ # !! We set the already_completed so auto-completion will not update those values!
'already_completed': True,
}
return comm_values
-
- def prepare_statetement_lines_vals(self, cursor, uid, parser_vals,
- account_payable, account_receivable, statement_id, context):
+
+ def prepare_statetement_lines_vals(
+ self, cr, uid, parser_vals, account_payable, account_receivable,
+ statement_id, context):
"""
Hook to build the values of a line from the parser returned values. At
least it fullfill the statement_id and account_id. Overide it to add your
- own completion if needed.
-
- :param dict of vals from parser for account.bank.statement.line (called by
+ own completion if needed.
+
+ :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.
+ :return: dict of vals that will be passed to create method of statement line.
"""
statement_obj = self.pool.get('account.bank.statement')
values = parser_vals
- values['statement_id']= statement_id
- values['account_id'] = statement_obj.get_account_for_counterpart(
- cursor,
- uid,
- parser_vals['amount'],
- account_receivable,
- account_payable
- )
+ values['statement_id'] = statement_id
+ values['account_id'] = statement_obj.get_account_for_counterpart(cr,
+ uid,
+ parser_vals['amount'],
+ account_receivable,
+ account_payable)
+
+ date = values.get('date')
+ period_memoizer = context.get('period_memoizer')
+ if not period_memoizer:
+ period_memoizer = {}
+ context['period_memoizer'] = period_memoizer
+ if period_memoizer.get(date):
+ values['period_id'] = period_memoizer[date]
+ else:
+ # This is awfully slow...
+ periods = self.pool.get('account.period').find(cr, uid,
+ dt=values.get('date'),
+ context=context)
+ values['period_id'] = periods[0]
+ period_memoizer[date] = periods[0]
+ values['type'] = 'general'
return values
-
- def statement_import(self, cursor, uid, ids, profile_id, file_stream, ftype="csv", context=None):
+
+ def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
"""
Create a bank statement with the given profile and parser. It will fullfill the bank statement
with the values of the file providen, but will not complete data (like finding the partner, or
the right account). This will be done in a second step with the completion rules.
It will also create the commission line if it apply and record the providen file as
an attachement of the bank statement.
-
+
:param int/long profile_id: ID of the profile used to import the file
:param filebuffer file_stream: binary of the providen file
:param char: ftype represent the file exstension (csv by default)
:return: ID of the created account.bank.statemênt
"""
- context = context or {}
statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
attachment_obj = self.pool.get('ir.attachment')
prof_obj = self.pool.get("account.statement.profile")
if not profile_id:
- raise osv.except_osv(
- _("No Profile !"),
- _("You must provide a valid profile to import a bank statement !"))
- prof = prof_obj.browse(cursor,uid,profile_id,context)
-
+ raise osv.except_osv(_("No Profile!"),
+ _("You must provide a valid profile to import a bank statement!"))
+ prof = prof_obj.browse(cr, uid, profile_id, context=context)
+
parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
result_row_list = parser.parse(file_stream)
- # Check all key are present in account.bank.statement.line !!
+ # Check all key are present in account.bank.statement.line!!
+ if not result_row_list:
+ raise osv.except_osv(_("Nothing to import"),
+ _("The file is empty"))
parsed_cols = parser.get_st_line_vals(result_row_list[0]).keys()
for col in parsed_cols:
if col not in statement_line_obj._columns:
- raise osv.except_osv(
- _("Missing column !"),
- _("Column %s you try to import is not present in the bank statement line !") %(col))
-
- statement_id = statement_obj.create(cursor,uid,{'profile_id':prof.id,},context)
- account_receivable, account_payable = statement_obj.get_default_pay_receiv_accounts(cursor, uid, context)
+ raise osv.except_osv(_("Missing column!"),
+ _("Column %s you try to import is not "
+ "present in the bank statement line!") % col)
+
+ statement_id = statement_obj.create(cr, uid,
+ {'profile_id': prof.id},
+ context=context)
+ if prof.receivable_account_id:
+ account_receivable = account_payable = prof.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 and compute the global commission
# based on the commission_amount column
+ statement_store = []
for line in result_row_list:
parser_vals = parser.get_st_line_vals(line)
- values = self.prepare_statetement_lines_vals(cursor, uid, parser_vals, account_payable,
- account_receivable, statement_id, context)
- # we finally create the line in system
- statement_line_obj.create(cursor, uid, values, context=context)
+ values = self.prepare_statetement_lines_vals(cr, uid, parser_vals, account_payable,
+ account_receivable, statement_id, context)
+ statement_store.append(values)
+ # Hack to bypass ORM poor perfomance. Sob...
+ statement_line_obj._insert_lines(cr, uid, statement_store, context=context)
+
# Build and create the global commission line for the whole statement
- comm_vals = self.prepare_global_commission_line_vals(cursor, uid, parser, result_row_list, prof, statement_id, context)
+ comm_vals = self.prepare_global_commission_line_vals(cr, uid, parser, result_row_list,
+ prof, statement_id, context)
if comm_vals:
- res = statement_line_obj.create(cursor, uid, comm_vals,context=context)
-
- attachment_obj.create(
- cursor,
- uid,
- {
- 'name': 'statement file',
- 'datas': file_stream,
- 'datas_fname': "%s.%s"%(datetime.datetime.now().date(),
- ftype),
- 'res_model': 'account.bank.statement',
- 'res_id': statement_id,
- },
- context=context
- )
- # If user ask to launch completion at end of import, do it !
+ statement_line_obj.create(cr, uid, comm_vals, context=context)
+ else:
+ # Trigger store field computation if someone has better idea
+ start_bal = statement_obj.read(cr, uid, statement_id,
+ ['balance_start'],
+ context=context)
+ start_bal = start_bal['balance_start']
+ statement_obj.write(cr, uid, [statement_id],
+ {'balance_start': start_bal})
+
+ attachment_obj.create(cr,
+ uid,
+ {'name': 'statement file',
+ 'datas': file_stream,
+ 'datas_fname': "%s.%s" % (
+ datetime.datetime.now().date(),
+ ftype),
+ 'res_model': 'account.bank.statement',
+ 'res_id': statement_id},
+ context=context)
+
+ # If user ask to launch completion at end of import, do it!
if prof.launch_import_completion:
- statement_obj.button_auto_completion(cursor, uid, [statement_id], context)
-
+ statement_obj.button_auto_completion(cr, uid, [statement_id], context)
+
# Write the needed log infos on profile
- self.write_logs_after_import(cursor, uid, prof.id, statement_id,
- len(result_row_list), context)
-
- except Exception, exc:
- statement_obj.unlink(cursor, uid, [statement_id])
+ self.write_logs_after_import(cr, uid, prof.id,
+ statement_id,
+ len(result_row_list),
+ context)
+
+ except Exception:
+ statement_obj.unlink(cr, uid, [statement_id], context=context)
error_type, error_value, trbk = sys.exc_info()
st = "Error: %s\nDescription: %s\nTraceback:" % (error_type.__name__, error_value)
st += ''.join(traceback.format_tb(trbk, 30))
- raise osv.except_osv(
- _("Statement import error"),
- _("The statement cannot be created : %s") %(st))
+ raise osv.except_osv(_("Statement import error"),
+ _("The statement cannot be created: %s") % st)
return statement_id
-
class AccountStatementLine(Model):
@@ -228,8 +256,48 @@
"""
_inherit = "account.bank.statement.line"
- _columns={
- 'commission_amount': fields.sparse(type='float', string='Line Commission Amount',
+ def _get_available_columns(self, statement_store):
+ """Return writeable by SQL columns"""
+ statement_line_obj = self.pool['account.bank.statement.line']
+ model_cols = statement_line_obj._columns
+ avail = [k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')]
+ keys = [k for k in statement_store[0].keys() if k in avail]
+ keys.sort()
+ return keys
+
+ def _insert_lines(self, cr, uid, statement_store, context=None):
+ """ Do raw insert into database because ORM is awfully slow
+ when doing batch write. It is a shame that batch function
+ does not exist"""
+ statement_line_obj = self.pool['account.bank.statement.line']
+ 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)
+ 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:
+ cr.executemany(sql, tuple(statement_store))
+ except psycopg2.Error as sql_err:
+ cr.rollback()
+ raise osv.except_osv(_("ORM bypass error"),
+ sql_err.pgerror)
+
+ def _update_line(self, cr, uid, vals, context=None):
+ """ Do raw update into database because ORM is awfully slow
+ when cheking security."""
+ cols = self._get_available_columns([vals])
+ 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:
+ cr.execute(sql, vals)
+ except psycopg2.Error as sql_err:
+ cr.rollback()
+ raise osv.except_osv(_("ORM bypass error"),
+ sql_err.pgerror)
+
+ _columns = {
+ 'commission_amount': fields.sparse(
+ type='float',
+ string='Line Commission Amount',
serialization_field='additionnal_bank_fields'),
-
}
=== modified file 'account_statement_base_import/statement_view.xml'
--- account_statement_base_import/statement_view.xml 2012-08-02 12:46:12 +0000
+++ account_statement_base_import/statement_view.xml 2013-06-10 07:05:32 +0000
@@ -16,10 +16,12 @@
<field name="import_type"/>
<button name="%(account_statement_base_import.statement_importer_action)d"
string="Import Bank Statement"
- type="action" icon="gtk-ok"
+ type="action" icon="gtk-ok"
colspan = "2"/>
- <separator colspan="4" string="Import Logs"/>
- <field name="rec_log" colspan="4" nolabel="1"/>
+ <group attrs="{'invisible': [('rec_log', '=', False)]}">
+ <separator colspan="4" string="Historical Import Logs"/>
+ <field name="rec_log" colspan="4" nolabel="1" />
+ </group>
</field>
</field>
</record>
@@ -32,13 +34,13 @@
<field eval="20" name="priority"/>
<field name="arch" type="xml">
<data>
- <xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='label']" position="after">
+ <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='label']" position="after">
<field name="commission_amount" />
</xpath>
</data>
</field>
</record>
-
+
</data>
</openerp>
=== modified file 'account_statement_base_import/wizard/import_statement.py'
--- account_statement_base_import/wizard/import_statement.py 2012-11-27 10:51:47 +0000
+++ account_statement_base_import/wizard/import_statement.py 2013-06-10 07:05:32 +0000
@@ -23,15 +23,18 @@
Wizard to import financial institute date in bank statement
"""
-from osv import fields, osv
-from tools.translate import _
+from openerp.osv import orm, fields
+
+from openerp.tools.translate import _
import os
-class CreditPartnerStatementImporter(osv.osv_memory):
+
+class CreditPartnerStatementImporter(orm.TransientModel):
_name = "credit.statement.import"
-
+
def default_get(self, cr, uid, fields, context=None):
- if context is None: context = {}
+ if context is None:
+ context = {}
res = {}
if (context.get('active_model', False) == 'account.statement.profile' and
context.get('active_ids', False)):
@@ -39,80 +42,81 @@
assert len(ids) == 1, 'You cannot use this on more than one profile !'
res['profile_id'] = ids[0]
other_vals = self.onchange_profile_id(cr, uid, [], res['profile_id'], context=context)
- res.update(other_vals.get('value',{}))
+ res.update(other_vals.get('value', {}))
return res
-
+
_columns = {
'profile_id': fields.many2one('account.statement.profile',
'Import configuration parameter',
required=True),
'input_statement': fields.binary('Statement file', required=True),
'partner_id': fields.many2one('res.partner',
- 'Credit insitute partner',
- ),
+ 'Credit insitute partner'),
'journal_id': fields.many2one('account.journal',
- 'Financial journal to use transaction',
- ),
- 'input_statement': fields.binary('Statement file', required=True),
+ 'Financial journal to use transaction'),
'file_name': fields.char('File Name', size=128),
'commission_account_id': fields.many2one('account.account',
- 'Commission account',
- ),
+ 'Commission account'),
'commission_analytic_id': fields.many2one('account.analytic.account',
- 'Commission analytic account',
- ),
+ 'Commission analytic account'),
'receivable_account_id': fields.many2one('account.account',
'Force Receivable/Payable Account'),
- 'force_partner_on_bank': fields.boolean('Force partner on bank move',
- help="Tic that box if you want to use the credit insitute partner\
- in the counterpart of the treasury/banking move."
- ),
- 'balance_check': fields.boolean('Balance check',
- help="Tic 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."
- ),
- }
-
+ 'force_partner_on_bank': fields.boolean(
+ 'Force partner on bank move',
+ help="Tic that box if you want to use the credit insitute partner "
+ "in the counterpart of the treasury/banking move."),
+ 'balance_check': fields.boolean(
+ 'Balance check',
+ help="Tic 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."),
+ }
+
def onchange_profile_id(self, cr, uid, ids, profile_id, context=None):
- res={}
+ res = {}
if profile_id:
- c = self.pool.get("account.statement.profile").browse(cr,uid,profile_id)
- res = {'value': {'partner_id': c.partner_id and c.partner_id.id or False,
- 'journal_id': c.journal_id and c.journal_id.id or False, 'commission_account_id': \
- c.commission_account_id and c.commission_account_id.id or False,
- 'receivable_account_id': c.receivable_account_id and c.receivable_account_id.id or False,
- 'commission_a':c.commission_analytic_id and c.commission_analytic_id.id or False,
- 'force_partner_on_bank':c.force_partner_on_bank,
- 'balance_check':c.balance_check,}}
+ c = self.pool.get("account.statement.profile").browse(
+ cr, uid, profile_id, context=context)
+ res = {'value':
+ {'partner_id': c.partner_id and c.partner_id.id or False,
+ 'journal_id': c.journal_id and c.journal_id.id or False,
+ 'commission_account_id':
+ c.commission_account_id and c.commission_account_id.id or False,
+ 'receivable_account_id': c.receivable_account_id and c.receivable_account_id.id or False,
+ 'commission_a': c.commission_analytic_id and c.commission_analytic_id.id or False,
+ 'force_partner_on_bank': c.force_partner_on_bank,
+ 'balance_check': c.balance_check,
+ }
+ }
return res
def _check_extension(self, filename):
- (shortname, ftype) = os.path.splitext(filename)
+ (__, ftype) = os.path.splitext(filename)
if not ftype:
#We do not use osv exception we do not want to have it logged
raise Exception(_('Please use a file with an extention'))
return ftype
- def import_statement(self, cursor, uid, req_id, context=None):
+ def import_statement(self, cr, uid, req_id, context=None):
"""This Function import credit card agency statement"""
context = context or {}
if isinstance(req_id, list):
req_id = req_id[0]
- importer = self.browse(cursor, uid, req_id, context)
+ importer = self.browse(cr, uid, req_id, context)
ftype = self._check_extension(importer.file_name)
sid = self.pool.get(
'account.statement.profile').statement_import(
- cursor,
+ cr,
uid,
False,
importer.profile_id.id,
importer.input_statement,
- ftype.replace('.',''),
+ ftype.replace('.', ''),
context=context
)
model_obj = self.pool.get('ir.model.data')
action_obj = self.pool.get('ir.actions.act_window')
- action_id = model_obj.get_object_reference(cursor, uid, 'account', 'action_bank_statement_tree')[1]
- res = action_obj.read(cursor, uid, action_id)
+ action_id = model_obj.get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')[1]
+ res = action_obj.read(cr, uid, action_id)
res['domain'] = res['domain'][:-1] + ",('id', '=', %d)]" % sid
return res
=== modified file 'account_statement_completion_voucher/__init__.py'
--- account_statement_completion_voucher/__init__.py 2012-06-27 07:58:32 +0000
+++ account_statement_completion_voucher/__init__.py 2013-06-10 07:05:32 +0000
@@ -18,4 +18,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
=== modified file 'account_statement_completion_voucher/__openerp__.py'
--- account_statement_completion_voucher/__openerp__.py 2012-06-27 07:58:32 +0000
+++ account_statement_completion_voucher/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,8 +24,11 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
- 'complexity': 'normal', #easy, normal, expert
- 'depends': ['account_statement_base_completion','account_voucher'],
+ 'complexity': 'normal',
+ 'depends': [
+ 'account_statement_base_completion',
+ 'account_voucher'
+ ],
'description': """
This module is only needed when using account_statement_base_completion with voucher in order adapt the view correctly.
""",
@@ -36,9 +39,8 @@
],
'demo_xml': [],
'test': [],
- 'installable': True,
+ 'installable': False,
'images': [],
- 'auto_install': True,
+ 'auto_install': False,
'license': 'AGPL-3',
- 'active': False,
}
=== modified file 'account_statement_completion_voucher/statement_view.xml'
--- account_statement_completion_voucher/statement_view.xml 2012-06-27 07:58:32 +0000
+++ account_statement_completion_voucher/statement_view.xml 2013-06-10 07:05:32 +0000
@@ -3,19 +3,19 @@
<data>
<!-- Override what we have in account_statement_base_completion to replace the one in the voucher -->
- <record id="account_statement_base_completion.bank_statement_view_form2" model="ir.ui.view">
+ <!-- <record id="account_statement_base_completion.bank_statement_view_form2" model="ir.ui.view">
<field name="name">account_bank_statement_import_base.bank_statement.auto_cmpl</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account_voucher.view_bank_statement_tree_voucher" />
<field name="type">form</field>
<field name="arch" type="xml">
<data>
- <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='voucher_id']" position="after">
+ <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='voucher_id']" position="after">
<field name="already_completed" />
</xpath>
</data>
</field>
- </record>
+ </record> -->
</data>
</openerp>
=== modified file 'account_statement_ext/__init__.py'
--- account_statement_ext/__init__.py 2012-06-20 14:10:01 +0000
+++ account_statement_ext/__init__.py 2013-06-10 07:05:32 +0000
@@ -21,4 +21,5 @@
import statement
import report
-import account
\ No newline at end of file
+import account
+import voucher
\ No newline at end of file
=== modified file 'account_statement_ext/__openerp__.py'
--- account_statement_ext/__openerp__.py 2013-05-15 21:12:19 +0000
+++ account_statement_ext/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -2,7 +2,7 @@
##############################################################################
#
# Author: Nicolas Bessi, Joel Grand-Guillaume
-# Copyright 2011-2012 Camptocamp SA
+# 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
@@ -20,12 +20,19 @@
##############################################################################
{'name': "Bank statement extension and profiles",
- 'version': '1.1',
+ 'version': '1.3.0',
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
+<<<<<<< TREE
'complexity': 'normal', #easy, normal, expert
'depends': ['account','report_webkit'],
+=======
+ 'complexity': 'normal',
+ 'depends': ['account',
+ 'report_webkit',
+ 'account_voucher'],
+>>>>>>> MERGE-SOURCE
'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,
@@ -59,6 +66,7 @@
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.
@@ -70,13 +78,11 @@
""",
'website': 'http://www.camptocamp.com',
- 'init_xml': [],
- 'update_xml': [
- 'statement_view.xml',
- 'report/bank_statement_webkit_header.xml',
- 'report.xml',
- 'security/ir.model.access.csv',
- ],
+ 'data': ['statement_view.xml',
+ 'report/bank_statement_webkit_header.xml',
+ 'report.xml',
+ 'security/ir.model.access.csv',
+ 'security/ir_rule.xml'],
'demo_xml': [],
'test': [],
'installable': True,
@@ -84,4 +90,4 @@
'auto_install': False,
'license': 'AGPL-3',
'active': False,
-}
+ }
=== modified file 'account_statement_ext/account.py'
--- account_statement_ext/account.py 2012-06-20 14:10:01 +0000
+++ account_statement_ext/account.py 2013-06-10 07:05:32 +0000
@@ -18,13 +18,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-import netsvc
-logger = netsvc.Logger()
-from openerp.osv.orm import Model, fields
+
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
class account_move(Model):
- _inherit='account.move'
-
+ _inherit = 'account.move'
+
def unlink(self, cr, uid, ids, context=None):
"""
Delete the reconciliation when we delete the moves. This
@@ -35,6 +36,3 @@
if move_line.reconcile_id:
move_line.reconcile_id.unlink(context=context)
return super(account_move, self).unlink(cr, uid, ids, context=context)
-
-
-
=== modified file 'account_statement_ext/i18n/fr.po'
--- account_statement_ext/i18n/fr.po 2012-12-13 13:57:29 +0000
+++ account_statement_ext/i18n/fr.po 2013-06-10 07:05:32 +0000
@@ -41,7 +41,7 @@
#. module: account_statement_ext
#: code:addons/account_statement_ext/statement.py:361
#, python-format
-msgid "Configuration Error !"
+msgid "Configuration Error!"
msgstr "Erreur de configuration !"
#. module: account_statement_ext
@@ -64,7 +64,7 @@
#: code:addons/account_statement_ext/statement.py:307
#: code:addons/account_statement_ext/statement.py:372
#, python-format
-msgid "Error !"
+msgid "Error!"
msgstr "Erreur !"
#. module: account_statement_ext
=== modified file 'account_statement_ext/report/__init__.py'
--- account_statement_ext/report/__init__.py 2012-06-20 14:10:01 +0000
+++ account_statement_ext/report/__init__.py 2013-06-10 07:05:32 +0000
@@ -1,9 +1,4 @@
-# -*- encoding: utf-8 -*-
-#
-# __init__.py
-#
-# Copyright (c) 2009 CamptoCamp. All rights reserved.
-##############################################################################
+# -*- 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
@@ -28,4 +23,4 @@
#
##############################################################################
-import bank_statement_report
\ No newline at end of file
+import bank_statement_report
=== modified file 'account_statement_ext/report/bank_statement_report.py'
--- account_statement_ext/report/bank_statement_report.py 2012-06-20 14:10:01 +0000
+++ account_statement_ext/report/bank_statement_report.py 2013-06-10 07:05:32 +0000
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
@@ -18,33 +18,29 @@
#
##############################################################################
-import time
-
-from report import report_sxw
-from osv import osv
-from tools.translate import _
-import pooler
-from operator import add, itemgetter
-from itertools import groupby
+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
+
class BankStatementWebkit(report_sxw.rml_parse):
- def __init__(self, cursor, uid, name, context):
- super(BankStatementWebkit, self).__init__(cursor, uid, name, context=context)
+ 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
+ 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))
- statement = self.pool.get('account.bank.statement').browse(cursor,uid,context['active_id']);
footer_date_time = self.formatLang(str(datetime.today())[:19], date_time=True)
self.localcontext.update({
- 'cr': cursor,
+ 'cr': cr,
'uid': uid,
- 'get_bank_statement' : self._get_bank_statement_data,
+ 'get_bank_statement': self._get_bank_statement_data,
'report_name': _('BORDEREAU DE REMISE DE CHEQUES'),
'additional_args': [
('--header-font-name', 'Helvetica'),
@@ -58,10 +54,15 @@
('--footer-line',),
],
})
- def _get_bank_statement_data(self,statement):
+
+ 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)
+ 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',
=== modified file 'account_statement_ext/security/ir.model.access.csv'
--- account_statement_ext/security/ir.model.access.csv 2012-09-20 08:37:42 +0000
+++ account_statement_ext/security/ir.model.access.csv 2013-06-10 07:05:32 +0000
@@ -1,3 +1,3 @@
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,0,0,0
+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
=== added file 'account_statement_ext/security/ir_rule.xml'
--- account_statement_ext/security/ir_rule.xml 1970-01-01 00:00:00 +0000
+++ account_statement_ext/security/ir_rule.xml 2013-06-10 07:05:32 +0000
@@ -0,0 +1,10 @@
+<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>
\ No newline at end of file
=== modified file 'account_statement_ext/statement.py'
--- account_statement_ext/statement.py 2013-04-04 11:14:03 +0000
+++ account_statement_ext/statement.py 2013-06-10 07:05:32 +0000
@@ -18,13 +18,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
-from tools.translate import _
-import datetime
-import netsvc
-logger = netsvc.Logger()
-from openerp.osv.orm import Model, fields
+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)
+ 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 AccountStatementProfil(Model):
"""
@@ -33,38 +45,55 @@
journal to use, the partner and commision account and so on.
"""
_name = "account.statement.profile"
+ _inherit = ['mail.thread']
+
_description = "Statement Profil"
-
+
_columns = {
- 'name': fields.char('Name', size=128, required=True),
- '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 tic 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="Tic that box if you want to use the credit insitute partner\
- in the counterpart of the intermediat/banking move."
- ),
- 'balance_check': fields.boolean('Balance check',
- help="Tic 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."
- ),
+ 'name': fields.char('Name', required=True),
+ '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),
+<<<<<<< TREE
'bank_statement_ids': fields.one2many('account.bank.statement', 'profile_id', 'Bank Statement Imported'),
'internal_account_transfer_id': fields.many2one('account.account',
'Internal Account Transfer',
@@ -72,80 +101,115 @@
bank transfer")
+=======
+
+ 'bank_statement_ids': fields.one2many('account.bank.statement',
+ 'profile_id',
+ 'Bank Statement Imported'),
+ 'company_id': fields.many2one('res.company', 'Company'),
+>>>>>>> MERGE-SOURCE
}
-
+
def _check_partner(self, cr, uid, ids, context=None):
obj = self.browse(cr, uid, ids[0], context=context)
- if obj.partner_id == False and obj.force_partner_on_bank:
+ 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' !", []),
+ (_check_partner, "You need to put a partner if you tic the 'Force partner on bank move'!", []),
]
class AccountBankStatement(Model):
"""
- We improve the bank statement class mostly for :
- - Removing the period and compute it from the date of each line.
+ 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
+ - 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
+
_columns = {
- 'profile_id': fields.many2one('account.statement.profile',
- 'Profil', required=True, readonly=True, states={'draft': [('readonly', False)]}),
+ 'profile_id': fields.many2one(
+ 'account.statement.profile',
+ 'Profil',
+ required=True,
+ readonly=True,
+ states={'draft': [('readonly', False)]}),
'credit_partner_id': fields.related(
- 'profile_id',
- 'partner_id',
- type='many2one',
- relation='res.partner',
- string='Financial Partner',
- store=True, readonly=True),
+ 'profile_id',
+ 'partner_id',
+ type='many2one',
+ relation='res.partner',
+ string='Financial Partner',
+ store=True,
+ readonly=True),
'balance_check': fields.related(
- 'profile_id',
- 'balance_check',
- type='boolean',
- string='Balance check',
- store=True, readonly=True),
- 'journal_id': fields.related(
- 'profile_id',
- 'journal_id',
+ 'profile_id',
+ 'balance_check',
+ type='boolean',
+ string='Balance check',
+ store=True,
+ readonly=True),
+ 'journal_id': fields.related(
+ 'profile_id',
+ 'journal_id',
type='many2one',
- relation='account.journal',
- string='Journal',
- store=True, readonly=True),
- 'period_id': fields.many2one('account.period', 'Period', required=False, readonly=True),
+ relation='account.journal',
+ string='Journal',
+ store=True,
+ readonly=True),
+ 'period_id': fields.many2one(
+ 'account.period',
+ 'Period',
+ required=False,
+ readonly=False,
+ invisible=True),
}
_defaults = {
- 'period_id': lambda *a: False,
+ 'period_id': _default_period,
}
-
+
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)
+ profile = profile_obj.browse(cr, uid, vals['profile_id'], context=context)
vals['journal_id'] = profile.journal_id.id
+<<<<<<< TREE
return super(AccountBankStatement, self).create(cr, uid, vals, context=context)
def _get_period(self, cursor, uid, date, context=None):
+=======
+ return super(AccountBankSatement, self).create(cr, uid, vals, context=context)
+
+ def _get_period(self, cr, uid, date, context=None):
+>>>>>>> MERGE-SOURCE
"""
Find matching period for date, used in the statement line creation.
"""
period_obj = self.pool.get('account.period')
- periods = period_obj.find(cursor, uid, dt=date, context=context)
+ periods = period_obj.find(cr, uid, dt=date, context=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
@@ -153,184 +217,111 @@
"""
for statement in self.browse(cr, uid, ids, context=context):
if (statement.period_id and
- statement.company_id.id != statement.period_id.company_id.id):
+ statement.company_id.id != statement.period_id.company_id.id):
return False
for line in statement.line_ids:
if (line.period_id and
- statement.company_id.id != line.period_id.company_id.id):
+ statement.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']),
+ (_check_company_id,
+ 'The journal and period chosen have to belong to the same company.',
+ ['journal_id', 'period_id']),
]
- def button_cancel(self, cr, uid, ids, context={}):
- """
- We cancel the related move, delete them and finally put the
- statement in draft state. So no need to unreconcile all entries,
- then unpost them, then finaly cancel the bank statement.
- """
- done = []
- for st in self.browse(cr, uid, ids, context=context):
- if st.state=='draft':
- continue
- ids = []
- for line in st.line_ids:
- for move in line.move_ids:
- if move.state <> 'draft':
- move.button_cancel(context=context)
- move.unlink(context=context)
- done.append(st.id)
- self.write(cr, uid, done, {'state':'draft'}, context=context)
- return True
-
- def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
- """
- Override a large portion of the code to compute the periode for each line instead of
- taking the period of the whole statement.
- Remove the entry posting on generated account moves.
+ 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(AccountBankSatement, 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(AccountBankSatement, 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 receivable_account_id is set, we'll use it instead of the "partner" one
- - If partner_id is set, we'll us it for the commission (when imported throufh the wizard)
- 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 int/long: st_line_id: account.bank.statement.line ID
- :param int/long: company_currency_id: res.currency ID
- :param char: st_line_number: that will be used as the name of the generated account move
- :return: int/long: ID of the created account.move
+ :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
"""
- if context is None:
- context = {}
- res_currency_obj = self.pool.get('res.currency')
- account_move_obj = self.pool.get('account.move')
- account_move_line_obj = self.pool.get('account.move.line')
- account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') # Chg
- st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context) # Chg
- st = st_line.statement_id
-
- context.update({'date': st_line.date})
- ctx = context.copy() # Chg
- ctx['company_id'] = st_line.company_id.id # Chg
- period_id = self._get_period( # Chg
- cr, uid, st_line.date, context=ctx)
-
- move_id = account_move_obj.create(cr, uid, {
- 'journal_id': st.journal_id.id,
- 'period_id': period_id, # Chg
- 'date': st_line.date,
- 'name': st_line_number,
- 'ref': st_line.ref,
- }, context=context)
- account_bank_statement_line_obj.write(cr, uid, [st_line.id], { # Chg
- 'move_ids': [(4, move_id, False)]
- })
-
- torec = []
- if st_line.amount >= 0:
- account_id = st.journal_id.default_credit_account_id.id
- else:
- account_id = st.journal_id.default_debit_account_id.id
-
- acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
- context.update({
- 'res.currency.compute.account': acc_cur,
- })
- amount = res_currency_obj.compute(cr, uid, st.currency.id,
- company_currency_id, st_line.amount, context=context)
-
- val = {
- 'name': st_line.name,
- 'date': st_line.date,
- 'ref': st_line.ref,
- 'move_id': move_id,
- 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
- 'account_id': (st_line.account_id) and st_line.account_id.id,
- 'credit': ((amount>0) and amount) or 0.0,
- 'debit': ((amount<0) and -amount) or 0.0,
- # Replace with the treasury one instead of bank #Chg
- 'statement_id': st.id,
- 'journal_id': st.journal_id.id,
- 'period_id': period_id, #Chg
- 'currency_id': st.currency.id,
- 'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False
- }
-
- if st.currency.id <> company_currency_id:
- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st.currency.id, amount, context=context)
- val['amount_currency'] = -amount_cur
-
- if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
- val['currency_id'] = st_line.account_id.currency_id.id
- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st_line.account_id.currency_id.id, amount, context=context)
- val['amount_currency'] = -amount_cur
-
- move_line_id = account_move_line_obj.create(cr, uid, val, context=context)
- torec.append(move_line_id)
-
- # Fill the secondary amount/currency
- # if currency is not the same than the company
- amount_currency = False
- currency_id = False
- if st.currency.id <> company_currency_id:
- amount_currency = st_line.amount
- currency_id = st.currency.id
- # GET THE RIGHT PARTNER ACCORDING TO THE CHOSEN PROFIL # Chg
- if st.profile_id.force_partner_on_bank: # Chg
- bank_parrtner_id = st.profile_id.partner_id.id # Chg
- else: # Chg
- bank_parrtner_id = ((st_line.partner_id) and st_line.partner_id.id) or False # Chg
-
- account_move_line_obj.create(cr, uid, {
- 'name': st_line.name,
- 'date': st_line.date,
- 'ref': st_line.ref,
- 'move_id': move_id,
- 'partner_id': bank_parrtner_id, # Chg
- 'account_id': account_id,
- 'credit': ((amount < 0) and -amount) or 0.0,
- 'debit': ((amount > 0) and amount) or 0.0,
- # Replace with the treasury one instead of bank #Chg
- 'statement_id': st.id,
- 'journal_id': st.journal_id.id,
- 'period_id': period_id, #Chg
- 'amount_currency': amount_currency,
- 'currency_id': currency_id,
- }, context=context)
-
- for line in account_move_line_obj.browse(cr, uid, [x.id for x in
- account_move_obj.browse(cr, uid, move_id,
- context=context).line_id],
- context=context):
- if line.state <> 'valid':
- raise osv.except_osv(_('Error !'),
- _('Journal item "%s" is not valid.') % line.name)
-
- # Bank statements will not consider boolean on journal entry_posted
- account_move_obj.post(cr, uid, [move_id], context=context)
- return move_id
+ bank_partner_id = super(AccountBankSatement, self)._get_counter_part_partner(cr,
+ uid,
+ st_line,
+ context=context)
+ # get the right partner according to the chosen profil
+ 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
+ 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)
+ 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
+ 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:
@@ -346,47 +337,48 @@
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 !
+
+ TODO: Log the error in a bank statement field instead of using a popup!
"""
- # obj_seq = self.pool.get('irerrors_stack.sequence')
- if context is None:
- context = {}
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.'))
+ 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
+# Begin Changes
st_number = self._get_st_number_period_profile(cr, uid, st.date, st.profile_id.id)
-# End Changes
+# 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.'))
+ 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,))
+ 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)
+ 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)
@@ -397,72 +389,128 @@
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)
- self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,))
- return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
-
- def get_account_for_counterpart(self, cursor, uid,
- amount, account_receivable, account_payable):
+ 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
- :return: int/long :the default account to be used by statement line as the counterpart
- of the journal account depending on the amount.
+ :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
- if amount >= 0:
+ 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
- else:
- account_id = account_payable
if not account_id:
raise osv.except_osv(
_('Can not determine account'),
_('Please ensure that minimal properties are set')
)
- return account_id
+ return [account_id, ltype]
- def get_default_pay_receiv_accounts(self, cursor, uid, context=None):
+ 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
+ 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.
"""
account_receivable = False
account_payable = False
- context = context or {}
property_obj = self.pool.get('ir.property')
model_fields_obj = self.pool.get('ir.model.fields')
model_fields_ids = model_fields_obj.search(
- cursor,
+ cr,
uid,
[('name', 'in', ['property_account_receivable',
'property_account_payable']),
- ('model', '=', 'res.partner'),],
+ ('model', '=', 'res.partner')],
context=context
)
- property_ids = property_obj.search(
- cursor,
- uid, [
- ('fields_id', 'in', model_fields_ids),
- ('res_id', '=', False),
- ],
- context=context
- )
-
- for erp_property in property_obj.browse(cursor, uid,
- property_ids, 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':
@@ -473,56 +521,64 @@
"""
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 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:
+<<<<<<< TREE
return super(AccountBankStatement,self).balance_check(cr, uid, st_id, journal_type, context)
+=======
+ return super(AccountBankSatement, self).balance_check(
+ cr, uid, st_id, journal_type, context=context)
+>>>>>>> MERGE-SOURCE
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)
+ import_config = self.pool.get("account.statement.profile").browse(
+ cr, uid, profile_id, context=context)
journal_id = import_config.journal_id.id
account_id = import_config.journal_id.default_debit_account_id.id
credit_partner_id = import_config.partner_id and import_config.partner_id.id or False
- return {'value': {'journal_id':journal_id, 'account_id': account_id,
- 'balance_check':import_config.balance_check,
- 'credit_partner_id':credit_partner_id,
- }}
+ return {'value': {'journal_id': journal_id,
+ 'account_id': account_id,
+ 'balance_check': import_config.balance_check,
+ 'credit_partner_id': credit_partner_id}}
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
+ 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, cursor, user, context=None):
+ def _get_period(self, cr, uid, context=None):
"""
Return a period from a given date in the context.
"""
- date = context.get('date', None)
- periods = self.pool.get('account.period').find(cursor, user, dt=date)
+ if context is None:
+ context = {}
+ date = context.get('date')
+ periods = self.pool.get('account.period').find(cr, uid, dt=date)
return periods and periods[0] or False
- def _get_default_account(self, cursor, user, context=None):
- return self.get_values_for_line(cursor, user, context = context)['account_id']
-
+ 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),
@@ -532,19 +588,25 @@
'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, context = None):
+
+ 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
- - Elif line_type is given, take the partner receivable/payable property (payable if type= supplier, receivable
+ # 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, take the partner receivable/payable property (receivable if amount >= 0.0,
- payable otherwise). In that case, we also fullfill the type (receivable = customer, payable = supplier)
- so it is easier for the accountant to know why the receivable/payable has been chosen
+ - 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'
@@ -557,20 +619,32 @@
...
}
"""
- if context is None:
- context = {}
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 profile_id:
- profile = self.pool.get("account.statement.profile").browse(cr,uid,profile_id)
+ 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
- res['type'] = 'general'
+ 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 partner -> take from him
+ # 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)
pay_account = part.property_account_payable.id
@@ -578,62 +652,53 @@
# 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)
- # Now we have both pay and receive account, choose the one to use
- # based on line_type first, then amount, otherwise take receivable one.
- if line_type is not False:
- if line_type == 'supplier':
- res['account_id'] = pay_account
- else:
- res['account_id'] = receiv_account
- elif amount is not False:
- if amount >= 0:
- res['account_id'] = receiv_account
- res['type'] = 'customer'
- else:
- res['account_id'] = pay_account
- res['type'] = 'supplier'
- if not account_id:
- res['account_id'] = receiv_account
+ 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, context=None):
+
+ 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_partner = self.pool.get('res.partner')
- if context is None:
- context = {}
+ obj_stat = self.pool.get('account.bank.statement')
if not partner_id:
return {}
- part = obj_partner.browse(cr, uid, partner_id, context=context)
- if not part.supplier and not part.customer:
- type = 'general'
- elif part.supplier and part.customer:
- type = 'general'
- else:
- if part.supplier == True:
- type = 'supplier'
- if part.customer == True:
- type = 'customer'
- res_type = self.onchange_type(cr, uid, ids, partner_id, type, profile_id, context=context) # Chg
+ 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': type, 'account_id': res_type['value']['account_id']}}
- return {'value': {'type': type}}
-
- def onchange_type(self, cr, uid, line_id, partner_id, type, profile_id, context=None):
+ 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.
"""
+<<<<<<< TREE
if context is None:
context = {}
res = super(AccountBankStatementLine,self).onchange_type(cr, uid, line_id, partner_id, type, context)
+=======
+ res = super(AccountBankSatementLine, self).onchange_type(cr, uid,
+ line_id,
+ partner_id,
+ line_type,
+ context=context)
+>>>>>>> MERGE-SOURCE
if 'account_id' in res['value']:
- result = self.get_values_for_line(cr, uid, profile_id = profile_id,
- partner_id = partner_id, line_type = type, context = context)
+ 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']})
+ res['value'].update({'account_id': result['account_id']})
return res
-
=== modified file 'account_statement_ext/statement_view.xml'
--- account_statement_ext/statement_view.xml 2013-04-04 11:14:03 +0000
+++ account_statement_ext/statement_view.xml 2013-06-10 07:05:32 +0000
@@ -2,6 +2,7 @@
<openerp>
<data>
+<<<<<<< TREE
<!-- Account Move Line : add statement_treasury_id -->
<record id="view_move_line_tree" model="ir.ui.view">
<field name="name">account.move.line.tree</field>
@@ -27,6 +28,8 @@
</field>
</record>
+=======
+>>>>>>> MERGE-SOURCE
<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>
@@ -36,6 +39,7 @@
<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" />
@@ -44,6 +48,7 @@
<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>
@@ -56,6 +61,7 @@
<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" />
@@ -72,6 +78,7 @@
<field name="view_mode">tree,form</field>
</record>
+<<<<<<< TREE
<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 model="ir.ui.view" id="id_in_statement_line">
@@ -87,19 +94,24 @@
</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"/>
+
+
+
+>>>>>>> MERGE-SOURCE
<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="type">search</field>
<field name="arch" type="xml">
- <xpath expr="/search/group/field[@name='name']" position="before">
+ <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/group/field[@name='period_id']" position="replace">
+ <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"/>
@@ -125,6 +137,7 @@
</field>
</record>
+<<<<<<< TREE
<record id="view_treasury_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement.form</field>
@@ -197,6 +210,68 @@
</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 -->
+ <xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
+ </xpath>
+
+ <xpath expr="/form/sheet/group" position="after">
+ <group>
+ <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
+ <separator string="Profile Details" colspan="4"/>
+ <field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>
+ <field name="credit_partner_id"/>
+ <field name="account_id" invisible="1"/>
+ <field name="balance_check" invisible="1"/>
+ </group>
+ </xpath>
+
+ # Make balance visible or not depending on profile
+ <xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">
+ <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
+ </xpath>
+ <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="attributes">
+ <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
+ </xpath>
+ <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="after">
+ <field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
+ </xpath>
+
+ <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">
+ <field name="id" readonly="1" />
+ </xpath>
+
+ <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">
+ <field name="id" readonly="1" />
+ </xpath>
+ # Adapt onchange signature
+ <xpath expr="/form/sheet/notebook/page/field/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="/form/sheet/notebook/page/field/form/group/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="/form/sheet/notebook/page/field/form/group/field[@name='type']" position="replace">
+ <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
+ </xpath>
+ <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace">
+ <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
+ </xpath>
+
+ </field>
+ </record>
+
+
+>>>>>>> MERGE-SOURCE
<act_window id="act_bank_statement_from_profile"
name="Open Statements"
res_model="account.bank.statement"
=== added file 'account_statement_ext/voucher.py'
--- account_statement_ext/voucher.py 1970-01-01 00:00:00 +0000
+++ account_statement_ext/voucher.py 2013-06-10 07:05:32 +0000
@@ -0,0 +1,49 @@
+# -*- 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)
=== modified file 'account_statement_ext_voucher/__init__.py'
--- account_statement_ext_voucher/__init__.py 2012-06-20 14:10:01 +0000
+++ account_statement_ext_voucher/__init__.py 2013-06-10 07:05:32 +0000
@@ -18,5 +18,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
-import statement_voucher
=== modified file 'account_statement_ext_voucher/__openerp__.py'
--- account_statement_ext_voucher/__openerp__.py 2012-07-04 11:51:39 +0000
+++ account_statement_ext_voucher/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,11 +24,18 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
- 'complexity': 'normal', #easy, normal, expert
- 'depends': ['account_statement_ext','account_voucher'],
+ 'complexity': 'normal',
+ 'depends': [
+ 'account_statement_ext',
+ 'account_voucher'
+ ],
'description': """
- This module is only needed when using account_bank_statement_ext with voucher in order to compute the period
+ This module is deprecated. It was only needed when using account_bank_statement_ext with voucher in order to compute the period
correctly. This is mainly because with account_bank_statement_ext, the period is computed for each line.
+
+ Now, we include this in the account_statement_ext module and added a dependencies on account_voucher (mainly cause we can't get
+ rid of the voucher in version 7.0).
+
""",
'website': 'http://www.camptocamp.com',
'init_xml': [],
@@ -37,9 +44,9 @@
],
'demo_xml': [],
'test': [],
- 'installable': True,
+ 'installable': False,
'images': [],
- 'auto_install': True,
+ 'auto_install': False,
'license': 'AGPL-3',
- 'active': False,
+
}
=== modified file 'account_statement_ext_voucher/statement_voucher.py'
--- account_statement_ext_voucher/statement_voucher.py 2012-07-04 14:27:06 +0000
+++ account_statement_ext_voucher/statement_voucher.py 2013-06-10 07:05:32 +0000
@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-from openerp.osv.orm import Model, fields
+
+from openerp.osv.orm import Model
class AccountVoucher(Model):
@@ -30,7 +31,8 @@
if context is None:
context = {}
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'))[0].period_id.id
+ 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(
@@ -47,4 +49,3 @@
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)
-
=== removed file 'account_statement_ext_voucher/statement_voucher_view.xml'
--- account_statement_ext_voucher/statement_voucher_view.xml 2012-07-04 11:51:39 +0000
+++ account_statement_ext_voucher/statement_voucher_view.xml 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<openerp>
- <data>
-
- <record id="account_voucher.view_bank_statement_form_invoice" model="ir.ui.view">
- <field name="name">account.bank.statement.invoice.form.inherit</field>
- <field name="model">account.bank.statement</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account.view_bank_statement_form"/>
- <field name="arch" type="xml">
- <field name="currency" invisible="1" position="after">
- </field>
- </field>
- </record>
-
- </data>
-</openerp>
=== modified file 'account_statement_transactionid_completion/__openerp__.py'
--- account_statement_transactionid_completion/__openerp__.py 2012-07-31 14:29:55 +0000
+++ account_statement_transactionid_completion/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,8 +24,11 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
- 'complexity': 'normal', #easy, normal, expert
- 'depends': ['account_statement_base_completion', 'base_transaction_id'],
+ 'complexity': 'normal',
+ 'depends': [
+ 'account_statement_base_completion',
+ 'base_transaction_id'
+ ],
'description': """
Add a completion method based on transaction ID providen by the bank/office.
@@ -50,5 +53,4 @@
'images': [],
'auto_install': True,
'license': 'AGPL-3',
- 'active': False,
}
=== modified file 'account_statement_transactionid_completion/statement.py'
--- account_statement_transactionid_completion/statement.py 2012-06-26 13:46:03 +0000
+++ account_statement_transactionid_completion/statement.py 2013-06-10 07:05:32 +0000
@@ -19,34 +19,34 @@
#
##############################################################################
-from tools.translate import _
-import datetime
-import netsvc
-logger = netsvc.Logger()
-from openerp.osv.orm import Model, fields
+from openerp.tools.translate import _
+from openerp.osv.orm import Model
+from openerp.osv import fields
from openerp.addons.account_statement_base_completion.statement import ErrorTooManyPartner
+
class AccountStatementCompletionRule(Model):
"""Add a rule based on transaction ID"""
-
+
_inherit = "account.statement.completion.rule"
-
+
def _get_functions(self, cr, uid, context=None):
- res = super (AccountStatementCompletionRule, self)._get_functions(
- cr, uid, context=context)
- res.append(('get_from_transaction_id_and_so', 'From line reference (based on SO transaction ID)'))
+ res = super(AccountStatementCompletionRule, self)._get_functions(
+ cr, uid, context=context)
+ res.append(('get_from_transaction_id_and_so',
+ 'From line reference (based on SO transaction ID)'))
return res
- _columns={
+ _columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
}
-
- def get_from_transaction_id_and_so(self, cr, uid, line_id, context=None):
+
+ def get_from_transaction_id_and_so(self, cr, uid, st_line, context=None):
"""
Match the partner based on the transaction ID field of the SO.
Then, call the generic st_line method to complete other values.
In that case, we always fullfill the reference of the line with the SO name.
- :param int/long line_id: ID of the concerned account.bank.statement.line
+ :param dict st_line: read 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 {}
@@ -55,36 +55,40 @@
...}
"""
st_obj = self.pool.get('account.bank.statement.line')
- st_line = st_obj.browse(cr,uid,line_id)
res = {}
- if st_line:
- so_obj = self.pool.get('sale.order')
- so_id = so_obj.search(cr, uid, [('transaction_id', '=', st_line.transaction_id)])
- if so_id and len(so_id) == 1:
- so = so_obj.browse(cr, uid, so_id[0])
- res['partner_id'] = so.partner_id.id
- res['ref'] = so.name
- elif so_id and len(so_id) > 1:
- raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than one partner.')%(st_line.name,st_line.ref))
- if so_id:
- st_vals = st_obj.get_values_for_line(cr, uid, profile_id = st_line.statement_id.profile_id.id,
- partner_id = res.get('partner_id',False), line_type = st_line.type, amount = st_line.amount, context=context)
- res.update(st_vals)
+ so_obj = self.pool.get('sale.order')
+ so_id = so_obj.search(cr,
+ uid,
+ [('transaction_id', '=', st_line['transaction_id'])],
+ context=context)
+ if len(so_id) > 1:
+ raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than '
+ 'one partner.') % (st_line['name'], st_line['ref']))
+ if len(so_id) == 1:
+ so = so_obj.browse(cr, uid, so_id[0], context=context)
+ res['partner_id'] = so.partner_id.id
+ res['ref'] = so.name
+ st_vals = st_obj.get_values_for_line(cr,
+ uid,
+ profile_id=st_line['profile_id'],
+ master_account_id=st_line['master_account_id'],
+ partner_id=res.get('partner_id', False),
+ line_type=st_line['type'],
+ amount=st_line['amount'] if st_line['amount'] else 0.0,
+ context=context)
+ res.update(st_vals)
return res
-
+
class AccountStatementLine(Model):
_inherit = "account.bank.statement.line"
- _columns={
+ _columns = {
# 'additionnal_bank_fields' : fields.serialized('Additionnal infos from bank', help="Used by completion and import system."),
- 'transaction_id': fields.sparse(type='char', string='Transaction ID',
+ 'transaction_id': fields.sparse(
+ type='char',
+ string='Transaction ID',
size=128,
serialization_field='additionnal_bank_fields',
help="Transction id from the financial institute"),
}
-
-
-
-
-
=== modified file 'account_statement_transactionid_completion/statement_view.xml'
--- account_statement_transactionid_completion/statement_view.xml 2012-06-22 15:45:50 +0000
+++ account_statement_transactionid_completion/statement_view.xml 2013-06-10 07:05:32 +0000
@@ -10,7 +10,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<data>
- <xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='label']" position="after">
+ <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='label']" position="after">
<field name="transaction_id" />
</xpath>
</data>
=== modified file 'account_statement_transactionid_import/__init__.py'
--- account_statement_transactionid_import/__init__.py 2012-06-22 15:45:50 +0000
+++ account_statement_transactionid_import/__init__.py 2013-06-10 07:05:32 +0000
@@ -19,4 +19,4 @@
#
##############################################################################
import parser
-import statement
\ No newline at end of file
+import statement
=== modified file 'account_statement_transactionid_import/__openerp__.py'
--- account_statement_transactionid_import/__openerp__.py 2012-07-31 14:29:55 +0000
+++ account_statement_transactionid_import/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,8 +24,11 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
- 'complexity': 'normal', #easy, normal, expert
- 'depends': ['account_statement_base_import','account_statement_transactionid_completion'],
+ 'complexity': 'normal',
+ 'depends': [
+ 'account_statement_base_import',
+ 'account_statement_transactionid_completion'
+ ],
'description': """
This module brings generic methods and fields on bank statement to deal with
the importation of different bank and offices that uses transactionID.
@@ -36,12 +39,12 @@
This module can handle a commission taken by the payment office and has the following format:
- * transaction_id : the transaction ID given by the bank/office. It is used as reference
+ * transaction_id: the transaction ID given by the bank/office. It is used as reference
in the generated entries and is useful for reconciliation process
- * date : date of the payment
- * amount : amount paid in the currency of the journal used in the importation profile
- * commission_amount : amount of the comission for each line
- * label : the comunication given by the payment office, used as communication in the
+ * date: date of the payment
+ * amount: amount paid in the currency of the journal used in the importation profile
+ * commission_amount: amount of the comission for each line
+ * label: the comunication given by the payment office, used as communication in the
generated entries.
""",
'website': 'http://www.camptocamp.com',
@@ -54,5 +57,4 @@
'images': [],
'auto_install': False,
'license': 'AGPL-3',
- 'active': False,
}
=== modified file 'account_statement_transactionid_import/parser/__init__.py'
--- account_statement_transactionid_import/parser/__init__.py 2012-06-20 14:10:01 +0000
+++ account_statement_transactionid_import/parser/__init__.py 2013-06-10 07:05:32 +0000
@@ -19,6 +19,4 @@
#
##############################################################################
-# from parser import new_bank_statement_parser
-# from parser import BankStatementImportParser
-import transactionid_file_parser
\ No newline at end of file
+import transactionid_file_parser
=== modified file 'account_statement_transactionid_import/parser/transactionid_file_parser.py'
--- account_statement_transactionid_import/parser/transactionid_file_parser.py 2012-06-22 15:45:50 +0000
+++ account_statement_transactionid_import/parser/transactionid_file_parser.py 2013-06-10 07:05:32 +0000
@@ -17,36 +17,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
-from openerp.tools.translate import _
-import base64
-import csv
-import tempfile
import datetime
from account_statement_base_import.parser.file_parser import FileParser
-try:
- import xlrd
-except:
- raise Exception(_('Please install python lib xlrd'))
class TransactionIDFileParser(FileParser):
"""
TransactionID parser that use a define format in csv or xls to import
bank statement.
"""
-
+
def __init__(self, parse_name, ftype='csv'):
- convertion_dict = {
- 'transaction_id': unicode,
- 'label': unicode,
- 'date': datetime.datetime,
- 'amount': float,
- 'commission_amount': float
- }
+ conversion_dict = {'transaction_id': unicode,
+ 'label': unicode,
+ 'date': datetime.datetime,
+ 'amount': float,
+ 'commission_amount': float}
# Order of cols does not matter but first row of the file has to be header
keys_to_validate = ['transaction_id', 'label', 'date', 'amount', 'commission_amount']
- super(TransactionIDFileParser,self).__init__(parse_name, keys_to_validate=keys_to_validate, ftype=ftype, convertion_dict=convertion_dict)
+ super(TransactionIDFileParser, self).__init__(parse_name, keys_to_validate=keys_to_validate,
+ ftype=ftype, conversion_dict=conversion_dict)
@classmethod
def parser_for(cls, parser_name):
@@ -59,7 +49,7 @@
def get_st_line_vals(self, line, *args, **kwargs):
"""
This method must return a dict of vals that can be passed to create
- method of statement line in order to record it. It is the responsibility
+ method of statement line in order to record it. It is the responsibility
of every parser to give this dict of vals, so each one can implement his
own way of recording the lines.
:param: line: a dict of vals that represent a line of result_row_list
@@ -76,15 +66,13 @@
In this generic parser, the commission is given for every line, so we store it
for each one.
"""
- return {
- 'name': line.get('label', line.get('ref','/')),
- 'date': line.get('date', datetime.datetime.now().date()),
- 'amount': line.get('amount', 0.0),
- 'ref': line.get('transaction_id','/'),
- 'label': line.get('label',''),
- 'transaction_id': line.get('transaction_id','/'),
- 'commission_amount': line.get('commission_amount', 0.0),
- }
+ return {'name': line.get('label', line.get('ref', '/')),
+ 'date': line.get('date', datetime.datetime.now().date()),
+ 'amount': line.get('amount', 0.0),
+ 'ref': line.get('transaction_id', '/'),
+ 'label': line.get('label', ''),
+ 'transaction_id': line.get('transaction_id', '/'),
+ 'commission_amount': line.get('commission_amount', 0.0)}
def _post(self, *args, **kwargs):
"""
@@ -93,7 +81,6 @@
res = super(TransactionIDFileParser, self)._post(*args, **kwargs)
val = 0.0
for row in self.result_row_list:
- val += row.get('commission_amount',0.0)
+ val += row.get('commission_amount', 0.0)
self.commission_global_amount = val
return res
-
=== modified file 'account_statement_transactionid_import/statement.py'
--- account_statement_transactionid_import/statement.py 2012-08-02 12:46:12 +0000
+++ account_statement_transactionid_import/statement.py 2013-06-10 07:05:32 +0000
@@ -19,25 +19,29 @@
#
##############################################################################
-from openerp.osv.orm import Model, fields
-from openerp.osv import fields, osv
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
class AccountStatementProfil(Model):
_inherit = "account.statement.profile"
-
-
+
def get_import_type_selection(self, cr, uid, context=None):
"""
Has to be inherited to add parser
"""
- res = super(AccountStatementProfil, self).get_import_type_selection(cr, uid, context=context)
- res.append(('generic_csvxls_transaction','Generic .csv/.xls based on SO transaction ID'))
+ res = super(AccountStatementProfil, self).get_import_type_selection(
+ cr, uid, context=context)
+ res.append(('generic_csvxls_transaction',
+ 'Generic .csv/.xls based on SO transaction ID'))
return res
-
-
+
_columns = {
- 'import_type': fields.selection(get_import_type_selection, 'Type of import', required=True,
- help = "Choose here the method by which you want to import bank statement for this profile."),
-
+ 'import_type': fields.selection(
+ get_import_type_selection,
+ 'Type of import',
+ required=True,
+ help="Choose here the method by which you want to import "
+ "bank statement for this profile."),
+
}
-
=== modified file 'base_transaction_id/__openerp__.py'
--- base_transaction_id/__openerp__.py 2012-07-31 14:29:55 +0000
+++ base_transaction_id/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -24,23 +24,34 @@
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Hidden/Dependency',
- 'complexity': 'easy', #easy, normal, expert
- 'depends': ['account', 'sale','stock'],
+ 'complexity': 'easy',
+ 'depends': [
+ 'account',
+ 'sale',
+ 'stock'
+ ],
'description': """
- Adds transaction id to invoice and sale models and views. On Sales order, you can specify the transaction ID
- used for the payment and it will be propagated to the invoice (even if made from packing).
- This is mostly used for e-commerce handling. You can then add a mapping on that SO field to save the e-commerce
- financial Transaction ID into the OpenERP SO field. The main purpose is to ease the reconciliation process and
+ Adds transaction id to invoice and sale models and views.
+ On Sales order, you can specify the transaction ID used
+ for the payment and it will be propagated to the invoice
+ (even if made from packing).
+ This is mostly used for e-commerce handling.
+ You can then add a mapping on that SO field to save
+ the e-commerce financial Transaction ID into the
+ OpenERP sale order field.
+ The main purpose is to ease the reconciliation process and
be able to find the partner when importing the bank statement.
""",
'website': 'http://www.openerp.com',
'init_xml': [],
- 'update_xml': ['invoice_view.xml', 'sale_view.xml'],
+ 'update_xml': [
+ 'invoice_view.xml',
+ 'sale_view.xml'
+ ],
'demo_xml': [],
'test': [],
'installable': True,
'images': [],
'auto_install': False,
'license': 'AGPL-3',
- 'active': False,
}
=== modified file 'base_transaction_id/invoice.py'
--- base_transaction_id/invoice.py 2012-05-15 11:52:10 +0000
+++ base_transaction_id/invoice.py 2013-06-10 07:05:32 +0000
@@ -19,17 +19,18 @@
#
##############################################################################
-from osv import fields, osv
-from tools.translate import _
-
-class AccountInvoice(osv.osv):
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class AccountInvoice(Model):
_inherit = 'account.invoice'
+
_columns = {
- 'transaction_id':fields.char(
+ 'transaction_id': fields.char(
'Transaction id',
size=128,
required=False,
select=1,
- help="Transction id from the financial institute"
- ),
+ help="Transction id from the financial institute"),
}
=== modified file 'base_transaction_id/sale.py'
--- base_transaction_id/sale.py 2012-05-15 11:52:10 +0000
+++ base_transaction_id/sale.py 2013-06-10 07:05:32 +0000
@@ -19,21 +19,25 @@
#
##############################################################################
-from osv import fields, osv
-
-class SaleOrder(osv.osv):
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class SaleOrder(Model):
_inherit = 'sale.order'
+
_columns = {
- 'transaction_id':fields.char('Transaction id', size=128,required=False,
- help="Transction id from the financial institute"),
+ 'transaction_id': fields.char(
+ 'Transaction id',
+ size=128,
+ required=False,
+ help="Transaction id from the financial institute"),
}
-
- def _prepare_invoice(self, cursor, uid, order, lines, context=None):
+ def _prepare_invoice(self, cr, uid, order, lines, context=None):
#we put the transaction id in the generated invoices
- if context is None:
- context = {}
- invoice_vals = super(SaleOrder, self)._prepare_invoice(cursor, uid, order, lines, context)
+ invoice_vals = super(SaleOrder, self)._prepare_invoice(
+ cr, uid, order, lines, context=context)
invoice_vals.update({
'transaction_id': order.transaction_id})
return invoice_vals
=== modified file 'base_transaction_id/stock.py'
--- base_transaction_id/stock.py 2012-05-16 14:09:21 +0000
+++ base_transaction_id/stock.py 2013-06-10 07:05:32 +0000
@@ -19,20 +19,24 @@
#
##############################################################################
-from osv import osv
-
-class StockPicking(osv.osv):
+from openerp.osv.orm import Model
+
+
+class StockPicking(Model):
_inherit = "stock.picking"
- def action_invoice_create(self, cursor, uid, ids, journal_id=False,
- group=False, type='out_invoice', context=None):
- res = super(StockPicking, self).action_invoice_create(cursor, uid, ids,
- journal_id,group, type, context)
+ def action_invoice_create(
+ self, cr, uid, ids, journal_id=False, group=False,
+ type='out_invoice', context=None):
+ res = super(StockPicking, self).action_invoice_create(
+ cr, uid, ids, journal_id, group, type, context)
for pick_id in res:
- pick = self.browse(cursor, uid, pick_id)
+ pick = self.browse(cr, uid, pick_id, context=context)
if pick.sale_id and pick.sale_id.transaction_id:
- self.pool.get('account.invoice').write(cursor,
- uid,
- res[pick_id],
- {'transaction_id': pick.sale_id.transaction_id})
+ self.pool.get('account.invoice').write(
+ cr,
+ uid,
+ res[pick_id],
+ {'transaction_id': pick.sale_id.transaction_id},
+ context=context)
return res
=== added directory 'invoicing_voucher_killer'
=== added file 'invoicing_voucher_killer/__init__.py'
--- invoicing_voucher_killer/__init__.py 1970-01-01 00:00:00 +0000
+++ invoicing_voucher_killer/__init__.py 2013-06-10 07:05:32 +0000
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
+# @author Nicolas Bessi
+#
+# 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/>.
+#
+##############################################################################
=== added file 'invoicing_voucher_killer/__openerp__.py'
--- invoicing_voucher_killer/__openerp__.py 1970-01-01 00:00:00 +0000
+++ invoicing_voucher_killer/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
+# @author Nicolas Bessi
+#
+# 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': 'Invoicing voucher killer',
+ 'version': '1.0.0',
+ 'category': 'other',
+ 'description': """
+Prevent the usage of voucher from invoices
+##########################################
+This add-on will disable "Register Payment" button
+""",
+ 'author': 'Camptocamp',
+ 'website': 'http://www.camptocamp.com',
+ 'depends': ['account_voucher'],
+ 'data': ['invoice_data.xml',
+ 'invoice_view.xml'],
+ 'demo_xml': [],
+ 'test': [],
+ 'installable': True,
+ 'active': False,
+ }
=== added file 'invoicing_voucher_killer/invoice_data.xml'
--- invoicing_voucher_killer/invoice_data.xml 1970-01-01 00:00:00 +0000
+++ invoicing_voucher_killer/invoice_data.xml 2013-06-10 07:05:32 +0000
@@ -0,0 +1,7 @@
+<openerp>
+ <data>
+ <record id="invoice_voucher_user" model="res.groups">
+ <field name="name">Use voucher in Invoices</field>
+ </record>
+ </data>
+</openerp>
=== added file 'invoicing_voucher_killer/invoice_view.xml'
--- invoicing_voucher_killer/invoice_view.xml 1970-01-01 00:00:00 +0000
+++ invoicing_voucher_killer/invoice_view.xml 2013-06-10 07:05:32 +0000
@@ -0,0 +1,48 @@
+<openerp>
+ <data>
+ <record id="invoice_voucher_group" model="ir.ui.view">
+ <field name="name">Hide voucher in invoice</field>
+ <field name="model">account.invoice</field>
+ <field name="inherit_id" ref="account_voucher.view_invoice_customer" />
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <xpath expr="//button[@name='invoice_pay_customer'][last()]"
+ position="replace">
+ <button name="invoice_pay_customer"
+ type="object"
+ string="Register Payment"
+ attrs="{'invisible': ['|', ('state','!=','open'), ('sent','=',True)]}"
+ groups="invoicing_voucher_killer.invoice_voucher_user"/>
+ </xpath>
+ <xpath expr="//button[@name='invoice_pay_customer'][1]"
+ position="replace">
+ <button name="invoice_pay_customer"
+ type="object"
+ string="Register Payment"
+ attrs="{'invisible': ['|', ('state','!=','open'), ('sent','=',False)]}"
+ class="oe_highlight"
+ groups="invoicing_voucher_killer.invoice_voucher_user"/>
+ </xpath>
+ </field>
+ </record>
+
+ <record id="invoice_voucher_group_supp_inv" model="ir.ui.view">
+ <field name="name">Hide voucher in supplier invoice</field>
+ <field name="model">account.invoice</field>
+ <field name="inherit_id" ref="account_voucher.view_invoice_supplier" />
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <xpath expr="//button[@name='invoice_pay_customer'][last()]"
+ position="replace">
+ <button name="invoice_pay_customer"
+ type="object"
+ string="Pay"
+ states="open"
+ class="oe_highlight"
+ groups="invoicing_voucher_killer.invoice_voucher_user"/>
+ </xpath>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== added directory 'statement_voucher_killer'
=== added file 'statement_voucher_killer/__init__.py'
--- statement_voucher_killer/__init__.py 1970-01-01 00:00:00 +0000
+++ statement_voucher_killer/__init__.py 2013-06-10 07:05:32 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
+# @author Nicolas Bessi
+#
+# 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 voucher
=== added file 'statement_voucher_killer/__openerp__.py'
--- statement_voucher_killer/__openerp__.py 1970-01-01 00:00:00 +0000
+++ statement_voucher_killer/__openerp__.py 2013-06-10 07:05:32 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
+# @author Nicolas Bessi
+#
+# 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': 'voucher killer',
+ 'version': '1.0.0',
+ 'category': 'other',
+ 'description': """
+Prevent voucher creation when importing lines into statement.
+#############################################################
+
+When importing invoice or payment into a bank statement or a payment order, normally a
+draft voucher is created on the line. This module will disable this voucher creation""",
+ 'author': 'Camptocamp',
+ 'website': 'http://www.camptocamp.com',
+ 'depends': ['account_voucher', 'account_payment'],
+ 'init_xml': [],
+ 'update_xml': [],
+ 'demo_xml': [],
+ 'test': [],
+ 'installable': True,
+ 'active': False,
+ }
=== added file 'statement_voucher_killer/voucher.py'
--- statement_voucher_killer/voucher.py 1970-01-01 00:00:00 +0000
+++ statement_voucher_killer/voucher.py 2013-06-10 07:05:32 +0000
@@ -0,0 +1,128 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
+# @author Nicolas Bessi
+#
+# 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 orm
+
+import time
+
+
+class AccountStatementFromInvoiceLines(orm.TransientModel):
+
+ _inherit = "account.statement.from.invoice.lines"
+
+ def populate_statement(self, cr, uid, ids, context=None):
+ """Taken from account voucher as no hook is available. No function
+ no refactoring, just trimming the part that generates voucher"""
+ if context is None:
+ context = {}
+ statement_id = context.get('statement_id', False)
+ if not statement_id:
+ return {'type': 'ir.actions.act_window_close'}
+ data = self.read(cr, uid, ids, context=context)[0]
+ line_ids = data['line_ids']
+ if not line_ids:
+ return {'type': 'ir.actions.act_window_close'}
+
+ line_obj = self.pool.get('account.move.line')
+ statement_obj = self.pool.get('account.bank.statement')
+ statement_line_obj = self.pool.get('account.bank.statement.line')
+ currency_obj = self.pool.get('res.currency')
+ line_date = time.strftime('%Y-%m-%d')
+ statement = statement_obj.browse(cr, uid, statement_id, context=context)
+ # for each selected move lines
+ for line in line_obj.browse(cr, uid, line_ids, context=context):
+ ctx = context.copy()
+ # take the date for computation of currency => use payment date
+ ctx['date'] = line_date
+ amount = 0.0
+
+ if line.debit > 0:
+ amount = line.debit
+ elif line.credit > 0:
+ amount = -line.credit
+
+ if line.amount_currency:
+ amount = currency_obj.compute(cr, uid, line.currency_id.id,
+ statement.currency.id, line.amount_currency, context=ctx)
+ elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id):
+ amount = currency_obj.compute(cr, uid, line.invoice.currency_id.id,
+ statement.currency.id, amount, context=ctx)
+
+ context.update({'move_line_ids': [line.id],
+ 'invoice_id': line.invoice.id})
+ s_type = 'general'
+ if line.journal_id.type in ('sale', 'sale_refund'):
+ s_type = 'customer'
+ elif line.journal_id.type in ('purchase', 'purhcase_refund'):
+ s_type = 'supplier'
+ statement_line_obj.create(cr, uid, {
+ 'name': line.name or '?',
+ 'amount': amount,
+ 'type': s_type,
+ 'partner_id': line.partner_id.id,
+ 'account_id': line.account_id.id,
+ 'statement_id': statement_id,
+ 'ref': line.ref,
+ 'voucher_id': False,
+ 'date': time.strftime('%Y-%m-%d'),
+ }, context=context)
+ return {'type': 'ir.actions.act_window_close'}
+
+
+class AccountPaymentPopulateStatement(orm.TransientModel):
+ _inherit = "account.payment.populate.statement"
+
+ def populate_statement(self, cr, uid, ids, context=None):
+ """Taken from payment addon as no hook is vailable. No function
+ no refactoring, just trimming the part that generates voucher"""
+ line_obj = self.pool.get('payment.line')
+ statement_obj = self.pool.get('account.bank.statement')
+ statement_line_obj = self.pool.get('account.bank.statement.line')
+ currency_obj = self.pool.get('res.currency')
+
+ if context is None:
+ context = {}
+ data = self.read(cr, uid, ids, [], context=context)[0]
+ line_ids = data['lines']
+ if not line_ids:
+ return {'type': 'ir.actions.act_window_close'}
+
+ statement = statement_obj.browse(cr, uid, context['active_id'], context=context)
+
+ for line in line_obj.browse(cr, uid, line_ids, context=context):
+ ctx = context.copy()
+ ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now
+ amount = currency_obj.compute(cr, uid, line.currency.id,
+ statement.currency.id, line.amount_currency, context=ctx)
+ if not line.move_line_id.id:
+ continue
+ context.update({'move_line_ids': [line.move_line_id.id]})
+ st_line_id = statement_line_obj.create(cr, uid, {
+ 'name': line.order_id.reference or '?',
+ 'amount': - amount,
+ 'type': 'supplier',
+ 'partner_id': line.partner_id.id,
+ 'account_id': line.move_line_id.account_id.id,
+ 'statement_id': statement.id,
+ 'ref': line.communication,
+ }, context=context)
+
+ line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
+ return {'type': 'ir.actions.act_window_close'}