[FIX] account: fixes default journal_id problem in cash satement view.

bzr revid: vra@tinyerp.com-20100927061538-9hllvim57llb3zz9
This commit is contained in:
vra 2010-09-27 11:45:38 +05:30
parent c9219e6765
commit a5b8f7058f
3 changed files with 15 additions and 5 deletions

View File

@ -71,12 +71,10 @@ class account_bank_statement(osv.osv):
journal_pool = self.pool.get('account.journal')
journal_type = context.get('journal_type', False)
journal_id = False
if journal_type:
ids = journal_pool.search(cr, uid, [('type', '=', journal_type)])
if ids:
journal_id = ids[0]
return journal_id
def _default_balance_start(self, cr, uid, context={}):
@ -152,7 +150,7 @@ class account_bank_statement(osv.osv):
'name': fields.char('Name', size=64, required=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself', states={'confirm': [('readonly', True)]}),
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True,
states={'confirm': [('readonly', True)]}, domain=[('type', '=', 'bank')]),
readonly=True, states={'draft':[('readonly',False)]}),
'period_id': fields.many2one('account.period', 'Period', required=True,
states={'confirm':[('readonly', True)]}),
'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'),

View File

@ -203,8 +203,19 @@ class account_cash_statement(osv.osv):
res.append((0,0,dct))
return res
def _default_journal_id(self, cr, uid, context={}):
journal_pool = self.pool.get('account.journal')
journal_type = context.get('journal_type', False)
journal_id = False
if journal_type:
ids = journal_pool.search(cr, uid, [('type', '=', journal_type)])
if ids:
journal_id = ids[0]
return journal_id
_columns = {
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True, domain=[('type', '=', 'cash')]),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True),
'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"),
'state': fields.selection(
[('draft', 'Draft'),
@ -224,6 +235,7 @@ class account_cash_statement(osv.osv):
'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"),
'user_id': lambda self, cr, uid, context=None: uid,
'starting_details_ids':_get_cash_open_box_lines,
'journal_id': _default_journal_id,
'ending_details_ids':_get_default_cash_close_box_lines
}

View File

@ -2488,7 +2488,7 @@
<group col="6" colspan="4">
<field name="name" select="1"/>
<field name="company_id" select="1" groups="base.group_multi_company"/>
<field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('type','=','cash')]" select="1" />
<field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('type','=','cash')]" select="1" widget="selection"/>
<field name="user_id" select="1" readonly="1"/>
<field name="period_id" select="1"/>
<field name="currency" invisible="1"/>