When a product has been unbuilt and also (mistakenly) scrapped, it's
impossible to reuse the serial number in production again, even if the
product is unscrapped.
This fixes the sanity check in a similar way to the _check_sn_uniqueness
function, not just checking for removed stock move lines, but also unremoved
stock move lines. A test case is also added to check this scenario.
This is a similar fix to a previous commit we did
(4f07b260807053586ac6c01cf92ac3d5e37b1041) where we bumped into a
problem with the duplicate serial sanity check.
closesodoo/odoo#142574
X-original-commit: 1761b95d9fda5d5355f35effd1f345a25ded1197
Signed-off-by: William Henrotin (whe) <whe@odoo.com>