Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
3 Besvarelser
5871 Visninger

Every time I create a new db the id of a module changes. Since I would like to create some server actions linked to my xml I need to put a specific id (for both server actions AND models).

Populating the ID "manually" isn't an option, because those values are used on various places and I fear there is a great risk of using the same ID twice.
Is there a way to reserve an unique ID on creation stage trough python or xml without mess up the DB? 

Avatar
Kassér
Forfatter Bedste svar

Solved the server action issue!

The problem is how do you create a server action: if you create it by GUI then you don't have an external ID but just an ID number, while if you create via XML you can use the ID name as a button name and Odoo will assign automatically an ID number.

I have a server action called rest_checkout_send, then on button name I wrote

<button name="%(rest_checkout_send)d" string="Enviar" type="action" attrs="{'invisible':[('status','=','1')]}"/> 

and it was automatically update in

<button name="723" string="Enviar" type="action" attrs="{'invisible':[('status','=','1')]}"/>           	   

 That's simply perfect!

 

Avatar
Kassér
Bedste svar

Federico,

It's not possible to keep same ID, because sometimes you install "xyz" first and sometimes "abc" first. Obviously ID will be changed every time. It's simple logic.

However External ID never gets changed. ( That is why it is stands for) Why you are not thinking for to use "External ID" instead of "ID" ???

Are you aware about "External ID" ?

Avatar
Kassér
Forfatter

Thanks for your reply.
I know the logic behind the ID field, for that reason I'm looking for a way to reserve numbers. And yes, I'm aware of external ID but it doesn't apply to server actions: as far as I know is just for models.
If you look on ir.model table you can just declare the model name (crud_model_name) and the relative ID (crud_model_id). This means every time I install my custom module I need to edit the xml view and correct the IDs of server actions. Am I missing something?

Forfatter

Solved!

Related Posts Besvarelser Visninger Aktivitet
5
dec. 19
7608
0
jul. 15
3651
1
jun. 15
6037
0
jun. 15
120
1
mar. 15
3686