Help

0

Odoo 9 how to create a stock picking with product lot filled

Avatar
Nabil

Hi ,

i have this code below for creating picking programmatically but the picking is created without the information about product lot !

how i can do that

best regards


     for line in record.lines_ids:
                picking_lines.append((0, 0, {
                    'product_id': line.product_id.id,
                    'lot_id': line.lot_id.id,
                    'product_uom': line.product_uom_id.id,
                    'company_id': self.env.user.company_id.id,
                    'name': line.product_id.name,
                    'id_dd_line': line.id,
                    'product_uom_qty': line.qte * 1.0, }
                                      ))
                packop_lines.append((0, 0, {
                    'product_id': line.product_id.id,
                    'product_uom_id': line.product_uom_id.id,
                    'location_id': self.source_id.id,
                    'location_dest_id': self.destination_id.id,
                    'product_qty': line.qte * 1.0,
                    'pack_lot_ids': pack_lot_ids.append((0, 0, {
                                    'product_id': line.product_id.id,
                                    'lot_id': line.lot_id.id,
                                    'qty_todo': line.qte * 1.0, }))
                }))

        vals = {
                'location_id': self.source_id.id,
                'location_dest_id': self.destination_id.id,
                'min_date': self.date,
                'origin': self.name,
                'picking_type_id': self.env['stock.picking.type'].search([('code', '=', 'internal'),
                                                                          ('default_location_src_id',
                                                                           '=', self.source_id.id)]).id,
                'move_lines': picking_lines,
                'pack_operation_product_ids': packop_lines,
                'move_type': 'direct',
                'priority': '1',
                'company_id': self.env.user.company_id.id,
                'dd_id': self.id,
                'for_delegue': True,
                'state': 'assigned',
            }

            pick_id = self.env['stock.picking'].sudo().create(vals)
            rec = self.env['stock.picking'].browse(pick_id.id)
            rec.action_confirm()
            rec.action_assign() 

Avatar
Discard