Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

how to make the "mark done" disappear depending on a condition

Subscriure's

Get notified when there's activity on this post

This question has been flagged
5 Respostes
2321 Vistes
Avatar
Aws Hokan

How to change the XML code so that if the signed in user is the assignee user in a certain activity then the "mark done" button should appear to the mentioned user, if the signed in user NOT the assignee user the "mark done" button disappear.
the Activity.xml file that I think should change


0
Avatar
Descartar
Aws Hokan
Autor

Thanks Jason for response but i tried as you suggest but not working. the code appear as the following :
<button class="o_Activity_toolButton o_Activity_markDoneButton btn btn-link btn-primary pt-0 ps-0"
t-att-title="activityView.markDoneText" t-ref="markDoneButton" t-on-click="activityView.onClickMarkDoneButton" attrs="{'invisible': [('user_id', '!=', uid)]}"
>
<i class="fa fa-check"/> Mark Done
</button>

Aws Hokan
Autor

Thank you all for replay. I tried the mentioned solution but still face the same result.
I think that the condition is true but the parameters are false ( the assignee Id and the singed in user id)

Avatar
Jason Vu
Best Answer

Hi,

you can try to add this to your button: 

attrs="{'invisible': [('user_id', '!=', uid)]}"

Hope it helps!

1
Avatar
Descartar
Avatar
Osama Hassan
Best Answer

Hello aws hokan, Jason Vu provided sample code for such operation as you didn't provide you code snippet earlier.
Try this

attrs="{'invisible': [('activity_assignee_id', '!=', uid)]}"

upgrade module and clear browser cache as sometimes the cache prevents from changes made in xml/js file.


1
Avatar
Descartar
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Aws Hokan, 


We can achieve this by defining a new Boolean field and we have to compute it's value based on our condition. Now, We'll use this field in the attrs of the "mark done" button. 

Please find code in comment.

Kindly let us know if you face any issue.

Hope it will be helpful to you.

Thanks & Regards,
Email:   odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

0
Avatar
Descartar
Jainesh Shah(Aktiv Software)

Please find code here :-

You can use below code.

# python code:

from odoo import api, fields, models

class MailActivity(models.Model):
_inherit = "mail.activity"

display_mark_done = fields.Boolean(compute="_compute_display_mark_done")
@api.depends("user_id")
def _compute_display_mark_done(self):
for rec in self:
rec.display_mark_done = self.env.user.id == rec.user_id.id

<!--xml code:-->
<!--We'll user 'display_mark_done' field in the attrs of 'mark as done' button like below.-->
<!--please make sure that the priority is set to 100 so that other views can't override our view.-->

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

<odoo>
<record id="mail_activity_view_form_popup_inherited" model="ir.ui.view">
<field name="name">mail.activity</field>
<field name="model">mail.activity</field>
<field name="priority" eval="100"/>
<field name="inherit_id" ref="mail.mail_activity_view_form_popup"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_done']" position="attributes">
<!--other domains are coming from base view and we don't want to override it-->
<attribute name="attrs">
{'invisible': ['|', '|',
('display_mark_done', '=', False),
('activity_category', 'in', ['meeting', 'tax_report']),
('chaining_type', '=', 'trigger')]}
</attribute>
</xpath>
</field>
</record>
</odoo>

Avatar
Nimisha Muralidhar
Best Answer

Hi

You will need to add a condition to the visibility of the button based on the current user's role as the assignee. Use the attrs attribute to define the condition.

Thank You

-1
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi 

Please try the code given below,

<button name="action_mark_done" string="Mark Done" type="object"
        attrs="{'invisible': [('user_id', '!=', uid)]}"/>

Hope it helps

-1
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now