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

I have a button in a form, that calls an object method returning a Window Action dictionary.

Clicking on it, it opens a new form, as desired. This form opens in View mode.

Is it possible to make it open in Edit mode ?

頭像
捨棄
最佳答案

Hi,

Pass form_view_initial_mode as edit in the context.

Sample:

def action_duplicate(self):
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id("account.action_move_journal_line")
action['context'] = dict(self.env.context)
action['context']['form_view_initial_mode'] = 'edit'
action['context']['view_no_maturity'] = False
action['views'] = [(self.env.ref('account.view_move_form').id, 'form')]
action['res_id'] = self.copy().id
return action

See: How To Open Form View In Edit Mode From Python Code Odoo

Thanks

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
3月 15
4306
3
3月 15
5949
8
5月 16
33984
1
5月 15
4025
1
3月 15
17824