Wrong behavior of the reference field

Thank you for your answer
I will consider this an acceptable solution

But the question, and what is done in the tabs without another
For example, it works well for purchasing and selling invoices
It does not work well in the receipts and payments