Western comedy. Likely from the 1960s to early 1980s.
The protagonist is a man that somehow manages to become sheriff in a town. It ends up with him having to duel some badass bandit. I'm not 100% sure about him becoming sheriff, but 99% ;P Believe he did not really want this role.
It is not much I recall from the film, but one distinct thing is that he gets a lot of advice for the duel. Typically that he has to shift to the right (or left) and then bow or do this and that to escape the bullets from the enemy. Believe there also was some advice about the sun and how he should duck and have the wind on this or that side etc.
As he is preparing for (walking to) the duel he is repeating all the advices and believe he is rather confused. He is also very, very scared. The duel was typically set at sunrise (I believe). He might have been small built.
It is more likely from midst 1960s to early 1970s if I recall the colouring, sound, clipping etc. correctly, but I might be wrong.
There might have been some setting where the bandit he is going to duel terrorizes the town. Believe the duel is what it all accumulates to. (In other words not very distinct as westerns are.) Beside this I only recall glimpses that can be from any western / spaghetti film. (Bar fights, people ending up in water bins for horses etc. – but then again I might be mixing in some of those glimpses from other films.)