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
    • Artificial Intelligence
    • 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ó
    • Property Management
    • 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
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

Dynamic Domain for states

Subscriure's

Get notified when there's activity on this post

This question has been flagged
domain_filter
1 Respondre
4505 Vistes
Avatar
Naren R

Hi, 

Appreciate if you could help out with this domain for states.

Database model overview

  1. risk_state : Master table for all risk states in various risk assessment
  2. risk_flow : Flow for a particular risk assessment
  3. risk_flow_lines: The flow path for a particular risk assessment


Code


RiskStateModel(models.Model):
name : string

RiskFlowModel(models.Model):
name : string
risk_assessment_name: string
risk_flow_lines: One2Many( comodel = 'risk_flow_line' )

RiskFlowLine( models.Model)
inbound_state: Many2one( comodel = 'RiskStateModel' )
outbound_state : Many2Many( comodel = 'RiskStateModel')

The above setup allows me to define a RiskFlowModel for different type of risk assessments (e.g. Control Assessment, Loss Event, etc).

The issue I face is when I want to get the domain of possible states in a risk assessment i.e.

ControlAssessmentModel(model.Model)
    current_state_id                   = Many2One( comodel = 'RiskStateModel')
   domain_for_next_risk_states = Many2One( comodel = 'RiskStateModel')


For example suppose the following is setup in the database

Risk State Model

id

name

0

Draft

1

Control Assessment Required

2

Control Assessment OK

3

Control Assessment Fail

Risk Flow Model

id

Name

1

Control Assessment


Risk Flow Lines

id

risk_flow_id

inbound_state_id

risk_state_flow_id

(Many2Many rel)

1

1

( i.e. Control Assessment )

0 (i.e. Draft)

1

( 1st step is a control assesment)

2

1

1

2

Risk Flow Many2Many Model

risk_flow_line_id

outbound_state_id

comment

1

1

Draft can only go to assessment required

2

2

Assessment required can go to Control Assessment OK

2

2

Assessment required can go to Control Assessment Fail





How do I write the domain in the Control Assessment Model to give the available next risk assessment states?

Options

  1. Write a function : I can write a function that returns the following but I don't know how to get the right trigger for it
return { 'domain' : {'next_state_id_domain' : [ ('id' , 'in' , state_ids ) ]} }


     2. Web domain field

 I have used web domain field before but I am not sure how to modify it for this use case. 


Appreciate your comments - this use case is quite practical for risk assessments when there is no fixed path as things happen all the time and you need to be able to dynamically define flows.




0
Avatar
Descartar
Avatar
Adil Akbar
Best Answer

You can follow this: https://youtu.be/XGqXEL2qQmE

Hope it helps,

Thanks

0
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
Related Posts Respostes Vistes Activitat
Odoo v16 domain, how to create a domain by user.company_id
domain_filter
Avatar
Avatar
1
de nov. 22
7063
Filtering domain
domain_filter
Avatar
Avatar
2
de jul. 22
5605
Search domain : multiple condition Solved
domain_filter
Avatar
Avatar
2
de maig 18
11539
Odoo Web Service API - Search Domain Matching ? Solved
domain_filter
Avatar
Avatar
2
de jul. 17
9017
Filtering orders, purchases, invoices based on a product field Solved
domain_filter
Avatar
5
de jul. 15
7529
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 Svenska ภาษาไทย 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