rpdb is a remote debugger based on pdb. It re-routes stdin and stdout to a socket handler, so that you can debug server processes (remotely).
In Odoo.sh > yourstagingBranch, click on the SHELL-tab:
mywebsite-oerp-staging-5070461 [staging/v13.0]:~$ pip3 install rpdb
In Odoo.sh > yourstagingBranch, click on the EDITOR-tab:
IN ODOO-EDITOR:
- At the top of your python file, add:
 
    import rpdb
- In the function (def subscribe) to be inspected, add:
 
    def subscribe(self, event, **post):
        # code before
        rpdb.set_trace()
        # code after
- Click on menu Tab : Odoo>Update current module : alternatively, open a new Terminal window and execute this command: odoo-bin -u website_sale --stop-after-init
 
    mywebsite-oerp-staging-5070461 [staging/v13.0]: odoo-bin -u website_sale --stop-after-init
- After having restarted Odoo (all modules loaded), execute this command in the other Terminal window: nc 127.0.0.1 4444
 
    mywebsite-oerp-staging-5070461 [staging/v13.0]: ~$ nc 127.0.0.1 4444
- We can then use the common pdb commands:
 
l(ist): Lists the lines surrounding the current line
w(here): Displays the file and line number where we currently are
s(tep): Step into the function at the current line
n(ext): Continue execution until the next line in the current function is reached or it returns. (The difference between next and step is that step stops inside a called function, while next executes called functions at (nearly) full speed, only stopping at the next line in the current function.)
a(rgs): Print the argument list of the current function
p(rint) variablename : Print value of variablename
quit : To quit rPdb
More info : https://itnext.io/debugging-your-code-in-python-pdb-vs-rpdb-e7bb918a8ac3
Official documentation (commands) : https://docs.python.org/3/library/pdb.html
#######
OR, alternatively : Using this post How to debug python CLI that takes stdin? :
in Odoo.sh>EDITOR (Jupyter Lab): Open a first Terminal and create these two fifos which will be used as stdin/stdout to use pdb :
 mkfifo fifo_stdin
 mkfifo fifo_stdout
 cat fifo_stdout & cat > fifo_stdin
 
...which makes appear a prompt cursor. Keep this Terminal Tab opened.
Write these 2 lines at the top of the Python script to be debugged :
 import pdb
 mypdb=pdb.Pdb(stdin=open('fifo_stdin','r'), stdout=open('fifo_stdout','w'))
 
In this Python script, call set_trace() on your customized mypdb:
def _get_total_amount(self):     
   total_amount = sum(self._get_base_order_lines(program).mapped('price_total')) 
   mypdb.set_trace()  
   return total_amount
 
...