Ir al contenido
Odoo Menú
  • Inicia 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 propiedades
    • 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
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

Function field method is not called for tree view

Suscribirse

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

Se marcó esta pregunta
treeviewopenerp7function_fieldfunctionfieldodoo-update
2 Respuestas
8298 Vistas
Avatar
Eric

Hello,  I have a function field in a tree view that is supposed to display a calculated field, but for some reason the field is not being recalculated whenever I go to the tree view.  I know the function that calculates the field is not being called because I put a breakpoint in the beginning of the method, and it never stops on that breakpoint.  Does anyone know why a method for a functional field would not be called?  

Here is my field definition:

'days_remaining_func': fields.function(_get_days_remaining_func, method=True, type="integer", string="Days Remaining", store=True),


Here is my method:

def _get_days_remaining_func(self, cr, uid, ids, field_name, arg, context={}):

    # calculate the remaining days by subtracting the exp_date - todays date

    res = {}

    for rec in self.browse(cr, uid, ids):

        if not rec.support_exp_date:

            res.update({rec.id:{ field_name: None }})

            continue

        exp_date = datetime.strptime(rec.support_exp_date, "%Y-%m-%d")

        todays_date = datetime.now()

        days_remaining = exp_date - todays_date

        days_remaining = days_remaining.days

        res.update({rec.id:{ field_name: days_remaining }})

    return res

0
Avatar
Descartar
Avatar
Axel Mendoza
Mejor respuesta

The field does not recalculate because of it's defined with store=True

1
Avatar
Descartar
Avatar
Anil Kesariya
Mejor respuesta

HI Eric,

The issue suspected from your code is if your function method is call for only one field.

Than you can directly assigned return value to ID, you don't need to pass value with field. If your method is called for any new records means this is the fault.

Currently you did this.

 res.update({rec.id:{ field_name: None }}) 

Instead try this

res[rec.id] = your_val or None  

Or if your method is not called for already calculated record it means its store=true issue.

Here is the explanation of store=true..

When you define any functional field. than you will have

these possibilities :

when you set store=True it once the value of this will calculated will be stored in database and so ID of that record will not pass in list to recalculate if it is already calculated.

when  you haven't applied store=True than all the that ID will be pass to recalculate if any changes made on that record.

or

If you want to reconsecrate your information after storing in database than you can use store = {} (dictionary option)

Here in dictionary you pass the number of model and fields based on that your fields values is going to update and it will store as well.

The real example of store you will find in account module with account.invoice model. functional field with store= {}.

Any one who knows more about functional field than can improve my Answer.

Hope this will help.

Rgds,

Anil.








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
[SOLVED] OpenERP 7: Tree view - Order by date of creation and not by name Resuelto
treeview openerp7
Avatar
Avatar
Avatar
9
jun 15
14106
openerp7 - Return tree view from class with no new fields
treeview openerp7 return
Avatar
0
jun 18
3504
Display fields.function on tree view Resuelto
treeview one2many function_field
Avatar
Avatar
Avatar
4
ene 24
13899
Functional fields not update on write() -- for sales.order.line (price_subtotal) Resuelto
sale.order.line function_field functionfield
Avatar
Avatar
1
mar 15
8085
how to save functional fields in openerp7?
store openerp7 function_field store=False
Avatar
0
jul 19
4023
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 Svenska ภาษาไทย 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