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

Prevent record creation in computed One2Many or Mayn2Many in Tree/Kanban field

Subscriure's

Get notified when there's activity on this post

This question has been flagged
readonlymany2manyinversecomputed
2 Respostes
3133 Vistes
Avatar
Torsten

Hi,

I created a computed Many2Many field. To make it writable, I used the inverted argument to define a reverse function like so:

document_ids = fields.Many2many(..., compute='_compute_document_ids', inverse='_set_document_ids')
def _compute_document_ids(self): ​...
def _set_document_ids(self): ​...

Then I created a view which makes use of this field with a Kanban or Tree element. So far everything works fine, I can read, create and delete documents.


Now I want to have the Kanban not to be able to create or delete records, only to be able to edit records when opening them. So I tried the following attemps, none of them works:

### 1:
field name="document_ids" mode="kanban" options="{'no_create': True}" /> 

### 2:
field name="document_ids" mode="kanban" create="0" />
### 3:
field name="document_ids">
​tree create="0">
​ ...


No matter if I use Kanban/Tree here, I still have the "add" or "add a line" option. When I make the field readonly, then the add/delete options disappear. But when I open the record details, I also cannot edit the (because read only).


What am I missing? I need to have a computed field for showing related Many2Many records, I do not want to be able to add/remove records from the parent record but be able to edit them in detail view by clicking on them.

THX



0
Avatar
Descartar
Avatar
Nomadoo
Best Answer

To achieve your goal of making the Kanban view not able to create or delete records, but still be able to edit them when opening, you can use a combination of the following approaches:


    Make the Field Readonly in Kanban:

    Set the readonly attribute for the document_ids field in the Kanban view to prevent creating or deleting records directly from the Kanban view.


Use a Separate Form View for Editing:

Create a separate form view for editing the records and use it when clicking on a record in the Kanban view. This allows you to control the edit behavior independently.

Then, define a form view for the model where you can customize the behavior as needed.


When clicking on a record in the Kanban view, Odoo will open the form view specified in the model.


Use a Related Field for Display:

If you only need to display related records in the Kanban view and do not require direct editing, you can use a related field for display purposes in the Kanban view.


Then, define a related field in your model. 


    display_document_ids = fields.Many2many(related='document_ids')


    Note: This approach will only allow displaying related records in the Kanban view without the ability to edit them directly.


Choose the approach that best fits your requirements. If you need to customize the editing behavior, creating a separate form view for editing is a flexible solution.

1
Avatar
Descartar
Avatar
Torsten
Autor Best Answer

Hi. Thanks for your answer. 

According to it I created another view for editing the detail data (in my case Document). Odoo also uses this view correctly to display the detail date and I am also able to edit the record with this view.

But as soon as I make the Many2Many / One2Many field *readonly* in the parent view then the detail data view is also *locked* so that I cannot edit data anymore.

The same result also if I replace the Kanbank Many2Many with a tree.


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
Computed field value stored even when remove line Solved
many2many computed
Avatar
Avatar
Avatar
2
d’abr. 24
4718
Computed many2many field dependencies in Odoo 10
many2many computed
Avatar
1
de des. 16
8769
How do I make a button invisible if field (m2m) is False? Solved
many2many computed odoo10
Avatar
Avatar
4
de febr. 20
5116
many2many, records/rows readonly
readonly many2many records
Avatar
Avatar
2
de març 15
10868
Inverse Function ind Odoo 9
treeview inverse odoo9 computed
Avatar
2
de jul. 16
519
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