Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

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

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
developmentormmodel
1 ตอบกลับ
13847 มุมมอง
อวตาร
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
อวตาร
ละทิ้ง
อวตาร
Darrel
ผู้เขียน คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
How i can verify record then save in Odoo 12?
orm model
อวตาร
0
ก.ย. 19
4172
Why pool.get(model) is used to get a model instance instead of pool[model]?
development orm
อวตาร
อวตาร
อวตาร
2
ก.พ. 17
11743
Get model data in a controller แก้ไขแล้ว
orm model controller
อวตาร
อวตาร
อวตาร
อวตาร
4
ต.ค. 21
38513
Usage of ORM methods and ORM API documentation?
database orm model
อวตาร
อวตาร
1
มี.ค. 15
6031
why res.config model in odoo is TransientModel not Model ?
wizard orm model TransientModel
อวตาร
อวตาร
1
ส.ค. 25
4698
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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