Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3565 มุมมอง

I have an Odoo database containing tables which were created using a separate application interacting with the same database.

I know I could run SQL SELECT queries directly in Odoo to read the data, but I'm wondering if there's a way to just have the ORM read the table in a "read-only" way.

I'm already aware that you can set `_auto` to `False` on the model and override the `init()` method to disable Odoo's automatic management of the table, but I've only seen this used to have Odoo read data from a view. How would I use it to have Odoo read data from a regular table, but not write or delete?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I just tried this and quickly tested basic functionality (sort, filter, group by, export).


Note: "id" is required for Odoo to retrieve data, so as long as your table(s) have that field [I didn't test column aliases], you should be good with this approach:


Given this table:

CREATE TABLE films (id integer, code char(5), title varchar(40));
INSERT INTO films (id, code, title) VALUES (1,'LF232','Return of the Jedi');


You can create this class / model:




Then, with appropriate permissions (read access) and UI elements (Window Action, Menu, View), you would see:


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 21
8491
0
มี.ค. 15
3874
2
มี.ค. 15
4597
1
มี.ค. 15
5210
1
ธ.ค. 21
2311