From df5e007a5bb174737df1d93fed3e24bc1acd19a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 16 Apr 2008 00:10:30 +0200 Subject: [PATCH] Enter a date for reconciliation and not a period --- move.py | 24 ++++++++++++++---------- move.xml | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/move.py b/move.py index fb320ab021..d677b12994 100644 --- a/move.py +++ b/move.py @@ -1070,13 +1070,17 @@ class Line(OSV): #TODO add hexmd5 return result - def reconcile(self, cursor, user, ids, journal_id=False, period_id=False, + def reconcile(self, cursor, user, ids, journal_id=False, date=False, account_id=False, context=None): move_obj = self.pool.get('account.move') currency_obj = self.pool.get('account.currency') reconciliation_obj = self.pool.get('account.move.reconciliation') + period_obj = self.pool.get('account.period') + ids = ids[:] - if journal_id and period_id and account_id: + if journal_id and account_id: + if not date: + date = datetime.date.today() account = None amount = Decimal('0.0') for line in self.browse(cursor, user, ids, context=context): @@ -1084,10 +1088,11 @@ class Line(OSV): if not account: account = line.account amount = currency_obj.round(cursor, user, account.currency, amount) + period_id = period_obj.find(cursor, user, date=date, context=context) move_id = move_obj.create(cursor, user, { 'journal': journal_id, 'period': period_id, - 'date': datetime.date.today(), + 'date': date, 'lines': [ ('create', { 'name': 'Write-Off', @@ -1290,13 +1295,12 @@ class ReconcileLinesWriteOff(WizardOSV): 'Reconcile Lines Write-Off' _name = 'account.move.reconcile_lines.writeoff' journal = fields.Many2One('account.journal', 'Journal', required=True) - period = fields.Many2One('account.period', 'Period', required=True) + date = fields.Date('Date', required=True) account = fields.Many2One('account.account', 'Account', required=True, domain=[('type.code', '!=', 'view')]) - def default_period(self, cursor, user, context=None): - period_obj = self.pool.get('account.period') - return period_obj.find(cursor, user, exception=False, context=context) + def default_date(self, cursor, user, context=None): + return datetime.date.today() ReconcileLinesWriteOff() @@ -1350,13 +1354,13 @@ class ReconcileLines(Wizard): if data['form']: journal_id = data['form'].get('journal') - period_id = data['form'].get('period') + date = data['form'].get('date') account_id = data['form'].get('account') else: journal_id = False - period_id = False + date = False account_id = False - line_obj.reconcile(cursor, user, data['ids'], journal_id, period_id, + line_obj.reconcile(cursor, user, data['ids'], journal_id, date, account_id, context=context) return {} diff --git a/move.xml b/move.xml index 96a9c034a9..07ec7e5038 100644 --- a/move.xml +++ b/move.xml @@ -287,8 +287,8 @@