Skip to Content
Menu
This question has been flagged
2 Replies
11361 Views

I added a button in crm.lead form in order to create a new object I defined based on the values of the Lead. I successfully can open a form in a popup (target=new) with predefined values (using the context and default_ values). However, there is no Create button showing up, I can therefore not save my new record. Do you know how to add this Create button ? Here is my XML:

<!-- Create Event action -->
        <record id="action_crm_make_event" model="ir.actions.act_window">
          <field name="name">Create Event</field>
          <field name="type">ir.actions.act_window</field>
          <field name="res_model">crm.event.custom</field>
          <field name="view_type">form</field>
          <field name="view_mode">form</field>
          <field name="target">new</field>
       </record>

<!-- Button for creating event based on existing Lead -->

<button string="Create Event" name="%(action_crm_make_event)d" type="action"

                 context="{'default_name': name, ...}"/>

Avatar
Discard
Best Answer

I too faced this problem so i did some Research on this and came up with the solution in view.js file under web module:

at line  384, after "

 action.flags = _.defaults(action.flags || {}, {

            views_switcher : !popup && !inline,
            search_view : !popup && !inline,
            action_buttons : !popup && !inline,
            sidebar : !popup && !inline,
            pager : (!popup || !form) && !inline,
            display_title : !popup,
            search_disable_custom_filters: action.context && action.context.search_disable_custom_filters
        });"

ADD this line: 

"if (popup){
            action.flags.action_buttons = true;
        }"

This will show "save" and "Discard" buttons on 'target:new'.

Hope this will help you.

Avatar
Discard
Best Answer

Hello,

Please add one object button with any name except "create" (prefferable) in the form of "crm.event.custom" and in the method just retun True.

It should save the details of that pop up form.

It will work, try it.

Avatar
Discard
Author

This will add the button in the form of the "crm.event.custom". However, if I go on the form view without coming from the "crm.lead" object", I don't want to see this button, as I am not in a popup mode...