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

Odoo 10 : Make a specific field of popup window only readable

Suscribirse

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

Se marcó esta pregunta
viewsrelationshipreadonlyodoo10
5 Respuestas
6258 Vistas
Avatar
Zied Haffoudhi

Hi guys,


I'm stuck here :


<notebook>
<page string="purchase_inquiry_ids">
<!--This is a One2many field relation-->
<field name="purchase_inquiry_ids" context="{'default_purchase_order_id': active_id}"/>
</page>
</notebook>
 


When I click add an item, the purchase_order_id display the current id but I want to add a readonly="1" attribute to this field. 

I really appreciate your help to resolve this.

0
Avatar
Descartar
Avatar
Bejaoui Souheil
Mejor respuesta

Hi,

First, create a new form view for your model where you do all customization needed.

After that use "fields_view_get" for the purchase_inquiry_ids model to return this custom view when your context has "default_purchase_order_id" as a key.

@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
     if view_type == 'form' and self.env.context.get('default_purchase_order_id'):
         view_id = "the_custom_view_id"
     return super(YourClass, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)

Best regards.

1
Avatar
Descartar
Avatar
Zied Haffoudhi
Autor Mejor respuesta

I tried to simplify the code by inherit the default view of the 'purchase_inquiry' and pass an attribute to a specific field but it lead me up to a blind alley.

I was obligated to follow the long way.

I write the view from scratch and there I customize what I need :


<notebook>
<page string="purchase_inquiry_ids">
<!-- <field name="purchase_inquiry_ids" context="{'default_purchase_order_id': active_id}" options="{'always_reload': True}"/> -->
<field name="purchase_inquiry_ids" context="{'default_purchase_order_id': active_id}">
<form string="Demande d'offre Form">
<header>
<button string="Set to draft" type="object" name="draft_progressbar" attrs="{'invisible': [('state', '=', 'draft')]}"/>
<button string="Sent" type="object" name="sent_progressbar" attrs="{'invisible': [('state','=','sent')]}"/>
<button string="Received" type="object" name="received_progressbar" attrs="{'invisible': [('state','=','received')]}"/>
<button string="Accepted" type="object" name="accepted_progressbar" class="oe_highlight" attrs="{'invisible': [('state','=','accepted')]}"/>
<button string="Refused" type="object" name="refused_progressbar" class="oe_highlight" attrs="{'invisible': [('state','=','refused')]}"/>
<button string="Create Command" type="object" name="create_command" class="oe_highlight" attrs="{'invisible': [('state','!=','accepted')]}"/>
<field name="state" widget="statusbar" statusbar_visible="draft, sent, received, accepted, refused"/>
</header>
<sheet>
<group>
<field name="name"/>
<field name="purchase_order_id" readonly="1"/>
<field name="provider_id"/>
<field name="date_inquiry"/>
<field name="datefinal_inquiry"/>
</group>
<group col="6">
<field name="product" placeholder="Product Name"/>
<field name="qte" placeholder="Nbr Emballage"/>
<field name="qte_total_unity" placeholder="Qte Totale"/>
</group>
<notebook>
<page string="Informations">
<group>
<field name="price"/>
</group>
</page>
<page string="Description">
<label for="description" string="Description"/>
<field name="description"/>
</page>
</notebook>
</sheet>
</form>
</field>
</page>
</notebook>



0
Avatar
Descartar
Avatar
Mohammed Amal N
Mejor respuesta

You can give readonly="1" for a one2many field

just add

<field name="purchase_inquiry_ids" readonly="1" context="{'default_purchase_order_id': active_id}"/>


0
Avatar
Descartar
Zied Haffoudhi
Autor

Thank you for your reply Mohamed.

Readonly="1" there disable the possibility to create other record by clicking 'add an item'.

I want to display the popup to create another purchase_inquiry record using the current purchase_order id and I would like in this inherited form the purchase_order_id be disabled or readonly.

Mohammed Amal N

I didn't clearly understand what you are trying to say,

but if you want to add some thing to your one2many and make fields in its view readonly try this:

<field name='your_one2many'>

<tree>

<field name='field1_in_the_one2many_model' readonly='1'/>

<field name='field2> readonly='1'/>

</tree>

</field>

¿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
How to have 2 lists for the same relation field in a form view?
views relationship odoo10
Avatar
0
mar 19
3921
odoo 10 : form for picking with only one field
views odoo10
Avatar
Avatar
Avatar
2
dic 19
3732
How to hide fields in the create and edit popup view?
views odoo10
Avatar
0
nov 18
3874
Make readonly start_date, end_date from sale order view Resuelto
views readonly sale.order.form
Avatar
Avatar
Avatar
2
ago 25
1318
[Odoo 10] what is the best way to duplicate an existing view? Resuelto
views xml odoo10
Avatar
Avatar
Avatar
2
nov 23
8302
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