[FIX] models: query blowup when unlinking many records
[FIX] models: query blowup when unlinking many records

The method `unlink` checks whether any of the records to delete is used
as the default value of a company-dependent field.  The query simply
blows up when deleting several millions of records.  The fix consists in
performing the check in batches.

closes odoo/odoo#41331

X-original-commit: 30e8b8f2554e5d16b19f16ea90e3503098dc98a0
Signed-off-by: Raphael Collet (rco) <fcee45b878db1f337818c5c606c1542797080a40@openerp.com>

ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo