~openerp-chinese-team/openobject-addons/7.0-mrp-stock-picking-reference-fix

« back to all changes in this revision

Viewing changes to mrp/mrp.py

  • Committer: JoshuaJan
  • Date: 2013-11-13 02:45:37 UTC
  • Revision ID: popkar77@gmail.com-20131113024537-sq5s0zrdazgu9aax
[fix]mrp module stock.picking refference name

Show diffs side-by-side

added added

removed removed

Lines of Context:
593
593
        """
594
594
        self.write(cr, uid, ids, {'state': 'picking_except'})
595
595
        return True
596
 
    
 
596
 
597
597
    def _action_compute_lines(self, cr, uid, ids, properties=None, context=None):
598
598
        """ Compute product_lines and workcenter_lines from BoM structure
599
599
        @return: product_lines
610
610
        for production in self.browse(cr, uid, ids, context=context):
611
611
            #unlink product_lines
612
612
            prod_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.product_lines], context=context)
613
 
    
 
613
 
614
614
            #unlink workcenter_lines
615
615
            workcenter_line_obj.unlink(cr, SUPERUSER_ID, [line.id for line in production.workcenter_lines], context=context)
616
 
    
 
616
 
617
617
            # search BoM structure and route
618
618
            bom_point = production.bom_id
619
619
            bom_id = production.bom_id.id
623
623
                    bom_point = bom_obj.browse(cr, uid, bom_id)
624
624
                    routing_id = bom_point.routing_id.id or False
625
625
                    self.write(cr, uid, [production.id], {'bom_id': bom_id, 'routing_id': routing_id})
626
 
    
 
626
 
627
627
            if not bom_id:
628
628
                raise osv.except_osv(_('Error!'), _("Cannot find a bill of material for this product."))
629
 
    
 
629
 
630
630
            # get components and workcenter_lines from BoM structure
631
631
            factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_point.product_uom.id)
632
632
            res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id)
633
633
            results = res[0] # product_lines
634
634
            results2 = res[1] # workcenter_lines
635
 
    
 
635
 
636
636
            # reset product_lines in production order
637
637
            for line in results:
638
638
                line['production_id'] = production.id
639
639
                prod_line_obj.create(cr, uid, line)
640
 
    
 
640
 
641
641
            #reset workcenter_lines in production order
642
642
            for line in results2:
643
643
                line['production_id'] = production.id
681
681
                produce_move_id = self._make_production_produce_line(cr, uid, production, context=context)
682
682
                for scheduled in production.product_lines:
683
683
                    self._make_production_line_procurement(cr, uid, scheduled, False, context=context)
684
 
        
 
684
 
685
685
            if production.move_prod_id and production.move_prod_id.location_id.id != production.location_dest_id.id:
686
686
                move_obj.write(cr, uid, [production.move_prod_id.id],
687
687
                        {'location_id': production.location_dest_id.id})
884
884
 
885
885
    def _get_auto_picking(self, cr, uid, production):
886
886
        return True
887
 
    
 
887
 
888
888
    def _hook_create_post_procurement(self, cr, uid, production, procurement_id, context=None):
889
889
        return True
890
890
 
955
955
            partner_id = routing_loc.partner_id and routing_loc.partner_id.id or False
956
956
 
957
957
        # Take next Sequence number of shipment base on type
958
 
        pick_name = ir_sequence.get(cr, uid, 'stock.picking.' + pick_type)
 
958
        pick_name = ir_sequence.get(cr, uid, 'stock.picking' + (pick_type != 'internal' and '.' + pick_type or '' ))
959
959
 
960
960
        picking_id = stock_picking.create(cr, uid, {
961
961
            'name': pick_name,