Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
readonlymany2manyinversecomputed
2 Respuestas
3164 Vistas
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
Mejor respuesta

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 Mejor respuesta

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
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Computed field value stored even when remove line Resuelto
many2many computed
Avatar
Avatar
Avatar
2
abr 24
4746
Computed many2many field dependencies in Odoo 10
many2many computed
Avatar
1
dic 16
8787
How do I make a button invisible if field (m2m) is False? Resuelto
many2many computed odoo10
Avatar
Avatar
4
feb 20
5140
many2many, records/rows readonly
readonly many2many records
Avatar
Avatar
2
mar 15
10912
Inverse Function ind Odoo 9
treeview inverse odoo9 computed
Avatar
2
jul 16
519
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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