Close the windows itself (Openerp Python Command How)

Asked by John Chen


In Openerp:
Warehouse Management -> Delivery Order :
- When we press the process button, then it open another window box that shows product records, then press the validate button.
Here is the problems, after we press the validate button, the window still shown, it doesn't close itself.

Is there any way to make it close itself?
Or is there any python code that enable it to close itself?

Thanks OpenERP Community.



Question information

English Edit question
Odoo Web Client Edit question
No assignee Edit question
Solved by:
John Chen
Last query:
Last reply:
Revision history for this message
John Chen (john-chen2011) said :

Hey i found it by myself.
It is me or what? This community have become so quiet / silence......

I almost question and answer by myself. OMG!!

Close Code In OpenERP

    def do_partial(self, cr, uid, ids, context=None):
        """ Makes partial moves and pickings done.
        @param self: The object pointer.
        @param cr: A database cursor
        @param uid: ID of the user currently logged in
        @param fields: List of fields for which we want default values
        @param context: A standard dictionary
        @return: A dictionary which of fields with values.
        pick_obj = self.pool.get('stock.picking')
        move_obj = self.pool.get('stock.move')
        location_obj = self.pool.get('stock.location')

        picking_ids = context.get('active_ids', False)
        partial = self.browse(cr, uid, ids[0], context=context)
        partial_datas = {
            'delivery_date' :

        for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
            picking_type = self.get_picking_type(cr, uid, pick, context=context)
            moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out

            for move in moves_list:
                partial_datas['move%s' % (] = {
                    'product_qty': move.quantity,
                    'packaging_qty': move.packaging_qty,
                    'product_packaging': move.product_packaging,
                    'price_packaging': move.price_packaging,
                    'price_unit': move.price_unit,
                if (picking_type == 'in') and (move.product_id.cost_method == 'average'):
                    partial_datas['move%s' % (].update({
                                                    'product_price' : move.cost,
                #Added By: Kusnadi 2011. Recalculate Average Cost Price When Purchase Return --> Stock Picking
                #((amount_unit * product.qty_available)+(new_price*out_qty*-1))/(product.qty_availabe -out_qty)
                if (picking_type == 'out') and (move.product_id.cost_method == 'average'):
                    # Get the standard price
                    product_obj = self.pool.get('product.product')
                    product = product_obj.browse(cr, uid,
                    amount_unit = product.price_get('standard_price', context)[]
                    #raise osv.except_osv(_('Debug !'), _('Amount Unit =' + str(amount_unit) + ' QtyAvailable =' + str(product.qty_available) + ' cost =' + str(move.price_unit) + ' Move Quantity=' + str(move.quantity)))
                    new_std_price = ((amount_unit * product.qty_available)\
                        + (move.price_unit * move.quantity*-1))/(product.qty_available - move.quantity)
                    product_obj.write(cr, uid, [],{'standard_price': new_std_price})

        pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
        return {'type': 'ir.actions.act_window_close'}
Code that make the form able to close it by itself is:
return {'type': 'ir.actions.act_window_close'}