This question has been flagged
1 Reply
8538 Views

Hello gang,

Somebody write to me :

if you delete a record in a xml file and you update the module, the record will be deleted in database if you have not parameter noupdate="1" in <data>

I understand this. But I have a question.

Example :

  • I create a record id=mycustom.stock_location_a in my custom module;
  • I upgrade the module mycustom in my odoo;
  • I check in Warehouse->Locations, the new record (stock_location_a) is there;
  • The external ID (mycustom.stock_location_a) is of course created in ir.model.data.
  • Now, I remove the record id=mycustom.stock_location_a in my XML.
  • I upgrade mycustom again.
  • Here, I suppose that Odoo will erase the record mycustom.stock_location_a

Here is my questions :

  • But how Odoo can decide to delete the record? May be I have put the XML record in a other file or an other module, no????
  • Will Odoo delete mycustom.stock_location_a?
  • Which conditions before to delete it from Odoo?
Avatar
Discard
Best Answer

Hi,

           if noupdate = 0 or not defined in <data>, when you update a module, odoo verify corresponding records between all records in xml files and records in table ir_model_data and in model defined for the record in xml, the relation between ir_model_data and the model are in ir_model_data with columns res_id (id in model table) model and module, complete_name is module_name.xml_id, you can see column noupdate too (file base/ir/ir_module.py).

For all new records add in xml file if noupdate=0, a record is add in ir_model_data and model, for existing records in ir_model_data and xml if noupdate=0, datas in model are updated, if noupdate=0and  if a record is present in ir_model_data with values your module/your object/... but not in your module the record in ir_model_data and in the model defined in xml for the record will be deleted. But if there is a reference of your model record id in an other record you  will have an integrity error.

bye

Avatar
Discard
Author

thanks a lot. I will analyze each word of your answer.