Enforce to set company context to field with CompanyMultiValueMixin target
In order to achieve #4080 (closed) we need to be sure that referential record of type CompanyMultiValueMixin
has the proper company in the context so the MultiValue
fields returns the correct value.
Initially I thought that we should use get_multivalue
everywhere and ensure to set the proper context but this can not be done for the on_change calls.
But since #8586 (closed) and #8225 (closed) we can rely on instance having the proper context (if the developer does not set deliberately something else).
So the proposal is to add a MixinTestCase
in company to be used on module depending on company that checks for models having a Many2One
to company.company
that fields linking to CompanyMultiValueMixin
have a company
context set.
This will not directly ensure that on_change calls have the proper depends but if accessing a CompanyMultiValue
from a field having the context defined but the value is empty, will return no value as None
will not match and so the code will fail even if the global context has the proper company
key.
Also this will reduce the cases where using get_multivalue
is really needed.
An initial test shows that such test enforces cases that may not be problematic like the party on shipments but in some point it will anyway good to show related properties like accounting for the shipment's company.