Pipelines constitute the dominant inland transportation mode for crude oil and oil products. Lots of refined products such as gasoline, jet fuel and diesel are shipped from refineries and seaports to truck-loading terminals by multiproduct pipelines. Planning the operation of multiproduct pipelines is a very difficult task demanding efficient tools to get safe, on-time, low-cost and high-quality movement of the oil products. Some approaches have been recently proposed to cope with the detailed scheduling of unidirectional pipelines featuring a single input at the origin and multiple receiving terminals along the line. However, many pipelines present several input stations at intermediate locations and even dual-purpose (input/output) nodes. Therefore, it becomes necessary to reformulate detailed scheduling models to account for pipeline systems with multiple sources and intermediate offtake points. The new mathematical formulation developed in this work permits to obtain the optimal sequence of detailed pumping and stripping tasks that minimizes the overall flow restart and stoppage costs, through the least number of operations. The advantages of the new approach are illustrated by solving a real-world case study.