Only check consistency up to next decision workflow + display title of sub-object when consistency check fails
Two commits aiming to improve consistency checks. I will most likely apply them on Nexedi ERP5, and try to push them upstream before. We may accept both, only one, or none. I do not know who wants to have a look so feel free to ping. I discussed this change with JP who agreed with it, but that does not mean developers cannot diverge.
ERP5Type: only check consistency up to next decision workflow
When an object has sub-objects, consistency checking on the object was always checking consistency of all sub-objects. This does not makes sense for sub-objects having an independent decision (ie. not interaction, not edit) workflow.
For instance, one should be able to validate a Person even when its Assignments, which have their own Assignment Workflow, are inconsistent, because in any case the check can be bypassed by validating the Person first, then adding an Assignment, which is not going to invalidate the Person. Also, validating the Person has no actual impact on security before the Assignment is actually started, operation which will check consistency of the Assignment.
On the other hand, we still want to propagate consistency of sub-objects in cases where they do not have an independent decision workflow. For instance, consistency of an Order should always ensure consistency of all the lines, since lines have no other workflow than edit or interaction workflow.
This commit therefore introduces this logic in ERP5: for all sub-objects, first check if there is a decision workflow before extending the parent object consistency with consistency of the sub-object.
erp5_core: display title of sub-object when consistency check fails
When recursively checking consistency of sub-objects from a parent object, the message shown to the user was quite misleading, as it did not mentionned the actual object that the constraint was referring to. This commit adds a mention before all consistency messages not actually coming from the object being checked, to state the sub-object to which it applies.
For instance, before, when confirming an Order with a line missing a resource, one could see the message: "Product or service must be defined". This does not clearly indicates which line is to be modified. Now, the message shown instead is: "At Purchase Order Line ERP5 Development: Product or service must be defined", showing both the Portal Type of the object and its title, so the user can find it.
This commit however does not try to handle recursive cases intelligently, and will, for a sub-object A of a sub-object B of object C, only show the title and Portal Type of A on consistency message. It should be enough in the rare cases where this will happen.
/cc @jerome @vpelletier (who seem to have contributed around my changes)