Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
376 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

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?

Related Posts Odpovědi Zobrazení Aktivita
0
zář 23
1697
2
dub 25
1122
1
čvc 24
1737
1
led 24
4767
0
čvc 23
2762