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.

2

How to add a button in the seletions "More" [Closed]

By
CK
on 3/20/13, 12:03 AM 6,797 views

The Question has been closed

by
Sudhir Arya (SA)
on 04/18/2013 05:04:21

Hi,It is in the sale module, and I want to add a button "confirm sale" , I find the code in the saly.py :

def action_button_confirm(self, cr, uid, ids, context=None):
    assert len(ids) == 1,

This option should only be used for a single id at a time.'

wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)

# redisplay the record as a sales order
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
view_id = view_ref and view_ref[1] or False,
return {
    'type': 'ir.actions.act_window',
    'name': _('Sales Order'),
    'res_model': 'sale.order',
    'res_id': ids[0],
    'view_type': 'form',
    'view_mode': 'form',
    'view_id': view_id,
    'target': 'current',
    'nodestroy': True,
}`

and I also find the action button Make invoices in the wizard/sale_make_invoice:

<record id="view_sale_order_make_invoice" model="ir.ui.view">
    <field name="name">Create invoices</field>
    <field name="model">sale.make.invoice</field>
    <field name="arch" type="xml">
        <form string="Create invoices" version="7.0">
            <header>
                <button name="make_invoices" string="Create Invoices" type="object" class="oe_highlight"  />
                or
                <button string="Cancel" class="oe_link" special="cancel" />
            </header>
            <separator colspan="4" string="Do you really want to create the invoice(s)?" />
            <group>
                <field name="grouped"/>
                <field name="invoice_date"/>
            </group>
       </form>
    </field>
</record>

I try some methods to add the button , but there are all failure....

the button i want to add like this : postimage.org/image/v6smmnea5/

thanks

Will you please specify what you really want to do? Do you want to add button in view or something else?

Sudhir Arya (SA)
on 3/20/13, 1:21 AM

I want to add a exist button named "confirm sale" in view, and i have find the code of it ...

CK
on 3/20/13, 1:34 AM

Do you want multiple order confirm from quotation Tree View ????

Parth Gajjar
on 3/20/13, 2:09 AM

i cant upload my image , and i want to add the button like this http://postimage.org/image/v6smmnea5/

CK
on 3/20/13, 2:58 AM
3

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 3/20/13, 3:05 AM

You need to create a wizard and then create <act_window action.

<act_window
    id="act_window_id"
    name="Confirm Sale"
    src_model="wizard_objec_name"
    res_model="sale.order"
    view_id="your_wizard_form_view_id"/>

act_window will add action in "More" as you needed.

actually, i delete the exist <act_window id="action_order_line_product_tree"........> And i find the button "Make invoice" is still in "More"......

CK
on 3/20/13, 5:09 AM

the answer is in: http://help.openerp.com/question/7468/why-cant-i-make-a-button-in-tree/

CK
on 3/26/13, 10:42 PM
2
Nimesh Contractor
On 3/20/13, 2:11 AM

make a action having <field name="multi">True</field>

0
CK
On 3/20/13, 4:37 AM

Thanks for answer, but i am not very clearly how to do it . i find a act_window exist in sale_view.xml:

        <act_window
        context="{'search_default_product_id': active_id, 'default_product_id': active_id}"
        id="action_order_line_product_tree"
        name="Sales Order Lines"
        res_model="sale.order.line"
        src_model="product.product"
        groups="base.group_sale_salesman"/>

i think this is the action "make invoices" in "More", but i dont know why it wirte like this.

And I know the code of button "confirm sale" ,its in sale_view.xml:

        <record id="view_order_form" model="ir.ui.view">
        <field name="name">sale.order.form</field>
        <field name="model">sale.order</field>
        <field name="arch" type="xml">
            <form string="Sales Order" version="7.0">
                <header>
                    <button name="invoice_recreate" states="invoice_except" string="Recreate Invoice" groups="base.group_user"/>
                    <button name="invoice_corrected" states="invoice_except" string="Ignore Exception" groups="base.group_user"/>
                    <button name="action_quotation_send" string="Send by Email" type="object" states="draft" class="oe_highlight" groups="base.group_user"/>
                    <button name="action_quotation_send" string="Send by Email" type="object" states="sent" groups="base.group_user"/>
                    <button name="print_quotation" string="Print" type="object" states="draft" class="oe_highlight" groups="base.group_user"/>
                    <button name="print_quotation" string="Print" type="object" states="sent" groups="base.group_user"/>
                    <button name="action_button_confirm" states="draft" string="Confirm Sale" type="object" groups="base.group_user"/>
                    <button name="action_button_confirm" states="sent" string="Confirm Sale" class="oe_highlight" type="object" groups="base.group_user"/>…………

Can i use it directly? Thanks.....

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 3/20/13, 12:03 AM
Seen: 6797 times
Last updated: 3/16/15, 8:10 AM