[FIX] Account: [trunk][account_cancel] error when saving journal settings (general account journal view and in the write method)

lp bug: https://launchpad.net/bugs/681272 fixed

bzr revid: mra@mra-laptop-20101214110437-dflw8j6sn3cys097
This commit is contained in:
Salvi Angjeli 2010-12-14 16:34:37 +05:30 committed by Mustufa Rangwala
parent fd7a65d142
commit 48d4d8b4a3
1 changed files with 8 additions and 5 deletions

View File

@ -631,10 +631,13 @@ class account_journal(osv.osv):
return super(account_journal, self).copy(cr, uid, id, default, context=context)
def write(self, cr, uid, ids, vals, context=None):
if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)])
if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines'))
if context is None:
context = {}
for journal in self.browse(cr, uid, ids, context=context):
if 'company_id' in vals and journal.company_id.id != vals['company_id']:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)])
if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines'))
return super(account_journal, self).write(cr, uid, ids, vals, context=context)
def create_sequence(self, cr, uid, vals, context=None):
@ -726,7 +729,7 @@ class account_journal(osv.osv):
res = {}
view_id = type_map.get(type, 'general')
view_id = type_map.get(type, 'account_journal_view')
user = user_pool.browse(cr, uid, uid)
if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency: