コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
6529 ビュー

When i am deleting a record in postgresql DB from odoo front-end and if again i am creating a new record then the primary key index changed like if i am deleting id=2 record and if again creating new record ,then it stores id =3.. How ?? 

アバター
破棄
最善の回答

Actually, Odoo automatically apply sequence on ID field. This is done by _sequence attribute on model and it's apply on 'ID' field here https://github.com/odoo/odoo/blob/12.0/odoo/models.py#L3630

If you check your table in Postgresql then ID column have description like id integer NOT NULL DEFAULT nextval('model_name_id_seq'::regclass). Here, nextval will execute sequence which will auto increment index.

You can read in detail what is exact nextval function? https://www.postgresql.org/docs/current/sql-createsequence.html

You can use _sequence attribute on model to change sequence field.

アバター
破棄
著作者 最善の回答

Thank you Jigar Patel

アバター
破棄
関連投稿 返信 ビュー 活動
0
11月 21
3073
0
2月 25
1604
2
1月 25
8227
2
1月 24
10138
3
10月 23
8707