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

How to Disable edit option in form when the state is done

Suscribirse

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

Se marcó esta pregunta
11
2 Respuestas
14026 Vistas
Avatar
Jesny Sebastin

Hi,

  I need to make all the fields in the entire form read-only when   the state is done.I know we can do it by adding attrs="{'readonly':[('state','=','done']}" for each field. But i am looking for another method.i tried by adding record rule.But it doesn't work at all.

0
Avatar
Descartar
Chris TRINGHAM

https://www.odoo.com/forum/help-1/question/is-there-any-way-that-i-can-make-a-entire-form-readonly-132701

Waleed Ali Mohsen

https://www.odoo.com/forum/help-1/question/how-to-disable-edit-form-when-state-is-done-of-form-121296

Avatar
Michael Jurke
Mejor respuesta

If the question was about edit-ability - and ir.rule does not work for you (as it did not work for me, trying and searching for hours), then you can extend the write method:

    @api.multi
    def write(self, vals):
        if any(state == 'done' for state in set(self.mapped('state'))):
            raise UserError(_("No edit in done state"))
        else:
            return super().write(vals)

Trying to edit in done state will result in the Alert with your User Error message.

1
Avatar
Descartar
Nicolaus Hartmann

I used your suggestion Michael, and it worked fabulously. I went alittle further with it to check against called methods, something like this:

@api.multi

def write(self, vals):

invoice_refund = request.params.get('method') in 'invoice_refund'

move_reconcile = request.params.get('method') in ('assign_outstanding_credit', 'remove_move_reconcile')

group_account_edit = self.env.user.has_group('custom_sec_group.group_account_edit')

_logger.debug('Requested params method: [%s.%s]' % (request.params.get('model'), request.params.get('method')))

_logger.debug('Allow invoice_refund method: %s', invoice_refund)

if any(state != 'draft' for state in set(self.mapped('state'))

if not (group_account_edit or invoice_refund or move_reconcile)):

raise UserError(_('Edit allowed only in draft state. [%s.%s]' % (request.params.get('model'), request.params.get('method'))))

else:

_logger.info('Written vals: %s', vals)

return super().write(vals)

cteng

Hi, where should I put this write method?

Michael Jurke

@cteng You'll need to extend the model for which you want to disallow editing and override the write there.

Avatar
Bernardo
Mejor respuesta

@Michale Jurke, I tried your solution but got:
`AttributeError: module 'odoo.api' has no attribute 'multi'` 

0
Avatar
Descartar
Niyas Raphy (Walnut Software Solutions)

remove @api.multi

¿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
Onchange function not loading values on form
11
Avatar
Avatar
2
oct 18
3553
error in migrating module v8 to v11 Resuelto
11
Avatar
Avatar
Avatar
3
oct 18
4387
Is Odoo a stateless web application?
11
Avatar
Avatar
1
mar 18
5179
[11.0] invoicing of timesheet for multiple salesorders
11
Avatar
0
nov 17
3278
how to eliminate the "Create/edit" option at the quotation Resuelto
odoo 11
Avatar
Avatar
Avatar
2
abr 23
12975
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.

Sitio web hecho con

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