Move the sanity check from the `button_validate()` outside so it can be
run premptively in a different context.
Basically it allows batches to run the santiy_check as a whole. This
means that when the function checks if there is at least one quantity
done to check only those move_lines for the lot/serial numbers, it is
now able to check the pickings independantly from each others like
before, but also as if they were a single entity.
This can avoid this weird behavior in the following batch :
Picking | product_name | qty | done_qty
--------|----------------|-----|---------
Pick_1 | product_1 | 2 | 0
Pick_1 | product_serial | 1 | 0
Pick_2 | product_2 | 2 | 0
Setting a done_qty on product_1 would be fine to validate the batch,
since at least one done_qty would be found within Pick_1. But setting a
done_qty on product_2 would raise an error for missing serial numbers
since then no done_qty would be found within Pick_1.
This commit evens the behavior of the sanitizer in this case. While
keeping the way it works outside of a batch validation.
Task-2971346
X-original-commit: 3a3b5d90d58339f65b1db0b52a2c81e02b5a3f17
Part-of: odoo/odoo#102382