تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
5885 أدوات العرض

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? 

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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!

 

الصورة الرمزية
إهمال
أفضل إجابة

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" ?

الصورة الرمزية
إهمال
الكاتب

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?

الكاتب

Solved!

المنشورات ذات الصلة الردود أدوات العرض النشاط
5
ديسمبر 19
7613
0
يوليو 15
3658
1
يونيو 15
6043
0
يونيو 15
120
1
مارس 15
3687