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

Odoo project task tags domain

Subscriure's

Get notified when there's activity on this post

This question has been flagged
1 Respondre
4807 Vistes
Avatar
Willmore BattleShipNet

Project task can have many tags. Now when the user creates a task he can choose from all tags. But he wants to be able to choose tags only from those tags that are used for that project. 


What domain rule should I have on the field "tag" (on the form) to let user when creating new project task to see (and eventually to choose) only those tags that are used in the project the user creates task for?

2
Avatar
Descartar
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

You can do this from the onchange of the project and return the domain.

Ex:

api.onchange('project_id')
def onchange_project(self):
    tag_ids = []
    if self.project_id:
        for task in self.project_id.task_ids:
            tag_ids += task.tag_ids.ids
    return {'domain': {'tag_ids': [('id', 'in', tag_ids)]}}
Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
6
Avatar
Descartar
Willmore BattleShipNet
Autor

Thank you. I tried but got error. What can be wrong with that approach?

I have the following code

class InheritedProjectTask(models.Model):

"""docstring"""

_inherit = 'project.task'

@api.onchange('project_id')

def onchange_project(self):

"""docstring"""

tag_ids = []

if self.project_id:

tag_ids += [task.tag_ids.ids for task in self.project_id.task_ids]

return {'domain': {'tag_ids': [('id', 'in', tag_ids)]}}

With this code installed. I open a Project and click "Create" to open a Task creation form (form for new "project.task" model's object). On that form I click on drop-down "Tags" to list possible "Tags" for the project ("possible tags for the project" are all tags that are used on any of the task of the project the task is created for). And then I get error:

> res = self._obj.execute(query, params)

>

> TypeError: not all arguments converted during string formatting

on the console I see the error

> INFO DB odoo.sql_db: bad query: SELECT "project_tags".id FROM "project_tags" WHERE (("project_tags"."id" in (%s,%s,%s,%s,%s,%s,%s,%s)) AND (("project_tags"."id" not in (%s)) OR "project_tags"."id" IS NULL)) ORDER BY "project_tags"."id" limit 8

2018-08-03 10:40:20,476 12978 ERROR DB odoo.http: Exception during JSON request handling.

What did I do wrong in the code?

Sudhir Arya (ERP Harbor Consulting Services)

See my updated code in answer. It should work now.

Willmore BattleShipNet
Autor

Thank You very much for the proposed solution! I would not come to that in near time! :) But after applying it I can see on the "Tags" field (in debug mode when I hover over "Tags" drop down) that effective Domain is id, in,4,5,6,7,8,9,10,11,12,13,14,18,19,20,22,23,24,25,26,27,28,5,4,5,35 . And that is the problem: it doesn't really take tags from just this project's tasks. Tags from other projetcs tasks appear too which is unwanted. How this can be that all tags are included not just those from tasks of the current project?

Sudhir Arya (ERP Harbor Consulting Services)

It will only show all the tags which are used in the tasks of selected project.

Willmore BattleShipNet
Autor

It is really strange. I do the following: 1) Open "Projects". 2) Click "Create" 3) Create a project with a name "Really new project". 4) I open project "Really new project" tasks window. This window is empty as we didn't create any tasks yet. 5) I click "Create" and a form to create new task appears. 6) I enter task title "This is really new task in a really new project" . 7) In the field "Tags" I click with mouse and drop-down appears with text "No results to show" and I enter "1234657890" (this tag name is never used anywhere so it's completely new tag). I click "Create 1234657890" for this tag to be created and it appears in "Tags" field. So far so good. 8) I press "Save" on the task so that the new record is saved. Task is saved and on the form appears a button "Edit". 9) without reloading a page I click "Edit" and click on the "Tags" for drop-down to appear. Drop-down appears and it contains text "No results to show" (this is good because there are no more tags in that project to be selected because we have not created any other tags). I type "qqq" in "Tags" and create this tag, then on the task form I press "Save" to save that task. Then I navigate to any other project (let's say I navigate to **Another project**) and open one of project's tasks just to see it. And then I navigate to the project "Really new project" and press "Edit" and click "Tags" and I see all the tags appear from other project's. Why?

What I have noticed. If I go to any project (project1) and open a task of it then navigate to another project (project2) and click "Create" to create new task for the project2 then on "Tags" there will be only tags from project1 tasks (as we want) it seems that domain works. BUT if I go to any project (project1) and open a task of it then navigate to another project (project2) and click "Edit" to edit a task (of the project2) then on "Tags" there will be ALL TAGS (as if domain was ineffective). How is that possible?

I have noticed (from looking at the console output) that method onchange is called only when I click "Create" on the task. So I have troubles when I want to edit task because onchange is not called and all tags show up :(.

Is there anything else I could add besides onchange to make domain apply all the time.

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