diff --git a/account_statement_ext/__init__.py b/account_statement_ext/__init__.py
index a2a4b3ca..7194652a 100644
--- a/account_statement_ext/__init__.py
+++ b/account_statement_ext/__init__.py
@@ -22,3 +22,4 @@
import statement
import report
import account
+import voucher
\ No newline at end of file
diff --git a/account_statement_ext/__openerp__.py b/account_statement_ext/__openerp__.py
index 0cac0b66..f6b31497 100644
--- a/account_statement_ext/__openerp__.py
+++ b/account_statement_ext/__openerp__.py
@@ -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,14 +20,15 @@
##############################################################################
{'name': "Bank statement extension and profiles",
- 'version': '1.1',
+ 'version': '1.2.0',
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Finance',
'complexity': 'normal',
'depends': [
'account',
- 'report_webkit'
+ 'report_webkit',
+ 'account_voucher'
],
'description': """
Improve the basic bank statement, by adding various new features,
@@ -62,6 +63,8 @@
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.
diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py
index c1eccf20..3881e482 100644
--- a/account_statement_ext/statement.py
+++ b/account_statement_ext/statement.py
@@ -551,7 +551,7 @@ class AccountBankSatementLine(Model):
res['account_id'] = receiv_account
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.
@@ -571,7 +571,9 @@ class AccountBankSatementLine(Model):
type = 'customer'
res_type = self.onchange_type(cr, uid, ids, partner_id, type, profile_id, context=context) # Chg
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,
+ 'account_id': res_type['value']['account_id'],
+ 'voucher_id': False}}
return {'value': {'type': type}}
def onchange_type(self, cr, uid, line_id, partner_id, type, profile_id, context=None):
diff --git a/account_statement_ext/voucher.py b/account_statement_ext/voucher.py
new file mode 100644
index 00000000..9c66140c
--- /dev/null
+++ b/account_statement_ext/voucher.py
@@ -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 .
+#
+##############################################################################
+
+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)
diff --git a/account_statement_ext_voucher/__init__.py b/account_statement_ext_voucher/__init__.py
index 3ddc934d..50fd0bc5 100644
--- a/account_statement_ext_voucher/__init__.py
+++ b/account_statement_ext_voucher/__init__.py
@@ -18,5 +18,3 @@
# along with this program. If not, see .
#
##############################################################################
-
-import statement_voucher
diff --git a/account_statement_ext_voucher/__openerp__.py b/account_statement_ext_voucher/__openerp__.py
index 059e4163..e0a22552 100644
--- a/account_statement_ext_voucher/__openerp__.py
+++ b/account_statement_ext_voucher/__openerp__.py
@@ -30,8 +30,12 @@
'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': [],
@@ -40,9 +44,9 @@
],
'demo_xml': [],
'test': [],
- 'installable': True,
+ 'installable': False,
'images': [],
- 'auto_install': True,
+ 'auto_install': False,
'license': 'AGPL-3',
}
diff --git a/account_statement_ext_voucher/statement_voucher_view.xml b/account_statement_ext_voucher/statement_voucher_view.xml
deleted file mode 100644
index 25160599..00000000
--- a/account_statement_ext_voucher/statement_voucher_view.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
- account.bank.statement.invoice.form.inherit
- account.bank.statement
- form
-
-
-
-
-
-
-
-
-