This question has been flagged
2 Replies
8503 Views

Hi guys,

I would like to assign an action to the button in "More" menu. I managed to create a button and it opens a form but instead of form i would like to run state change procedure so for example if state is dispatched i want select all of them then open menu and apply action change_state to archived.

 

Avatar
Discard
Best Answer

Dear Dr Obx,

You need to create a wizard and you will select all record from wizard

and also create button inside wizard form view

when press the button at that time state will be change of order which are selected

Using below code you will create action in 'More' menu.

Syntax:

<record model="ir.values" id="any_name">
<field name="model_id" ref="module_name_model_model_name" />
<field name="name">Any String</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('your_action_name'))" />
<field name="key">action</field>
<field name="model">model.name</field>
</record>


Example:

<record model="ir.values" id="wiz_hospital_values">
<field name="model_id" ref="hospital_management.model_patient_patient" />
<field name="name">Wiz Hospital</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_wiz_hospital'))" />
<field name="key">action</field>
<field name="model">patient.patient</field>
</record>

Please let me know, if you have any problem.

Thanks & Regards

Ankit H Gandhi.

Avatar
Discard
Author

Thank you Ankit

Your Welcome !!!

Best Answer

Rob,

On clicking on menu under more, you have to get a form opened as a default functionality of odoo, but u can customize it in your way as:

in the new opened window(of new object) you can use it as a message box and prompt the user to change state by giving some message like;

"You are about to change the state of the selected [your object], Are you sure to continue?"

and then on click of button, you can do your functionality of changing the state  of the recordsw of  your object...

You can get the selected records ids in 'context' of current object(object of which your popped up form is related to) as "active_ids"

There might be some other direct method too, but its one of the way to customize wat you have according to your need.

Regards,    

Pawan

Avatar
Discard
Author

Are you there Pawan ? I need your advice, URGENT!

Yes ROB,...