This question has been flagged
3 Replies
5031 Views

hello everyone

I'm following a tutorial  to create a button to open a form from another model using type="action" button but when i lick on the button it loads for second and nothing happens and there is no errors

this is  the button :

<button class="oe_stat_button" name="%(open_patient_appointment)d" type="action"
icon="fa-usd">
<field string="Appointment" name="appointments_count" widget="statinfo"/>
</button>

the code of the action :

<record id="open_patient_appointment" model="ir.actions.act_window">
<field
name="name">Appointments</field>
<field
name="type">ir.actions.act_window</field>
<field
name="res_model">hospital.appointment</field>
<field
name="view_mode">tree,form</field>
<field
name="domain">[('patient_id','='active_id)]</field>
</record>

Avatar
Discard
Best Answer

Hello Mahmoud Ibrahim, 

Actually inside action you also needs to define module name along with action id

<button class="oe_stat_button" name="%(module_name.open_patient_appointment)d" type="action">
    <field string="Appointment" name="appointments_count" widget="statinfo"/>
</button>

And you can also update the action

<record id="open_patient_appointment" model="ir.actions.act_window">
    <field name="name">Appointments</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">hospital.appointment</field>
    <field name="view_mode">tree,form</field>
    <field name="domain">[('patient_id','='active_id)]</field>
     <field name="target">new</field>
</record>

Thanks

Anisha Bahukhandi

Avatar
Discard
Best Answer

Kindly check access file if added access for the model ( security > ir.model.access.csv )

Avatar
Discard
Author Best Answer

Hello Anisha, thank you for your reply


I updated the


button to :

 <button class="oe_stat_button" name="%(Hospital.open_patient_appointment)d" type="action"

                                icon="fa-usd">

                            <field string="Appointment" name="appointments_count" widget="statinfo"/>

                        </button>


and the class to :


<record id="open_patient_appointment" model="ir.actions.act_window">

        <field name="name">Appointments</field>

        <field name="type">ir.actions.act_window</field>

        <field name="res_model">hospital.appointment</field>

        <field name="view_mode">tree,form</field>

        <field name="domain">[('patient_id','='active_id)]</field>

        <field name="target">new</field>

    </record>


and upgraded the module with no errors but unfortunately it's still the same issue


update :

i found out the issue while learning similar task it was in line:

    <field name="domain">[('patient_id','='active_id)]</field>

it's missing a , after  the '='

Avatar
Discard

Oh I got it

The issue is with the domain line, Kindly replace the domain line with the below line

<field name="domain">[('patient_id', '=', active_id)]</field>