From 80a9af32dbd8dd2f14a18cd37a5c5424e1a9afbe Mon Sep 17 00:00:00 2001 From: ced <> Date: Mon, 26 Nov 2007 15:45:46 +0000 Subject: [PATCH] Use the start date of the period by default for account move line bzr revid: ced-caaccf4aa21d318635842ca1f67f4cfe29701d93 --- addons/account/account_move_line.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index a20a81948af..1bf889a65be 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -60,6 +60,8 @@ class account_move_line(osv.osv): if not 'move_id' in fields: #we are not in manual entry return data + period_obj = self.pool.get('account.period') + # Compute the current move move_id = False partner_id = False @@ -87,7 +89,12 @@ class account_move_line(osv.osv): order by id desc', (context['journal_id'], context['period_id'], uid)) res = cr.fetchone() - data['date'] = res and res[0] or time.strftime('%Y-%m-%d') + if res: + data['date'] = res[0] + else: + period = period_obj.browse(cr, uid, context['period_id'], + context=context) + data['date'] = period.date_start total = 0 ref_id = False @@ -204,13 +211,20 @@ class account_move_line(osv.osv): 'tax_amount': fields.float('Tax/Base Amount', digits=(16,2), select=True), } def _get_date(self, cr, uid, context): + period_obj = self.pool.get('account.period') dt = time.strftime('%Y-%m-%d') if ('journal_id' in context) and ('period_id' in context): - cr.execute('select date from account_move_line where journal_id=%d and period_id=%d order by id desc limit 1',\ - (context['journal_id'], context['period_id'])) + cr.execute('select date from account_move_line ' \ + 'where journal_id=%d and period_id=%d ' \ + 'order by id desc limit 1', + (context['journal_id'], context['period_id'])) res = cr.fetchone() if res: dt = res[0] + else: + period = period_obj.browse(cr, uid, context['period_id'], + context=context) + dt = period.date_start return dt _defaults = { 'blocked': lambda *a: False,