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

Hi, I'm using Odoo14 and I've succesfully made a kanban view for one of my module: it loads without showing errors and it shows everything I wanted, except for the images. The rectangles of the records shows the space in which it should load the image of the record, but this spot remains blank - either if it should show a loaded image or a default-avatar one. Any idea of what could have gone wrong? Thank you all very much

EDIT: the forum doesn't let me load the code with the symbols (I don't know why), so I'll try to explain it: after the "kanban", I wrote field name="nome" and field name="partita_iva"/; then I wrote "templates" and this:

t t-name="kanban-box"                            
    div class="oe_kanban_global_click o_kanban_record_has_image_fill
o_kanban_record"
        t t-if="record.azienda_logo.raw_value"
            div class="o_kanban_image_fill_left d-none d-md-block"
             t-attf-style="background-image:url
('#{kanban_image('piani_formazione.azienda', 'azienda_logo',
record.nome.raw_value)}')"/
        /t
        t t-else=""
             img class="o_kanban_image" alt="Avatar"
             t-att-src='_s + "/base/static/img/avatar.png"'/
         /t
Then div class="oe_kanban_details", that isn't relevant for the question. 

EDIT 2: I added an id field and used record.id.raw_value instead of record.nome.raw_value and now it works!! Thanks a lot



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

in XML file inside kanban section add id field(field name='id'), no need to add id field in .py file, and kanban template section add image field in below way

img t-att-src="kanban_image('model_name', 'image_field_name', record.id.raw_value)" alt="image"
.I guarantee to you your image definitely showing on kanban view
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi can you share your code

Gus

Ảnh đại diện
Huỷ bỏ