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

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>

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
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?

Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 23
1689
2
kwi 25
1107
1
lip 24
1729
1
sty 24
4752
0
lip 23
2758