Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How Odoo proceed to delete absent xml record?

By
Pascal Tremblay
on 3/15/15, 8:29 AM 1,877 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?
2

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/15/15, 9:42 AM

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

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

Pascal Tremblay
on 3/15/15, 9:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/15/15, 8:29 AM
Seen: 1877 times
Last updated: 3/16/15, 8:10 AM