You can achieve it using a Virtual layer.
Go the the menu layer / add layer / add-edit virtual layer
and enter the following query. You may want to add more fields and a unique ID.
select MakeLine(pt.geometry) as geometryfrom myPointLayer ptgroup by pt.code, pt."Line num"
If the input points are not already ordered by ID, you may have to include a sub-query to sort the points first, then apply makeLine
on it.