콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
15935 화면

Dear all,

Happy new year for all of you.

I am using Odoo 12 and have a form view with a button that executes a specific code.

Now, I need to close the form view and open the tree view after the code is executed.

What I have:

On the model:

    @api.multi
    def button_click(self, vals):
        #some code here

On the xml (form view):

    <record id="myform_view_id" model="ir.ui.view">
    <field name="name">mymodel.myform.name</field>
    <field name="model">mymodel</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
    <form>
        <header>
            <button string="Click Here" name="button_click" type="object" class="oe_highlight"/>
        </header>
            <!-- FORM DATA GOES HERE -->
    </form>
    </field>
    </record>

How can I close this form view and open the same model tree view (already defined) after user click on the "button_click"?

Thank you all in advance

Best regards

PM

아바타
취소
베스트 답변

Hi,

You can return something like this from the button action,

return {
'name': _('test'),
'view_type': 'tree',
'view_mode': 'tree',
'view_id': self.env.ref('account.invoice_tree').id,
'res_model': 'account.invoice',
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window',
'target': 'new',
}

Thanks

아바타
취소
작성자

Thank you @Niyas Raphy,

Problem solved.

베스트 답변

This works for me in Odoo 12:

...
tree_view = {
'name': _('Activities'),
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'mail.activity',
'type': 'ir.actions.act_window',
'target': 'main',
}
return tree_view
아바타
취소
관련 게시물 답글 화면 활동
1
6월 22
12975
2
3월 20
7092
2
12월 19
6825
0
1월 19
5604
0
3월 17
4045