please fix the code below. when creating a new stock.picking, if there are 2 lines of the same product name then in stock.picking it will become 1 line. it should remain 2 lines. is there an error in the code below? or are there any other suggestions?
def _create_delivery_order(self):
picking_obj = self.env['stock.picking']
warehouse = self._default_warehouse()
destination_id = self._default_destination_id()
# stock = self.env['stock.location'].search([
# ('warehouse_id', '=', warehouse.id),
# ('usage', '=', 'internal')
# ], limit=1)
picking = picking_obj.create({
'rma_order_id': self.id,
'partner_id': self.partner_id.id,
'partner_invoice_id': self.partner_invoice_id.id,
'branch_id': self.branch_id.id,
'picking_type_id': self._default_picking_id(),
'location_id': self.env.ref('stock.stock_location_customers').id,
'location_dest_id': destination_id,
'move_lines': [(0, 0, {
'product_id': line.product_id.id,
'name': line.product_id.name,
'price_unit': line.price_unit,
'product_uom_qty': line.quantity,
'product_uom': line.product_id.uom_id.id,
'location_id': self.env.ref('stock.stock_location_customers').id,
'location_dest_id': destination_id,
'reference_picking': line.picking_id.name,
'rma_line_id': line.id,
}) for line in self.order_lines],
'origin': self.name,
})
if self.request_type == 'cancel_so':
picking.name = self._sequence_delivery_order('C')
else:
picking.name = self._sequence_delivery_order('RET')
return picking