[FIX] account: proper handling of context in encoding by line
bzr revid: qdp-launchpad@openerp.com-20111114113405-c3oyzuw369rz7y0r
This commit is contained in:
parent
fc1375a782
commit
83e4168a03
|
@ -1084,8 +1084,6 @@ class account_move_line(osv.osv):
|
||||||
f.set("invisible", "context.get('journal_id', False)")
|
f.set("invisible", "context.get('journal_id', False)")
|
||||||
elif field in ('period_id',):
|
elif field in ('period_id',):
|
||||||
f.set("invisible", "context.get('period_id', False)")
|
f.set("invisible", "context.get('period_id', False)")
|
||||||
else:
|
|
||||||
f.set('invisible', "context.get('visible_id') not in %s" % (fields.get(field)))
|
|
||||||
|
|
||||||
orm.setup_modifiers(f, fields_get[field], context=context,
|
orm.setup_modifiers(f, fields_get[field], context=context,
|
||||||
in_tree_view=True)
|
in_tree_view=True)
|
||||||
|
@ -1245,6 +1243,12 @@ class account_move_line(osv.osv):
|
||||||
m = move_obj.browse(cr, uid, vals['move_id'])
|
m = move_obj.browse(cr, uid, vals['move_id'])
|
||||||
context['journal_id'] = m.journal_id.id
|
context['journal_id'] = m.journal_id.id
|
||||||
context['period_id'] = m.period_id.id
|
context['period_id'] = m.period_id.id
|
||||||
|
#we need to treat the case where a value is given in the context for period_id as a string
|
||||||
|
if 'period_id' not in context or not isinstance(context.get('period_id', ''), (int, long)):
|
||||||
|
period_candidate_ids = self.pool.get('account.period').name_search(cr, uid, name=context.get('period_id',''))
|
||||||
|
if len(period_candidate_ids) != 1:
|
||||||
|
raise osv.except_osv(_('Encoding error'), _('No period found or period given is ambigous.'))
|
||||||
|
context['period_id'] = period_candidate_ids[0][0]
|
||||||
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
|
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
|
||||||
move_id = vals.get('move_id', False)
|
move_id = vals.get('move_id', False)
|
||||||
journal = journal_obj.browse(cr, uid, context['journal_id'], context=context)
|
journal = journal_obj.browse(cr, uid, context['journal_id'], context=context)
|
||||||
|
|
|
@ -1235,8 +1235,8 @@
|
||||||
</group>
|
</group>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group>
|
<group>
|
||||||
<field name="journal_id" widget="selection" context="{'journal_id':self, 'visible_id':self, 'normal_view':False}"/>
|
<field name="journal_id" widget="selection" context="{'journal_id':self}"/>
|
||||||
<field name="period_id" context="{'period_id':self, 'search_default_period_id':self}"/>
|
<field name="period_id" context="{'period_id':self}"/>
|
||||||
</group>
|
</group>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group expand="0" string="Group By...">
|
<group expand="0" string="Group By...">
|
||||||
|
|
|
@ -188,7 +188,7 @@ class account_move_journal(osv.osv_memory):
|
||||||
'view_mode': 'tree,graph,form',
|
'view_mode': 'tree,graph,form',
|
||||||
'res_model': 'account.move.line',
|
'res_model': 'account.move.line',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'context': "{'search_default_posted': %d, 'visible_id':%s, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (move, journal_id, journal_id, period_id),
|
'context': "{'search_default_posted': %d, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (move, journal_id, period_id),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'search_view_id': res_id
|
'search_view_id': res_id
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue