When an accused person pleads that the person is guilty of any offence, and when, upon trial, an accused person is convicted of any offence, the proper officer is required to ask the person whether the person has anything to say why sentence should not be passed upon the person, but an omission to do so does not invalidate the judgment.