Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

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

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
developmentormmodel
1 Répondre
13861 Vues
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
Ignorer
Avatar
Darrel
Auteur Meilleure réponse

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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How i can verify record then save in Odoo 12?
orm model
Avatar
0
sept. 19
4178
Why pool.get(model) is used to get a model instance instead of pool[model]?
development orm
Avatar
Avatar
Avatar
2
févr. 17
11751
Get model data in a controller Résolu
orm model controller
Avatar
Avatar
Avatar
Avatar
4
oct. 21
38522
Usage of ORM methods and ORM API documentation?
database orm model
Avatar
Avatar
1
mars 15
6033
why res.config model in odoo is TransientModel not Model ?
wizard orm model TransientModel
Avatar
Avatar
1
août 25
4701
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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