twenger,

I'm building a module that depends on such behavior. Essentially you mimics the 
rpc client by calling the pool.execute_cr or pool.exec_workflow_cr methods. 
Check the code below:


            import pooler
            pool = 
pooler.get_pool(db_name)
            
            # We listen for xml messages, so we 
call a method to
            # convert the xml into a vals 
dictionary
            (action, oid, vals) = 
pool.execute_cr(cr, uid,  'sale.order', 'from_xml', message)
            
            #CREATE - if the message refers to a 
new sales order
            if action == 0: 
                log.debug("consume 
sale order: (create, %s)" % str(vals))
                oid = 
pool.execute_cr(cr, uid,  'sale.order', 'create', vals, 
{'mbi_propagate':False})
            
            #UPDATE
            elif action == 1: 
                ids = [oid]
                log.debug("consume 
sale order: (write, %s, %s)" % 
(str(ids),str(vals)))
                pool.execute_cr(cr, 
uid,  'sale.order', 'write', ids, vals, 
{'mbi_propagate':False})
            
            else:
                
log.debug(message)
                raise 
Exception('Action not implemented: %s' % action)
            
            # Start sale's workflow
            pool.exec_workflow_cr(cr, uid, 
'sale.order', 'order_confirm', oid)
            
            # Locate picking order
            pic_ids = pool.execute_cr(cr, 
uid, 'sale.order', 'read', [oid], 
['picking_ids'])[0]['picking_ids']
            
            # Assing products
            print 'pic_ids = %s' % 
str(pic_ids)
            pool.execute_cr(cr, uid, 
'stock.picking', 'force_assign', pic_ids)
            
            # Finish workflow - should create a 
new invoice automagically
            for pick_id in pic_ids:
                
pool.exec_workflow_cr(cr, uid, 'stock.picking', 'button_done', pick_id)
            
            # Fetch invoice ID
            inv_ids = pool.execute_cr(cr, 
uid, 'sale.order', 'read', [oid], 
['invoice_ids'])[0]['invoice_ids']
            
            # Confirm invoices
            for invoice_id in inv_ids:
                
pool.exec_workflow_cr(cr, uid, 'account.invoice', 'invoice_open', 
invoice_id)




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=48690#48690

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to