How to pass value from def to a view openerp
<p>This is my code: </p>

<pre><code>def view_purchase(self, cr, uid, ids, context=None):
    return {
        'type': 'ir.actions.act_window',
        'name': 'diary_purchase',
        'view_mode': 'form',
        'view_type': 'form',
        'context': "{'name': 'my purchase'}",
        'res_model': 'diaries_purchases',
        'target': 'current',
        'flags': {'form': {'action_buttons': True}}
    }
</code></pre>

<p>I need to send the value "my purchase" to the specific field called name of the view diaries_purchases, i guess by context, but my code not works, thanks for your help</p>

<p>In your destination model (the on you open with your <code>view_purchase()</code> function). Access the context variable <code>self.env.context</code> there you should find your value. You should use a computed or default value on the field <code>name</code>.</p>

<pre><code>def _get_name(self):
    self.name = self.env.context.get('name')

name = fields.char(string="Name",compute=_get_name,store=True)
</code></pre>

python view openerp