Before this commit, when having a x2many field invisible in a view, and displaying
it anyway in studio, there was a crash because some variable was undefined.
This originated from commit f22961a, which did not account
for the fact that viewMode is an optional props.
After this commit, the util function used by the x2m field and where the
crash occur has been refactored.
Moreover, the x2m field template has also been slightly refactored.
closesodoo/odoo#120918
Taskid: 3305808
Related: odoo/enterprise#40852
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>