Partition trigger and serial column concurrence
Your code is safe, because according to the documentation:


  Because this is returning a session-local value, it gives a predictable answer whether or not other sessions have executed nextval since the current session did.


But why don't you do the natural thing and

EXECUTE format(
           'insert into %I (id_beat, created_at) values ($1, $2)',
           partition_name)
USING NEW.id_beat, NEW.created_at;