Use the start date of the period by default for account move line

bzr revid: ced-caaccf4aa21d318635842ca1f67f4cfe29701d93
This commit is contained in:
ced 2007-11-26 15:45:46 +00:00
parent 21f9d54b28
commit 80a9af32db
1 changed files with 17 additions and 3 deletions

View File

@ -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,