İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
377 Görünümler

Hi everyone, 

we want to have the possibility to show or hide the chatter in the Tasks based on a flag inside the Project. Is it possible? 

We tried to develop a module in which the task's view is inherited and modified, but it isn't working

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

  <data>

   <record id="view_task_form_inherit_hide_chatter" model="ir.ui.view">

      <field name="name">project.task.form.inherit.hide.chatter</field>

      <field name="model">project.task</field>

      <field name="inherit_id" ref="project.view_task_form2"/>

      <field name="arch" type="xml">

        <xpath expr="//chatter" position="attributes">

          <attribute name="invisible">{'invisible': [('project_id.x_studio_show_chatter', '=', False)]}</attribute>

        </xpath>

      </field>

    </record>

  </data>

</odoo>

Avatar
Vazgeç
En İyi Yanıt

Hi,

You cannot directly access a field from another model using dot notation in the XML view definition (e.g., project_id.x_studio_show_chatter). Additionally, there is a syntax issue in your invisible condition.

Here’s how you can achieve your requirement:

  1. Create a related field on the project.task model that links to the x_studio_show_chatter field from the project.project model. This can be done using Odoo Studio by adding a related field.
  2. Use this related field in your XML view to control the visibility of the chatter:
    <xpath expr="//chatter" position="attributes">
        <attribute name="invisible">not x_studio_task_show_chatter</attribute>
    </xpath>

    Make sure that the related field is included in the form view so that it's available in the view context.

Hope it helps

Avatar
Vazgeç
Üretici

Thank you! It is helping as it's not giving me any errors, but the behaviour is not working: the chatter is only shown/hidden if done in Studio. Do you have any advice?

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Eyl 23
1700
2
Nis 25
1126
1
Tem 24
1737
1
Oca 24
4767
0
Tem 23
2762