I don't think you can nail down a specific time, in a general sense, for when wooden barrels became obsolete. It really all depends upon what commodity you're dealing with. Just as a couple examples;
I have been an antique dealer for 44 years. My area of specialization is glassware & art glass primarily from the late 1800's through the depression era years. During that time frame the majority of the glass manufacturers in this country were centered in the Ohio River Valley area. They shipped their products via rail & riverboat and the bulk of it was packed in wooden barrels packed with straw. In fact, most glass factories in that area, like H.Northwood & Co, Imperial, Fenton, Dugan & others had barrel making operations included in their complex, as well as storage facilities for the straw, called "Haysheds". When retailers & wholesalers purchased glass from these factories, they bought it by the barrel. The glassware was packed in assortments comprising several dozen pieces per barrel. The customer paid for the assortment, which also included a 25 to 50 cent charge for the barrel itself. By the 1930's, with the advent of automated packaging machinery, the practice of shipping glassware in barrels faded away in favor a boxes.
I grew up during the 1950's/1960's in Aroostook County in Northern Maine.......potato farming country. My family were all potato farmers. During the 1950's, mechanized harvesting was just starting to creep in up there, but the majority of farms still harvested by hand and the potatos were loaded, transported and sold in wooden barrels. A barrel held 165 lbs. of potatos & that's how they were marketed, by the barrel-weight. I remember that back then the price the farmer got for his potatos generally bounced around between $6. to $8. per barrel. At harvest time, flatbed trucks would drop off empty barrels along the rows of patatos. The crew would dig the potatos (backbreaking work), fill the barrels, then the trucks would come back. A hand-cranked crane arm on each truck would pick them up, load them & the trucks would then take them into the potato houses in town (in this case Fort Fairfield), for storage. The potato houses were in rows lined up along the railroad lines. Two lines went into Fort Fairfield: The Canadian Pacific and The Bangor & Aroostook. Strings of reefers would be shuttled into the potato house rows and the barrels of potatos loaded into them for shipment.
By the mid 1960's, mechanization of harvesting had taken hold & things changed. Large, open bin trucks drove alongside the harvester & the potatos dumped into them by conveyor, directly from the harvester. By then, big potato processors like Ore-Ida, McCains etc had huge processing plants located nearby (and still do) . Crops were "pre-sold" and taken by the trucks directly from the fields to the processing plants. The potatos were no longer marketed by the barrel-weight & the need for the barrels was gone. So, in this case the use of barrels lasted into the early 1960's, anyway. The downside to this was that railroads like the Bangor & Aroostook lost major cargo contracts. Potatos were no longer their "bread & butter" cargo. Logs, lumber & pulpwood became the major cargo for them.
I think you'll find that this was the case everywhere. The time-frame for discontinuing of the use of barrels varied, depending upon the commodity & many other factors. So, for a model railroad, it all depends on what era, location & commodity your line is transporting.