Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
215 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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

I get this error

Autor Najlepsza odpowiedź

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'

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
mar 15
10456
0
lut 16
5411
1
maj 23
4426
1
wrz 21
8413
1
lis 19
9917