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 you define specific (not default) views for each view mode type (form, tree, etc.) in act_window xml?

ติดตาม

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

คำถามนี้ถูกตั้งค่าสถานะ
10 ตอบกลับ
63954 มุมมอง
อวตาร
John Baldwin

I can't understand how to define specific views for each view mode... This is what I want to do:

in my act_window record I have "<field name="view_mode">tree,form</field>" defining that tree and form views are needed. I want to use "my_custom_tree_view" and "my_custom_form_view" for those types respectively. I've tried using a filed called "views" with (name, type) pairs. I've tried using "view_ids" the same way. I've tried using multiple "view_id" with ref's and that doesn't work.... Can someone please show me an example of assigning custom views to multiple view modes please?

<record model="ir.actions.act_window" id="test_action"> 
<field name="name">A Test Action</field> 
<field name="res_model">some.model</field>
<field name="view_mode">tree, form</field>
<!-- a field to describe my specific tree view and form view -->          <<<<<---- HELP ME HERE! 
</record>

1
อวตาร
ละทิ้ง
อวตาร
Temur
คำตอบที่ดีที่สุด

You can specify view to use as follows:

<field name="view_id" ref="the_xml_id_of_view"/> -just xml id if the view is in the same module

<field name="view_id" ref="module_name.the_xml_id_of_view"/> -external xml id if the view is in another model (pay attention to the dot notation)

You can also specify custom search view:

<field name="search_view_id" ref="xml_id_or_external_xml_id_as_needed"/>

Also you can manipulate default views using sequence="N" property, by setting lower N than it is in the active default view.

4
อวตาร
ละทิ้ง
Ankit H Gandhi(AHG)

Big Thanks @ Temur

+1

อวตาร
Reem Elobeid
คำตอบที่ดีที่สุด

This worked for me:

Add view_ids to your action, as follows

<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('xml.id.of.tree.view')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('xml.id.of.form.view')})]"/>
5
อวตาร
ละทิ้ง
อวตาร
james_p
คำตอบที่ดีที่สุด

Please check this code from product module. This should answer the question.


<record id="product_variant_action" model="ir.actions.act_window">            
    <field name="name">Product Variants</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">product.product</field>
    <field name="context">
        {'search_default_product_tmpl_id': [active_id],
        'default_product_tmpl_id': active_id}
    </field>
    <field name="search_view_id" ref="product_search_form_view"/>
    <field name="view_ids" eval="[(5, 0, 0),
        (0, 0, {'view_mode': 'tree'}),
        (0, 0, {'view_mode': 'form', 'view_id': ref('product_variant_easy_edit_view')}),
        (0, 0, {'view_mode': 'kanban'})]"/>
    <field name="help" type="html">
        <p class="oe_view_nocontent_create">
            Click to define a new product.
        </p>
    </field>
</record>
2
อวตาร
ละทิ้ง
Sanjay Jamod (sja)

Thanks.. it's works for me

อวตาร
Vladimir
คำตอบที่ดีที่สุด

You can in the action specify search_view_id, form_view_id and so on

<record id="action_res_usuarios" model="ir.actions.act_window">
            <field name="name">Usuarios</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.users</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_usuarios_tree"/>
            <field name="search_view_id" ref="view_usuarios_search"/>
            <field name="form_view_id" ref="view_users_simple_form"/>
            <field name="help">Create and manage users that will connect to the system. Users can be deactivated should
                there be a period of time during which they will/should not connect to the system. You can assign them
                groups in order to give them specific access to the applications they need to use in the system.
    </field>
        </record>

1
อวตาร
ละทิ้ง
อวตาร
Zbik
คำตอบที่ดีที่สุด

The easiest way is if you define additional ir.ui.view, separate for tree and form, like this (in effect three records):

     <record model="ir.actions.act_window" id="test_action"> 
       <field name="name">A Test Action</field> 
       <field name="res_model">some.model</field>
       <field name="view_type">form</field>
       <field name="view_mode">tree, form</field>
    </record>

    <record model="ir.ui.view" id="some_name_form">
      <field name="name">some_name_form</field>
      <field name="model">some.model</field>
      <field name="arch" type="xml">
        <form>
            <field name="name"/>
        </form>
      </field>
    </record>

    <record model="ir.ui.view" id="some_name_tree">
      <field name="name">some_name_tree</field>
      <field name="model">some.model</field>
      <field name="arch" type="xml">
        <tree>
            <field name="name"/>
        </tree>
      </field>
    </record>

 

0
อวตาร
ละทิ้ง
John Baldwin
ผู้เขียน

Thanks for the answer, but it does not solve the problem of multiple form/tree views and selecting the proper one.

Zbik

Why not solve? views not wroks? error? you have a menu which call test_action?

อวตาร
Arsenty Karamurza
คำตอบที่ดีที่สุด

I'll explain with an example:

This is a menuitem with an action associated to it.

<menuitem name="Measurement Sheets" id="cirem_measurements" parent="cirem_proposition" action="action_measurements" sequence="540"/>

..but it's not a simple xml-defined action:

    <record id="action_measurements" model="ir.actions.server">
<field name="name">Measurement Sheets</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="state">code</field>
<field name="code">action = self.my_measurements(cr, uid, context=context)</field>
<field eval="True" name="condition"/>
</record>

you see, it refers to code, which uses another action as a template for creating a custom action that has specific views assigned to each particular view type (kanban, tree, form)

so, firstly, here goes an action used as a template:

        <record id="action_measurements_base" model="ir.actions.act_window">
<field name="name">Measurement Sheets</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state', 'in', ('sent', 'draft', 'sale'))]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to fill in a new measurement sheet based on the measurement template.
</p><p>
Odoo will help you efficiently handle the complete sales flow:
quotation, sales order, delivery, invoicing and payment.
</p>
</field>
</record>


The most interesting part is the code that sets different view ids to each view type (based on the template-action):

(notice how one can redefine other action's properties too)

    def my_measurements(self, cr, uid, context=None):
IrModelData = self.pool['ir.model.data']
actionObject = IrModelData.xmlid_to_object(cr, uid, 'cirem.action_measurements_base', context=context)
action = actionObject.read(['name', 'help', 'res_model', 'target', 'domain', 'context', 'type', 'search_view_id'])
if not action:
action = {}
else:
action = action[0]
# action['name'] = 'Measurements' SET OTHER PROPERTIES LIKE THIS
tree_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'sale.view_order_tree')
form_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'cirem.measurements_view')
action.update({
'views': [
[tree_view_id, 'tree'],
[form_view_id, 'form'],
[False, 'graph'],
[False, 'calendar'],
[False, 'pivot']
],
})
return action

Ta-Da! Please let me know if I can be of any more help to you :)

0
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

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

ลงชื่อ
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • 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