Unable to delete records with One2Many of ModelStorage but not ModelSQL
We have a custom model that have a One2Many pointing to a ModelStorage class (but not ModelSQL). When deleting a record with this related records the following exception is thrown:
Traceback (most recent call last):
File "/home/sergi/projectes/develop/trytond/trytond/protocols/dispatcher.py", line 162, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/sergi/projectes/develop/trytond/trytond/modules/aritmos_sii/sii.py", line 1442, in delete
super(SIIRecord, cls).delete(records)
File "/home/sergi/projectes/develop/trytond/trytond/model/modelsql.py", line 1067, in delete
foreign_table = Model.__table__()
AttributeError: type object 'sii.record.desglose_iva_repercutida' has no attribute '__table__'
That's because the current code assumens that target models are always from ModelSQL and uses a sql expression to find the related records. Indeed, we should use a normal search for ModelStorage to delete related records.