[FIX] account: improved the code and also assigned ctx to context argument for def action_move_create in account/account_invoice.py

bzr revid: bde@tinyerp.com-20111221101236-4xppp8v82db84oq3
This commit is contained in:
Bharat Devnani (OpenERP) 2011-12-21 15:42:36 +05:30
parent 657183237a
commit 9b66690af2
1 changed files with 6 additions and 7 deletions

View File

@ -804,20 +804,19 @@ class account_invoice(osv.osv):
move_obj = self.pool.get('account.move')
if context is None:
context = {}
ctx = context.copy()
for inv in self.browse(cr, uid, ids, context=ctx):
for inv in self.browse(cr, uid, ids, context=context):
if not inv.journal_id.sequence_id:
raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal'))
if not inv.invoice_line:
raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.'))
if inv.move_id:
continue
ctx = context.copy()
ctx.update({'lang': inv.partner_id.lang})
if not inv.date_invoice:
self.write(cr, uid, [inv.id], {'date_invoice':time.strftime('%Y-%m-%d')}, context=ctx)
company_currency = inv.company_id.currency_id.id
ctx.update({'lang': inv.partner_id.lang})
# create the analytical lines
# one move line per invoice line
iml = self._get_analytic_lines(cr, uid, inv.id, context=ctx)
@ -911,7 +910,7 @@ class account_invoice(osv.osv):
date = inv.date_invoice or time.strftime('%Y-%m-%d')
part = inv.partner_id.id
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=context)),iml)
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=ctx)),iml)
line = self.group_lines(cr, uid, iml, line, inv)
@ -940,7 +939,7 @@ class account_invoice(osv.osv):
for i in line:
i[2]['period_id'] = period_id
move_id = move_obj.create(cr, uid, move, context=context)
move_id = move_obj.create(cr, uid, move, context=ctx)
new_move_name = move_obj.browse(cr, uid, move_id).name
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}, context=ctx)