I tried to use this code, but I am not unable to do it.
I don't know which pin acts as an interrupt and either it is active high or active low.
This code was originally not written by me. I have copied it from STM community.
///////////////////////////////////////////
///////////////////////////////////////////
Here's what I'm doing for the STM8L151 and it drops current to 0.5uA. This is full halt, but if you want to keep RTC active, just comment out those lines. One thing, you have to clear the wakeup INT before halt. Here, I'm using EXTI pin7 for wakeup.