Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How do I create a custom copy action in the More.. menu of a form?

By
Miku Laitinen
on 5/27/14, 8:54 AM 825 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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/27/14, 8:54 AM
Seen: 825 times
Last updated: 3/16/15, 8:10 AM