I added an option (named Confirm partners attendance to the meeting) to the menu More of a tree view (event.meeting.registration tree). If I click on this option, it redirects me to the form named mail.compose.message, which is what I want. Here is my code:
<act_window name="Confirm partners attendance to the meeting"
res_model="mail.compose.message"
src_model="event.meeting.registration"
view_mode="form"
target="new"
id="act_confirm_partners_attendance_to_event_meeting"/>
But, I need to check a condition before opening the form of mail.compose.message. If that condition is True, the form will be opened, if the condition is False, I want to raise an ORM exception.
So, my question is: how can I add an option to the menu More, and when clicking on it, check a condition before doing anything?
Note: I tried to check the condition in the default_get function of the res_model (mail.compose.message), but if the condition is False and the ORM exception is being shown, the form of mail.compose.message is being opened anyway, so when I close the ORM exception, the form is still there. And the right behaviour is that when I close the ORM exception, the form of mail.compose.message must be closed too.
Can anyone help me, please?
EDIT
I'm going to try it through an action server. I don't have any idea of ir.actions.server and the documentation is very poor. I was looking for them in several modules but even so I'm not able to understand them very well.
<record id="my_custom_action" model="ir.actions.server">
<field name="name">My new option</field>
<field name="model_id" ref="??????????"/>
<field name="state">code</field>
<field name="code">my_condition = self.my_event_meeting_registration_function(cr, uid, ids, context)</field>
</record>
<record id="ir_open_mail_compose_message_wizard" model="ir.values">
<field eval="'client_action_multi'" name="key2"/>
<field eval="'event.meeting.registration'" name="model"/>
<field name="name">My new option</field>
<field eval="'ir.actions.server,%d'%my_custom_action" name="value"/>
</record>
Please, correct me if I have anything wrong. What do I have to write in the ref of model_id?