Changes from https://lab.nexedi.com/nexedi/erp5/-/merge_requests/1751 and https://lab.nexedi.com/nexedi/erp5/-/merge_requests/1673