This question has been flagged

Hello, I have a custom module and I need it to open a custom form view depending on which line is selected from the list.  I made three menu items which filter the licenses based on the type of license it is. This is what I have so far:

Menu items:

  1. Temporary Licenses: Filters for temporary licenses and opens the regular licenses form view
  2. Permanent Licenses: Filters for permanent licenses and opens the regular licenses form view
  3. Stand Alone Licenses: Filters for stand alone licenses and needs to open a custom form view

Numbers 1 and 2 are just read only forms, and cant create or edit anything on them.  Number 3 I need to be able to create and edit records through a custom form view.  Can I call another form view based on the type of item from the filtered Licenses list and how?  Thank you

Avatar
Discard
Best Answer

You can pass the parameter view_id in your action definition. Define two actions and assign the first one to the first 2 menu elements, and the second one (the one with view_id defined to be the id of your custom form view) to the third menu element.

Menus and actions

Avatar
Discard
Author Best Answer

Thank you Leonardo for your reply. I did what you suggested and it worked. However when the form opens, it is in the create/new mode where it thinks you are creating a new record. Is there a way to display the tree view first, then the form once the red Create button is clicked? Here is my action if it helps at all

 

<record id="action_view_stand_alone_licenses" model="ir.actions.act_window"> <field name="name">Stand Alone License</field> <field name="res_model">sale.licenses</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="view_id" ref="view_stand_alone_license_form"/> <field name="search_view_id" ref="view_licenses_search"/> <field name="context">{"search_default_stand_alone_lic": 1, }</field> </record>

Avatar
Discard
Author

Thank you Leonardo for your reply. I did what you suggested and it worked. However when the form opens, it is in the create/new mode where it thinks you are creating a new record. Is there a way to display the tree view first, then the form once the red Create button is clicked? Here is my action if it helps at all Stand Alone Licensesale.licensesformtree,form{"search_default_stand_alone_lic": 1, }

Best Answer


As mentioned you can change or pass a view_id , id of your action.You can remove create and edit attr on the form or create another form . Hope it helps

<record model="ir.ui.view" id="search_filter_id">
            <field name="name">name</field>
            <field name="model">model</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search String">
                
                    <filter name="temporary" string="In-Patient" domain="[('temporary','=',True)]"/>
                    <filter name="permanent" string="Out-Patient" domain="[('permanent','=',True)]"/>
                    
                </search>
            </field>
        </record>
            
    
        <record model="ir.ui.view" id="custom_tree_view">
            <field name="name">name</field>
            <field name="model">model</field>    
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="custom string" version="7.0">
                    <!--fields here-->
                </tree>
            </field>
        </record>
        
        <record model="ir.ui.view" id="custom_form_view">
            <field name="name">name</field>
            <field name="model">model</field>    
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="custom string" version="7.0" create="false" edit="false">
                    <!--fields here-->
                </form>
            </field>
        </record>
    
        <record model="ir.actions.act_window" id="action_custom_view">
            <field name="name">name</field></field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">model</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
        
            <field name="view_id" ref="custom_form_view" />    
        </record>
        
        <record model="ir.actions.act_window" id="action_temporary_view">
            <field name="name">name</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">model</field>
            <field name="view_type">form</field>
            <field name="context">{"search_default_temporary":True}</field>
            <field name="view_id" ref="custom_tree_view" />    
        </record>
        
        <record model="ir.actions.act_window" id="action_permanent_view">
            <field name="name">name</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">model</field>
            <field name="view_type">form</field>
    
            <field name="context">{"search_default_permanent":True}</field>
            <field name="view_id" ref="custom_tree_view" />

        <menuitem action="action_permanent_view" id="1"   sequence="1" />        
        <menuitem action="action_temporary_view" id="2" sequence="2"/>
        <menuitem action="action_custom_view" id="3" parent="billing_soa"  sequence="3" />

 

Avatar
Discard