Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

how to create dynamic field labels?

Suscribirse

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

Se marcó esta pregunta
fieldv7label
2 Respuestas
21154 Vistas
Avatar
wjn

How can I create dynamic field labels in the form view?

For example for the name, I want to have a label "Company" if it's a company, and the label "Lastname" if it's a contact.

Ideally it should be something like this:

<field name="name" string="{[('Company',[('is_company','=', True)]), ('Lastname',[('is_company','=', False)]) }"/>

How to manage this?

3
Avatar
Descartar
Avatar
Hiral Patel (hip)
Mejor respuesta

Hello,

You can do like :

<label for="name" string="Company" attrs="{'invisible': [('is_company','=',False)]}"/>

<label for="name" string="First Name" attrs="{'invisible': [('is_company','=',True)]}"/>

Thanks.

4
Avatar
Descartar
Alexander

Hi, Do you test that? I tryed that solution, but when is_company equals True, Form is can not be saved.

Hiral Patel (hip)

I have tested this and it's working at my end. I have tested on runbot with latest revision and it's allow me to save record even when is_company equals True.

wjn
Autor

Thanks, I will give it a try. Most things I tried before messed up the format (how it's display on the view).

Hiral Patel (hip)

In res_partner_view.xml you will get record for partner form (having id ="view_partner_form"). In place of <label for="name"/> apply the code and then update your server. Otherwise enable debug mode and change it for your test purpose that it's working or not. I hope it will solve your problem.

George

Dear Friends, I would like to change field label(string) while onchange many2one field. I have configured few items in that object. I could not use fields_view_get. While i onchange i am able to update field string but is not reflected in the view. def onchange_ini_temp_id(self, cr, uid, ids, initiative_category_id, context=None): val = {} view_id=None view_type='form' toolbar=False submenu=False res = super(project_project, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) fields = res.get('fields', {}) doc = etree.XML(res['arch']) for node in doc.xpath("//field[@name='release']"): node.set('invisible', "0") node.set('string', 'Test Data') setup_modifiers(node, res['fields']['release']) res['arch'] = etree.tostring(doc) self.fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False) return res Thank you

Dr Obx

The easiest option is as Hiral suggested, just show or hide label depending on some field value. Looking for better solution as well :) However it doesn't work as good as it should ;)

Avatar
Alexander
Mejor respuesta

In your case, better way to define two fields and hide one of them when you change is_company.

For example:

<field name="name" attrs="{'invisible': [('is_company','=',True)]}"/>
<field name="company_name" attrs="{'invisible': [('is_company','=',False)]}"/>
1
Avatar
Descartar
wjn
Autor

The field "name" is the default field from res.partner, used for companies AND contacts in V7. I want to keep OpenERP's database as stock as possible, hence my question about dynamic label fields.

¿Le interesa esta conversación? ¡Participe en ella!

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
edit the label name of "Internal Reference" Product
form field label
Avatar
Avatar
Avatar
2
nov 18
5859
How do you create different Partner Labels and Product Labels?
openoffice v7 label
Avatar
0
mar 15
6728
Print a single label on a sheet of labels
v7 print label
Avatar
0
mar 15
4669
OpenERP 7: Adding a label to an invoice
invoice v7 label
Avatar
Avatar
1
mar 15
5573
How to know all fields of an object?
field v7 object
Avatar
Avatar
1
mar 15
8111
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 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