跳至内容
菜单
此问题已终结
2 回复
1772 查看

I would like to create an entry (In this case for a test) but I want to use it with a specific XMLID which is used in another module. Is it possible to change the xml ID after the creation of the entry within the code. The second party module can or can not be installed.

The background is that I want to test it with and without other modules installed. As env.ref("XXXX") is used I need it to have a specific name.

So solutions with entries in the data folder or exporting with a random name are not applicable.

形象
丢弃
最佳答案

Hello,

In Odoo, External Identifiers (also known as XML IDs) are stored in the ir.model.data table.
This table acts as a central registry for mapping these human-readable string identifiers to their corresponding database record IDs.

Key Points:

  • Purpose: External IDs serve several crucial functions:
    • Data Import/Export: They simplify data exchange with external systems and between Odoo databases. You can reference records by their external IDs during import, allowing Odoo to efficiently create or update existing records.
    • Code Referencing: Developers can use external IDs in Python code to effortlessly access specific records without relying on internal database IDs. This enhances code readability and maintainability.
  • Generation:
    • Manual: You can define external IDs explicitly during data import using XML files. This grants you more control over record identification.
    • Export: During data export using XML files, Odoo automatically generates external IDs for the exported records if they weren't already defined.

Modification:

  • Recommended Approach: If you need to change an external ID, it's recommended to:
    1. Identify the Record: Go to Settings --> Technical --> Sequences & Identifiers --> External Identifiers
       Use the ir.model.data model's search methods or Odoo's developer tools to locate the record associated with the specific external ID you want to modify.

Thanks & Regards,


CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209

Email: info@candidroot.com

 


形象
丢弃

The request was "in code", not through UI.

最佳答案

Hi,

Yes you can create a record with specify external id by passing value in the id column during the import of data. Or even from the python side, the external id is stored in a db table, you can see all the external id's from the External Identifiers menu under settings -> technical

So yes, programticaly it is possible to change the external id

Thanks

形象
丢弃
相关帖文 回复 查看 活动
0
8月 21
4
2
5月 18
9102
3
5月 18
4248
2
6月 24
1217
1
3月 24
2382