Effect of magnetic and electric fields on the transport properties of polyatomic gases. I. Formal theory