Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
6062 Lượt xem

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? 

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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!

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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?

Tác giả

Solved!

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 12 19
7760
0
thg 7 15
3855
1
thg 6 15
6190
0
thg 6 15
120
1
thg 3 15
3823