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 to confirm many delivery orders at once? [Resolved]

By
Wided
on 8/28/14, 2:21 AM 1,007 views

I've wrote a custom module to enable confirming selected delivery orders in a list view.

When I use it, I don't get an error but nothing happens  to my orders.

Here's the code: delivery_order_confirm.py

class delivery_order_confirm(osv.osv_memory):
    """
    This wizard will confirm all the selected delivery orders.
    """

    _name = "delivery.order.confirm"
    _description = "Confirm the selected delivery orders"

    def delivery_order_confirm(self, cr, uid, ids, context=None):
        
        if context is None:
            context = {}
        wf_service = netsvc.LocalService('workflow')
        orders = self.pool.get('stock.picking').read(cr, uid,
                                                      context['active_ids'],
                                                      ['state', 'name'],
                                                      context=context)

        for record in orders:
            if not record['state'] == 'draft':
                raise orm.except_orm(_('Warning!'),
                    _("Selected delivery order cannot be confirmed because it isn't in 'Draft' state: %s."
                      %record['name']))
            wf_service.trg_validate(uid, 'stock.picking', record['id'],
                                    'action_confirm', cr)
        return {'type': 'ir.actions.act_window_close'}

delivery_order_confirm()

delivery_order_confirm_view.xml

<openerp>
    <data>

        <record id="delivery_order_confirm_view" model="ir.ui.view">
            <field name="name">delivery.order.confirm.form</field>
            <field name="model">delivery.order.confirm</field>
            <field name="arch" type="xml">
                <form string="Confirm selected delivery orders" version="7.0">
                    <p>Do you want to confirm selected delivery orders?</p>
                    <footer>
                        <button string="Confirm orders" name="delivery_order_confirm" type="object" default_focus="1" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>

 

        <act_window id="action_delivery_order_confirm"
            multi="True"
            key2="client_action_multi" name="Confirm orders"
            res_model="delivery.order.confirm" src_model="stock.picking"
            view_mode="form" target="new" view_type="form" />

    </data>
</openerp>

 

Could you try to select a delivery which is not in Draft State, and see if the error message "WARNING" is triggered ?

Med Said BARA
on 8/28/14, 3:34 AM

Thanks for your answer Med Said, the error message is triggered, I've also added a print line inside this method to be sure that the code is being read, and it's read but not executed :o

Wided
on 8/28/14, 6:41 AM

What do you get in your openerp-server.log?

Med Said BARA
on 8/28/14, 7:47 AM

Thank you very much, it worked!

Wided
on 8/28/14, 9:44 AM
1

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 8/28/14, 10:09 AM

Could you try by changing 'action_confirm' to 'button_confirm'

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

2 follower(s)

Stats

Asked: 8/28/14, 2:21 AM
Seen: 1007 times
Last updated: 3/16/15, 8:10 AM