Refine the priorities of ir.values entries to make the result
deterministic in the presence of multiple matching default
values. We now give the priority to company-specific defaults,
before global defaults.
Before this change, the default value would be random when
both a per-company and global default value existed for the same
field (with no per-user default).
The priorities are now defined as follows (smaller number = higher prio):
1. Per-user default (user_id is set, company_id is set)
2. Per-user global default (user_id is set, company_id not set)
3. Per-company default (user_id not set, company_id set)
4. Global defaults (user_id not set, company_id not set)
The final "id" order spec ensures that the order is total.
Also added the corresponding regression test.
Closes#16038