MAKING POP-UP FORM, TRIGERED BY BUTTON
(Action Act Window"ir.actions.act.window")

Prepare The Form

     We create the form first and put it on the action record and menu item.Why? because the form id is called the first time.The form id is called by the action and the action id will be called by the button.If it is not sequential, an error will occur because the id that was called has not been defined. Here we create wizard form, you can use other common form. 

<record model="ir.ui.view" id="wizard_view_wizard">
      <field name="name">text.revision.wizard</field>
      <field name="model">request.wizard</field>
      <field name="arch" type="xml">
        <form string="Insert The Notes!">
          <group>
            <field name="revision_text" required="1" />
          </group>
          <footer>
            <button name="insert_note" type="object" string="Insert Notes" class="oe_highlight" />
          </footer>
        </form>
      </field>
</record>


This is the example view form :


Prepare The Action Act Window

<record model="ir.actions.act_window" id="[ID_THIS_ACTION]"
    
<field name="name">NAME OF ACTION</field>            ==> Name of action
      <field name="type">ir.actions.act_window</field>     ==> Type of action    
      <field name="res_model">MODEL_NAME</field>             ==> Model to present views for
      <field name="view_mode">VIEW_MODE,VIEW_MODE</field>    ==> Viw mode that you want like tree, form, kanban, pivot, etc
      <field name="view_id" ref="ID_VIEW" />                 ==> Reference view id. If view more than one use "view_ids"
      <field name="search_view_id" ref="ID_SEARCH" />        ==> Reference search view
      <field name="target">KIND_TARGET</field>               ==> Full screen mode (fullscreen) or in a dialog/popup (new). Defaults to current.
      <field name="domain">[('FIELD', 'CONDITION', 'FREE_VALUE')]</field> ==> filtering domain to implicitly add to all view search queries
      <field name="context">{'default_FIELD':'FREE_VALUE'}</field> ==> context data to pass to the views
 </record>


The most common action type, used to present visualisations of a model through views: a window action defines a set of view types (and possibly specific views) for a model (and possibly specific record of the model). search_view_id, target, domain, context are optional in action. This example action that you can follow:

 <record model="ir.actions.act_window" id="action_notes_wizard">
      <field name="name">Make Revision Notes</field>
      <field name="type">ir.actions.act_window</field>
      <field name="res_model">request.wizard</field>
      <field name="view_mode">form</field>
      <field name="view_id" ref="my_module.wizard_view_wizard" />
      <field name="target">new</field>
</record>

Making The Button 

    

Make the simple button that call the action is just need name action that call the action id and the action type is 'action' and don't forget string to your button. Example:

 <button name="%(module_name.action_id)d" states="your_state" string="Button_String" type="action" />

You can put the button where you want. If you want the button in the header of the form view (like most submit, send e-mail, share, etc) you simply wrap it within a <header> tag. If you want it somewhere else in the form then don't add the <header> around it. Example:

 <header>
   <button name="%(module_name.action_id)d" string="String_Button" type="action"/>
 </header>


You can also add attributes like groups, attrs, states, etc. This is the Example

<button name="%(my_module.action_notes_wizard)d" states="submit" string="Set to Draft" groups="module_name.my_own_group" type="action" />


name ==> call action that you want, don't forget to use "%( )d"

states ==> This button will be visible when the state value is 'submit'

string ==> This string will be appear in the button

groups ==> This button will be visible if the user has the groups 'my_own_groups

type ==> There is two kind of type (object & action) Object can call function in python and action can call action in xml

Thanks

and

Good Luck

 




Membuat Report Excel Dengan Modul Report XLSX