Fix ref in account move line from invoice and some indentations
bzr revid: ced-4b6e27000c37b0b778547184721cd48e964a046a
This commit is contained in:
parent
04f86677c9
commit
9a16ee5f8a
|
@ -70,7 +70,8 @@ class account_move_line(osv.osv):
|
|||
account_move_line \
|
||||
where \
|
||||
journal_id=%d and period_id=%d and create_uid=%d and state=%s \
|
||||
order by id desc limit 1', (context['journal_id'], context['period_id'], uid, 'draft'))
|
||||
order by id desc limit 1',
|
||||
(context['journal_id'], context['period_id'], uid, 'draft'))
|
||||
res = cr.fetchone()
|
||||
move_id = (res and res[0]) or False
|
||||
if not move_id:
|
||||
|
@ -82,7 +83,9 @@ class account_move_line(osv.osv):
|
|||
from \
|
||||
account_move_line \
|
||||
where \
|
||||
journal_id=%d and period_id=%d and create_uid=%d order by id desc', (context['journal_id'], context['period_id'], uid))
|
||||
journal_id=%d and period_id=%d and create_uid=%d \
|
||||
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')
|
||||
|
||||
|
|
|
@ -508,17 +508,27 @@ class account_invoice(osv.osv):
|
|||
}
|
||||
|
||||
def action_number(self, cr, uid, ids, *args):
|
||||
cr.execute('SELECT id, type, number, move_id, reference FROM account_invoice WHERE id IN ('+','.join(map(str,ids))+')')
|
||||
cr.execute('SELECT id, type, number, move_id, reference ' \
|
||||
'FROM account_invoice ' \
|
||||
'WHERE id IN ('+','.join(map(str,ids))+')')
|
||||
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
||||
if not number:
|
||||
number = self.pool.get('ir.sequence').get(cr, uid, 'account.invoice.'+invtype)
|
||||
number = self.pool.get('ir.sequence').get(cr, uid,
|
||||
'account.invoice.' + invtype)
|
||||
if type in ('in_invoice', 'in_refund'):
|
||||
ref = reference
|
||||
else:
|
||||
ref = self._convert_ref(cr, uid, number)
|
||||
cr.execute('UPDATE account_invoice SET number=%s WHERE id=%d', (number, id))
|
||||
cr.execute('UPDATE account_move_line SET ref=%s WHERE move_id=%d and ref is null', (ref, move_id))
|
||||
cr.execute('UPDATE account_analytic_line SET ref=%s FROM account_move_line WHERE account_move_line.move_id=%d AND account_analytic_line.move_id=account_move_line.id', (ref, move_id))
|
||||
cr.execute('UPDATE account_invoice SET number=%s ' \
|
||||
'WHERE id=%d', (number, id))
|
||||
cr.execute('UPDATE account_move_line SET ref=%s ' \
|
||||
'WHERE move_id=%d AND (ref is null OR ref = \'\')',
|
||||
(ref, move_id))
|
||||
cr.execute('UPDATE account_analytic_line SET ref=%s ' \
|
||||
'FROM account_move_line ' \
|
||||
'WHERE account_move_line.move_id = %d ' \
|
||||
'AND account_analytic_line.move_id = account_move_line.id',
|
||||
(ref, move_id))
|
||||
return True
|
||||
|
||||
def action_cancel(self, cr, uid, ids, *args):
|
||||
|
|
Loading…
Reference in New Issue