This question has been flagged
4601 Views

I have two copy methods for a sales quotation. One that copies the quotation without fields called external_ref and external_version and one that creates a new version of the quotation by sparing the external_ref and dropping the external_version.

When I use normal buttons in the quotation form, this solution works exactly as intended.

The problem is that I don't want the buttons to be located in the toolbar of the form. Mainly because there are already 4 buttons (in the draft state) and I don't want to confuse the users by putting one copy action in the toolbar and another (the default) in the 'More...' menu. So, I want the "Create a new version" action under the More... menu.

Here's something I got working.. almost:

<record id="ir_server_action_quotation_new_version" model="ir.actions.server">
            <field name="name">Create a new version of a quotation</field>
            <field name="type">ir.actions.server</field>
            <field name="model_id" ref="model_sale_order"/>
            <field name="state">code</field>
            <field name="code">self.new_version(cr, uid, context.get('active_ids'), context=context)</field>
</record>
<record id="ir_quotation_new_version" model="ir.values">
            <field name="name">Create New Version</field>
            <field name="action_id" ref="ir_server_action_quotation_new_version"/>
            <field name="value" eval="'ir.actions.server,' + str(ref('ir_server_action_quotation_new_version'))"/>
            <field name="key">action</field>
            <field name="model_id" ref="model_sale_order"/>
            <field name="model">sale.order</field>
            <field name="key2">client_action_multi</field>
</record>

So I got the "new version" action in the More... menu, but two problems remain:

  1. The new version action is visible in the tree view, and I only want it to be visible in the form
  2. A new version of the quotation is created as intended, but the browser doesn't navigate to the newly created quotation's form view (probably because the action is a server action)

The "new version" action should be visible whenever the default "copy" action is. And it must perform just like the copy action, only calling a different method.

Avatar
Discard