How to call a FORM VIEW via a button? (Odoo 13 Enterprise)

500 Views Asked by At

I defined a button via "Server Actions" in this FORM VIEW: enter image description here

And created another FORM VIEW from the submenu. enter image description here

Then I'd tried to call this FORM VIEW via the button, but it's not worked.

So how to call this FORM VIEW via the button?

Please help!

Thank you!

2

There are 2 best solutions below

1
Vishnu VaNnErI On

Try to give

"view_mode" : "form"
0
Farnoush Hosseini On

in xml :

<record id="account_common_report_view" model="ir.ui.view">
    <field name="name">Common Report</field>
    <field name="model">account.common.report</field>
    <field name="arch" type="xml">
    <form string="Report Options">
        <group col="4">
            <header>
                <button name="check_report" string="Print" type="object" 
                       default_focus="1" class="oe_highlight"/>
                <button string="Cancel" class="btn btn-secondary" />
            </header>
        </form>
    </field>
</record>

python : call every things call

def check_report(self):

    self.ensure_one()
    data = {}
    data['ids'] = self.env.context.get('active_ids', [])
    data['model'] = self.env.context.get('active_model', 'ir.ui.menu')
    data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'target_move', 'company_id'])[0]
    used_context = self._build_contexts(data)
    data['form']['used_context'] = dict(used_context, lang=get_lang(self.env).code)
    return self.with_context(discard_logo_check=True)._print_report(data)