Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
425 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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 correlati Risposte Visualizzazioni Attività
0
set 23
1755
2
apr 25
1208
1
lug 24
1829
1
gen 24
4933
0
lug 23
2813