Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
313 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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?

Post Terkait Replies Tampilan Aktivitas
0
Sep 23
1624
2
Apr 25
1075
1
Jul 24
1688
1
Jan 24
4666
0
Jul 23
2706