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
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • 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

Dynamic formula in user friendly manner ?

Suscribirse

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

Se marcó esta pregunta
technicalodoov14
2 Respuestas
3599 Vistas
Avatar
Saif Kazi

Greetings, I am familiar with the ability to create custom functions within a model in Odoo, however, I am inquiring if there is a user-friendly method for adding dynamic formulas directly from the form, such as inputting a short Python code that contains formula logic and executing it within the form. Has anyone had experience or knowledge of a solution for this within the Odoo platform? Any suggestions would be highly appreciated.

0
Avatar
Descartar
Avatar
S.M Firoz Ahmed ( Daffodil Software Limited )
Mejor respuesta

It is possible to add dynamic formulas directly from the form in Odoo by using the "Computed Fields" feature. Computed Fields allow you to define a custom function that will be called when certain fields in the form are changed, and the result of that function will be stored in a specific field in the model.

You can create a computed field by going to the developer mode in Odoo and navigate to the desired model and fields. In the fields you can create a new field and select "computed" as the type. Then you will have to write a python function that will be called when the field is computed, this function can make use of other fields in the form to calculate the final value.

Alternatively, you can also use the "onchange" method on fields, this method is called when the value of the field is changed by the user, you can use this method to update other fields with the new value.

It's worth mentioning that both solutions require knowledge of python programming, and it's recommended to test the code before implementing it on the live system.

0
Avatar
Descartar
Saif Kazi
Autor

Hey
thanks a lot for the reply .. actually I already tried this . but I had a one2many field . And the calculation is dependent on other records and not the same record

Avatar
MUHAMMAD Imran
Mejor respuesta

In Odoo, it is possible to create dynamic formulas and calculations directly from the form using the compute attribute. The compute attribute allows you to specify a method that will be called when the field's value is needed. This method can contain any logic or calculations you need to perform, including the use of Python code.


The method should be decorated with @api.depends and should have the same name as the field that you want to calculate. The depends attribute should contain a list of fields that are used in the calculation.


Here is an example of how you might use the compute attribute to create a dynamic formula in an Odoo model:


python

Copy code

class MyModel(models.Model):

    _name = 'my.model'


    x = fields.Integer()

    y = fields.Integer()

    result = fields.Integer(compute='_compute_result')


    @api.depends('x', 'y')

    def _compute_result(self):

        for record in self:

            record.result = record.x + record.y

In this example, the result field is calculated by adding the values of the x and y fields, and the calculation is performed whenever one of those fields changes.


It's worth noting that you can also use compute attribute with the function fields, and you can use them in the form view and in the tree view, it also could be used in the search view.


Keep in mind that the method decorated with @api.depends should be on the same model that the fields it depends on, otherwise, it will not work as expected

0
Avatar
Descartar
¿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
How to hide odoo from Wappalyzer
technical odoo
Avatar
Avatar
1
may 24
3159
Odoo - Add a dynamic <filter domain="xxxxx"
odoo v14
Avatar
Avatar
1
may 24
4059
Add files in the website form
technical odoo
Avatar
Avatar
Avatar
2
jun 23
3541
How to use a custom domain with Odoo v14?
odoo v14
Avatar
Avatar
1
abr 24
28602
auto filled record field in another page when create new record
odoo v14
Avatar
Avatar
1
nov 22
3369
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