Skip to Content
Menu
This question has been flagged
6603 Zobrazenia

Hello everyone...

Lately I've been trying to open a wizard from the leads form view using a button. What I want to do is the user to specify certain data in the fields that will appear in the wizard, but when 'saving' the data, it goes to the create method of the crm.lead model. 

I understand that with context in the window action I can define the current record, but I've tried setting parent_obj, res_id, default_res_id, current_id, and active_id as self.id; as you can see here:

 @api.multi
    def startup_template_act(self):
        action_vals = {
            'type':'ir.actions.act_window',
            'name':'Startup template form',
            'view_mode':'form',
            'view_type':'form',
            'target':'new',
            'res_model':'crm.lead',
            'views': [(self.env.ref('bca-11_0-crm-geh.bca_startup_template_form').id, 'form')],
            'view_id': self.env.ref('bca-11_0-crm-geh.bca_startup_template_form').id,
            'context': {'current_id':self.id, 'default_model': 'crm.lead'}
        }
        return action_vals

These are my XML button and my form view:

XML BUTTON (INSIDE THE LEADS FORM)

<button class="oe_highlight" name="startup_template_act" type="object" string="Start up"/> 

FORM VIEW
<record model="ir.ui.view" id="bca_startup_template_form">
          <field name="name">bca.startup_template.form</field>
          <field name="model">crm.lead</field>
          <field name="type">form</field>
          <field name="arch" type="xml">
              <group>
                  <form string="Startup email">
                      <field name="name"></field>
                      <field name="mail_template_partner_1" string="Project manager"></field>
                  </form>
              </group>
              <footer>
                <button string="Send" name="send_startup_mail" type="object" class="btn-primary"/>
                <button string="Cancel" class="btn-default" special="cancel"/>
              </footer>
          </field>
      </record>

I've tried a lot of possible solutions but nothing works as I expected. Some help would be really good. Thanks in advance.

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
aug 17
3468
0
mar 15
4495
1
feb 24
3131
2
júl 22
11526
1
apr 21
13070