[FIX] orm: better removal of custom m2m fields
authorMartin Trigaux <mat@openerp.com>
Tue, 8 Jul 2014 13:56:24 +0000 (15:56 +0200)
committerMartin Trigaux <mat@openerp.com>
Tue, 8 Jul 2014 13:56:24 +0000 (15:56 +0200)
commit84e9a67cdf78db94cb7a09543c1b7ac4ad19d8b4
tree98feecc61efdb11bc4041cbaef1338ed1f5c520b
parent6af3193d17021108f7501cfda824e7a1aecc8a85
[FIX] orm: better removal of custom m2m fields

orm: do not try to create ir.model.relation for custom m2m as self._module is either empty (for custom models), either the one of the last inheriting module (which is wrong). The field should be removed manually and should not be impacted by the uninstallation of modules. The removal of the relation table can be done when removing manually the custom field (see rev 6af3193).

ir.model: when removing a model, drop the table with the CASCADE instruction. This will remove left constraints from remaining m2m tables.
This means that dropping a table (either manually removing a custom model or uninstalling a module) will not drop the relation table for a custom m2m field. This is not ideal but better than the previous behaviour (which was to fail the DROP TABLE instruction and keep the table with a few columns and unconsistent data).
openerp/addons/base/ir/ir_model.py
openerp/osv/orm.py