Odoo Help


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.


How can I confirm sale with many ids a time

on 3/25/13, 4:10 AM 2,049 views

This is the confirm sale code :

    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,

It write "assert len(ids) == 1, 'This option should only be used for a single id at a time.'"

So how can I change it , then I can do it with many ids at a time. I try to delete this sentence, but it doesn't work. Should I change the "return" and "ids[0]"as well ?

if you change the return ids[0] to ids then it will give you trace-back, because it gives ids in list and in form view it will give you [oneid] thats y they pass ids[0]

Nimesh Contractor
on 3/25/13, 4:40 AM
Sreedath Namangalam
On 5/23/13, 9:52 AM

image description

Hi Sreedath Please can you help me with this I am having trouble implementing this code. Thank you

on 8/12/13, 1:28 PM
On 3/25/13, 5:17 AM

I try to write like this :

for id in context.get(('active_ids'), []):
        wf_service.trg_validate(uid, 'sale.order', id, 'order_confirm', cr)

but it also can't work as I want...

Is any doc about wf_service.trg_validate(),wf_service = netsvc.LocalService('workflow')? I find that if i write like this :

    def action_button_confirm(self, cr, uid, ids, context=None):
        wf_service = netsvc.LocalService('workflow')        
        return  True

It also can wok....

Hi CK were you able to fix the the problem with this? I also need something like this please kindly help.

on 8/14/13, 8:20 AM

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

0 follower(s)


Asked: 3/25/13, 4:10 AM
Seen: 2049 times
Last updated: 7/15/16, 2:54 AM