콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
246 화면

Hello,

I am trying to display the database ID of each record on the Kanban view for projects. To start, I just want to test modifying the Kanban view by adding a simple visual element.

Here is the XML I am using:

<odoo> <template id="project_task_kanban_inherit" inherit_id="project.view_task_kanban"> <xpath expr="//div[contains(@class,'o_kanban_record')]" position="inside"> <div style="width: 100%; height: 50px; background-color: black;"></div> </xpath> </template> </odoo>

This should display a black box on every record in the Kanban view. However, nothing is being displayed.

Could anyone please point out what I might be doing wrong?

Thank you in advance for your help!



UPDATE: See my answer in the comments for a solution

아바타
취소
베스트 답변

Hello stefan,

Try to inherit and update the template(t-name="card") of kanban view. Hope, it works.

Feel free to reach out us: lakhan@codespheretech.in

아바타
취소
베스트 답변

Hi,

Please refer to the code:

<odoo>

    <template id="project_task_kanban_inherit" inherit_id="project.view_task_kanban">

        <xpath expr="//div[contains(@class,'o_kanban_content')]" position="inside">

            <div style="width: 100%; height: 50px; background-color: black;">

                <!-- Optional: Display record ID -->

                <t t-esc="record.id"/>

            </div>

        </xpath>

    </template>

</odoo>


Hope it helps.

아바타
취소
작성자

Element '<xpath expr="//div[contains(@class,&#39;o_kanban_content&#39;)]">' cannot be located in parent view

I get this error

작성자 베스트 답변

I have found the solution:

<odoo>
<template id="project_task_kanban_inherit" inherit_id="project.view_task_kanban">
<xpath expr="//div[contains(@class,'o_kanban_record')]" position="inside">
<div style="background-color: #222; color: #fff; padding: 5px; margin-bottom: 5px;">
<div style="background-color: black; color: white; padding: 5px;">
Task ID: <field name="x_task_id"/>
</div>
</div>
</xpath>
</template>
</odoo>

class ProjectTask(models.Model):
_inherit = "project.task"

x_task_id = fields.Integer(string="Task ID", store=True)

@api.model_create_multi
def create(self, vals_list):
tasks = super().create(vals_list)
for task in tasks:
task.x_task_id = task.id
return tasks

You cannot access the ID because the BaseView does not include it. So in order to access it you have to create your own field and then display that. There is probably a way better way to do this. 
Also sidenote: already created tasks will not have x_task_id populated. Only new tasks. 
Im sure there is a way to actually populate already existing tasks fields with values. 

Also for some unknown reason this would not display anything before i explicitly set 'Model of the View' under Technical -> Views -> this view to 'Task'

아바타
취소
베스트 답변

Hello Stefan,



It looks like your issue stems from how Odoo loads and applies view customizations. Here's a breakdown to help you get that black box showing:


  Module Installation Order: Ensure your module containing this XML is installed after the 'project' module. Odoo applies changes in the order modules are loaded.

  Module Update: After adding or modifying the XML, you need to update your module. Go to Apps, find your module, and click 'Upgrade'. This applies the changes to the view.

  Clear Browser Cache: Sometimes, the browser holds onto older versions of the view. Clear your browser cache or try a hard refresh (Ctrl+Shift+R or Cmd+Shift+R) to ensure you're seeing the latest version.

  Check for Conflicting Customizations: If other modules are also modifying the Kanban view, they might be interfering. Disable other customizations temporarily to see if your black box appears.

  Verify XML Syntax: While your XML looks correct, double-check for any typos or syntax errors that might be preventing it from loading.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

아바타
취소
베스트 답변

Hello Stefan,



It appears the issue might stem from how Odoo loads and applies inherited views. Here's a breakdown to help troubleshoot:


  Module Installation Order: Ensure your module containing the Kanban view modification is installed or upgraded after the 'project' module. Odoo applies view changes in the order modules are loaded.

  Correct Module Update: After making changes to your XML, update your module. Go to Apps, search for your module, and click 'Upgrade'. This applies the changes to the database.

  Clear Browser Cache: Sometimes, the browser retains older versions of the web assets. Clear your browser cache or try a hard refresh (Ctrl+Shift+R or Cmd+Shift+R) to ensure you're seeing the latest version.

  Check for Conflicting Views: Verify that no other module is overriding the same Kanban view, which could prevent your changes from being displayed.

  Verify XML Syntax: Double-check your XML for any syntax errors. Even a small mistake can prevent the view from loading correctly. Use Odoo's server logs for error messages related to view loading.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

아바타
취소
관련 게시물 답글 화면 활동
1
3월 15
10467
0
2월 16
5420
1
5월 23
4456
1
9월 21
8463
1
11월 19
9926