[FIX/REF] Account : Context handling corrected,cleaning
lp bug: https://launchpad.net/bugs/655793 fixed bzr revid: jvo@tinyerp.com-20101006173826-seoi9hkd52kx5rg6
This commit is contained in:
parent
834f85ab4f
commit
417c87c928
|
@ -1162,32 +1162,36 @@ class account_move(osv.osv):
|
||||||
]
|
]
|
||||||
|
|
||||||
def post(self, cr, uid, ids, context=None):
|
def post(self, cr, uid, ids, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
invoice = context.get('invoice', False)
|
invoice = context.get('invoice', False)
|
||||||
valid_moves = self.validate(cr, uid, ids, context)
|
valid_moves = self.validate(cr, uid, ids, context)
|
||||||
if valid_moves:
|
|
||||||
for move in self.browse(cr, uid, valid_moves):
|
if not valid_moves:
|
||||||
if move.name =='/':
|
raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
|
||||||
new_name = False
|
|
||||||
journal = move.journal_id
|
for move in self.browse(cr, uid, valid_moves):
|
||||||
|
if move.name =='/':
|
||||||
|
new_name = False
|
||||||
|
journal = move.journal_id
|
||||||
|
|
||||||
if invoice and invoice.internal_number:
|
if invoice and invoice.internal_number:
|
||||||
new_name = invoice.internal_number
|
new_name = invoice.internal_number
|
||||||
|
else:
|
||||||
|
if journal.sequence_id:
|
||||||
|
c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
|
||||||
|
new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c)
|
||||||
else:
|
else:
|
||||||
if journal.sequence_id:
|
raise osv.except_osv(_('Error'), _('No sequence defined on the journal !'))
|
||||||
c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
|
|
||||||
new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c)
|
|
||||||
else:
|
|
||||||
raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
|
|
||||||
|
|
||||||
if new_name:
|
if new_name:
|
||||||
self.write(cr, uid, [move.id], {'name':new_name})
|
self.write(cr, uid, [move.id], {'name':new_name})
|
||||||
|
|
||||||
cr.execute('UPDATE account_move '\
|
cr.execute('UPDATE account_move '\
|
||||||
'SET state=%s '\
|
'SET state=%s '\
|
||||||
'WHERE id IN %s',
|
'WHERE id IN %s',
|
||||||
('posted', tuple(valid_moves),))
|
('posted', tuple(valid_moves),))
|
||||||
else:
|
|
||||||
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def button_validate(self, cursor, user, ids, context=None):
|
def button_validate(self, cursor, user, ids, context=None):
|
||||||
|
|
Loading…
Reference in New Issue