Skip to Content
Menu
This question has been flagged
1 Reply
28838 Views

I have partner_id field in my current form view and one button in which I pass context like this:- 

<button type="object" name="create_repair" string="Create Repair" context="{'partner_id': partner_id}"/>

In create_repair method, I can get this context like this:-

def create_repair(self, context=None):

form_view = self.env.ref('mrp_repair.view_repair_order_form')

partner = context.get('partner_id')

return {
    'name': 'Repair Order',
    'view_type': 'form',
    'view_mode': 'tree, form',
    'res_model': 'mrp.repair',
    'views': [
        (form_view.id, 'form')
    ],
    'type': 'ir.actions.act_window',
    'context': {'partner_id': partner}
}

In my xml file, I can call like this:-

<field name="partner_id" context="{'partner_id': partner_id}"/>

But I cannot get any option selected.

I want to get value from one form and pass it on another form's field which is many2one field

Please help me to sort out this issue.

​​

Avatar
Discard
Best Answer

Hi,

You can update your code like this,

return {
'name': 'Repair Order',
'view_type': 'form',
'view_mode': 'tree, form',
'res_model': 'mrp.repair',
'views': [
(form_view.id, 'form')
],
'type': 'ir.actions.act_window',
'context': {'default_partner_id': partner}
}


Thanks

Avatar
Discard
Author

It's working!!! Thanks

thank you so much!

Related Posts Replies Views Activity
0
Apr 24
367
4
Oct 18
8321
1
Jan 24
12757
0
Jul 22
1193
3
Sep 20
2121