跳至內容
選單
此問題已被標幟
1 回覆
30786 瀏覽次數

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.

​​

頭像
捨棄
最佳答案

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

頭像
捨棄
作者

It's working!!! Thanks

thank you so much!

相關帖文 回覆 瀏覽次數 活動
0
4月 24
1421
4
10月 18
9389
1
1月 25
1410
1
1月 24
14366
0
7月 22
2464