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

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
3590 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.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How to hide odoo from Wappalyzer
technical odoo
Avatar
Avatar
1
may 24
3156
Odoo - Add a dynamic <filter domain="xxxxx"
odoo v14
Avatar
Avatar
1
may 24
4057
Add files in the website form
technical odoo
Avatar
Avatar
Avatar
2
jun 23
3532
How to use a custom domain with Odoo v14?
odoo v14
Avatar
Avatar
1
abr 24
28588
auto filled record field in another page when create new record
odoo v14
Avatar
Avatar
1
nov 22
3366
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