Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
5860 Zobrazení

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

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?

Autor

Solved!

Related Posts Odpovědi Zobrazení Aktivita
5
pro 19
7595
0
čvc 15
3645
1
čvn 15
6032
0
čvn 15
120
1
bře 15
3680