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

How do I dump all the fields and values in a model (ideally including those from relationships)?

Suscribirse

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

Se marcó esta pregunta
developmentormmodel
1 Responder
13875 Vistas
Avatar
Darrel

Specifically, I am trying to see all of the data included in a product record, and I'm doing it from the create() method of a stock.move child class I have created.

If I use: _logger.info(', '.join(dir(product)))

I get (exhibit A). It does have the fields, but it also has all of the models helper functions and properties, and there is so much there that it is very hard to see just the actual fields from the database that have to do with products (like weight, SKU, etc).

I found a function called get_fields() in the model source, but it seems to dump all available schema and metadata surrounding products, way more than I need, and does not provide the actual values in the record.

I just want a dictionary of key value pairs for product and it's related models that I have loaded using browse(). Does something like that exist?

 

Exhibit A:

CONCURRENCY_CHECK_FIELD, _BaseModel__export_rows, _BaseModel__export_xml_id, __add__, __and__, __class__, __contains__, __delattr__, __dict__, __doc__, __eq__, __format__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __init__, __int__, __iter__, __last_update, __le__, __len__, __lt__, __metaclass__, __module__, __ne__, __new__, __nonzero__, __or__, __reduce__, __reduce_ex__, __repr__, __setattr__, __setitem__, __sizeof__, __str__, __sub__, __subclasshook__, __unicode__, __weakref__, _add_field, _add_magic_fields, _add_missing_default_values, _add_sql_constraints, _all_columns, _apply_ir_rules, _auto, _auto_end, _auto_init, _browse, _build_model, _cache, _check_concurrency, _check_ean_key, _check_m2m_recursion, _check_qorder, _check_record_rules_result_count, _check_recursion, _check_removed_columns, _check_selection_field_value, _columns, _compute_display_name, _compute_uos_qty, _constraint_methods, _constraints, _context, _convert_records, _convert_to_cache, _convert_to_write, _cr, _create, _create_parent_columns, _create_table, _custom, _date_name, _defaults, _depends, _description, _dirty, _drop_constraint, _execute_sql, _extract_records, _field_create, _fields, _find_partner_from_emails, _garbage_collect_attachments, _generate_m2o_order_by, _generate_order_by, _get_access_link, _get_column_infos, _get_default_calendar_view, _get_default_form_view, _get_default_search_view, _get_default_tree_view, _get_domain_dates, _get_domain_locations, _get_external_ids, _get_followers, _get_image_variant, _get_inbox_action_xml_id, _get_message_data, _get_name_template_ids, _get_partner_code_name, _get_price_extra, _get_subscription_data, _get_tracked_fields, _get_user_chatter_options, _get_xml_ids, _group_by_full, _has_onchange, _ids, _in_cache_without, _inherit, _inherit_fields, _inherits, _inherits_check, _inherits_join_add, _inherits_join_calc, _inherits_reload, _inherits_reload_src, _init_constraints_onchanges, _init_function_fields, _init_manual_fields, _is_an_ordinary_table, _is_product_variant_impl, _local_constraints, _local_sql_constraints, _log_access, _log_create, _m2m_raise_or_create_relation, _m2o_add_foreign_key_checked, _m2o_add_foreign_key_unchecked, _m2o_fix_foreign_key, _mail_flat_thread, _mail_mass_mailing, _mail_post_access, _mapped_cache, _mapped_func, _message_add_suggested_recipient, _message_extract_payload, _message_find_partners, _message_get_auto_subscribe_fields, _message_preprocess_attachments, _model, _module, _name, _name_search, _needaction, _needaction_domain_get, _o2m_raise_on_missing_reference, _onchange_eval, _onchange_methods, _onchange_spec, _order, _original_module, _ormcache, _parent_columns_exist, _parent_name, _parent_order, _parent_store, _parent_store_compute, _patch_method, _pop_field, _prefetch_field, _prepare_setup_fields, _product_available, _product_available_text, _product_code, _product_lst_price, _product_partner_ref, _product_price, _purchase_count, _read_from_database, _read_group_fill_results, _read_group_format_result, _read_group_get_domain, _read_group_prepare, _read_group_prepare_data, _read_group_process_groupby, _rec_name, _rec_name_fallback, _recompute_check, _recompute_done, _recompute_todo, _register, _register_hook, _revert_method, _sales_count, _save_constraint, _save_relation_table, _search, _search_followers, _search_is_follower, _search_message_unread, _search_product_quantity, _select_column_data, _sequence, _set_default_value_on_column, _set_followers, _set_image_variant, _set_product_lst_price, _setup_fields, _sql_constraints, _stock_move_count, _store_get_values, _store_set_values, _table, _table_exist, _track, _transient, _transient_clean_old_rows, _transient_clean_rows_older_than, _transient_vacuum, _translate, _uid, _update_store, _validate_fields, _view_look_dom_arch, _website_url, _where_calc, _write, accessory_product_ids, action_view_routes, active, alternative_product_ids, attribute_line_ids, attribute_value_ids, browse, categ_id, check_access_rights, check_access_rule, check_field_access_rights, check_mail_message_access, check_recursion, clear_caches, code, color, company_id, compute_concurrency_field, compute_concurrency_field_with_access, copy, copy_data, copy_translations, cost_method, create, create_date, create_uid, create_workflow, default_code, default_get, delete_workflow, delivery_count, description, description_purchase, description_sale, display_name, distinct_field_get, ean13, ensure_one, env, exists, export_data, fields_get, fields_get_keys, fields_view_get, filtered, get_access_action, get_empty_list_help, get_external_id, get_formview_action, get_formview_id, get_metadata, get_suggested_thread, get_xml_id, id, ids, image, image_medium, image_small, image_variant, import_data, incoming_qty, invalidate_cache, is_product_variant, is_transient, list_price, load, loc_case, loc_rack, loc_row, location_id, log, lst_price, mapped, mes_type, message_auto_subscribe, message_capable_models, message_change_thread, message_follower_ids, message_get_default_recipients, message_get_email_values, message_get_reply_to, message_get_subscription_data, message_get_suggested_recipients, message_ids, message_is_follower, message_last_post, message_mark_as_read, message_mark_as_unread, message_new, message_parse, message_partner_info_from_emails, message_post, message_process, message_redirect_action, message_route, message_route_process, message_route_verify, message_subscribe, message_subscribe_users, message_summary, message_track, message_unread, message_unsubscribe, message_unsubscribe_users, message_update, modified, name, name_create, name_get, name_search, name_template, need_procurement, new, on_order, onchange, onchange_uom, open_product_template, optional_product_ids, orderpoint_ids, outgoing_qty, packaging_ids, partner_ref, pool, price, price_extra, price_get, pricelist_id, print_report, product_manager, product_tmpl_id, product_type_id, product_variant_count, product_variant_ids, property_account_creditor_price_difference, property_account_expense, property_account_income, property_stock_account_input, property_stock_account_output, property_stock_inventory, property_stock_procurement, property_stock_production, public_categ_ids, purchase_count, purchase_ok, qty_available, qty_available_text, read, read_followers_data, read_group, read_string, reception_count, recompute, redirect_workflow, refresh, rental, resolve_2many_commands, resolve_o2m_commands_to_record_dicts, route_ids, sale_delay, sale_ok, sales_count, search, search_count, search_read, seller_delay, seller_id, seller_ids, seller_qty, signal_workflow, sorted, standard_price, state, step_workflow, sudo, supplier_taxes_id, taxes_id, track_all, track_incoming, track_outgoing, type, unlink, uom_id, uom_po_id, uos_coeff, uos_id, update, user_has_groups, user_review, valuation, view_header_get, view_init, virtual_available, volume, warehouse_id, warranty, website_description, website_message_ids, website_meta_description, website_meta_keywords, website_meta_title, website_published, website_sequence, website_size_x, website_size_y, website_style_ids, website_url, weight, weight_net, with_context, with_env, write, write_date, write_string, write_uid

1
Avatar
Descartar
Avatar
Darrel
Autor Mejor respuesta

I eventually wrote a little function for this. Not sure if there is anything for this built into odoo.

        import pprint
        def model_data(obj):
            fields_dict = {}
            for key in obj.fields_get():
                fields_dict[key] = obj[key]
            return fields_dict

 

1
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 i can verify record then save in Odoo 12?
orm model
Avatar
0
sept 19
4189
Why pool.get(model) is used to get a model instance instead of pool[model]?
development orm
Avatar
Avatar
Avatar
2
feb 17
11760
Get model data in a controller Resuelto
orm model controller
Avatar
Avatar
Avatar
Avatar
4
oct 21
38527
Usage of ORM methods and ORM API documentation?
database orm model
Avatar
Avatar
1
mar 15
6039
why res.config model in odoo is TransientModel not Model ?
wizard orm model TransientModel
Avatar
Avatar
1
ago 25
4705
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