จะสืบทอดมุมมองเฉพาะในโมดูลของเราเองได้อย่างไร? โอดู

สวัสดียามเช้าครับ ขอสืบทอด วิว ODOO บางส่วนครับ เพื่อที่ฉันจะได้ใช้มันโมดูลของตัวเอง ใครช่วยอธิบายฉันหน่อยได้ไหมว่ามีวิธีใดบ้างที่เป็นไปได้?

ขอบคุณล่วงหน้า.!


person CSMaverick    schedule 14.10.2015    source แหล่งที่มา


คำตอบ (2)


ดูการสืบทอด

แทนที่จะแก้ไขมุมมองที่มีอยู่เดิม (โดยการเขียนทับ) Odoo ให้การสืบทอดมุมมอง โดยที่มุมมอง "ส่วนขยาย" ย่อยจะถูกนำไปใช้กับด้านบนของมุมมองรูท และสามารถเพิ่มหรือลบเนื้อหาออกจากพาเรนต์ได้

มุมมองส่วนขยายอ้างอิงถึงพาเรนต์โดยใช้ฟิลด์ inherit_id และแทนที่จะเป็นมุมมองเดียว ฟิลด์โค้งจะประกอบด้วยองค์ประกอบ xpath จำนวนเท่าใดก็ได้ที่เลือกและแก้ไขเนื้อหาของมุมมองพาเรนต์:

<!-- improved idea categories list -->
<record id="idea_category_list2" model="ir.ui.view">
    <field name="name">id.category.list2</field>
    <field name="model">idea.category</field>
    <field name="inherit_id" ref="id_category_list"/>
    <field name="arch" type="xml">
        <!-- find field description and add the field
             idea_ids after it -->
        <xpath expr="//field[@name='description']" position="after">
          <field name="idea_ids" string="Number of ideas"/>
        </xpath>
    </field>
</record>

expr นิพจน์ XPath ที่เลือกองค์ประกอบเดียวในมุมมองพาเรนต์ ทำให้เกิดข้อผิดพลาดหากไม่ตรงกับองค์ประกอบใดเลยหรือมากกว่าหนึ่งตำแหน่ง

Operation to apply to the matched element:

inside
    appends xpath's body at the end of the matched element
replace
    replaces the matched element by the xpath's body
before
    inserts the xpath's body as a sibling before the matched element
after
    inserts the xpaths's body as a sibling after the matched element
attributes
    alters the attributes of the matched element using special attribute elements in the xpath's body

เคล็ดลับ

เมื่อจับคู่องค์ประกอบเดียว แอตทริบิวต์ตำแหน่งสามารถตั้งค่าได้โดยตรงบนองค์ประกอบที่จะค้นหา มรดกทั้งสองด้านล่างจะให้ผลลัพธ์เดียวกัน

<xpath expr="//field[@name='description']" position="after">
    <field name="idea_ids" />
</xpath>

<field name="description" position="after">
    <field name="idea_ids" />
</field>

หวังว่าความช่วยเหลือนี้

person Baiju KS    schedule 14.10.2015

นี่คือวิธีที่ฉันสืบทอดและใช้มุมมองที่มีอยู่ในโมดูลใหม่ของฉัน ฉันต้องการสืบทอดมุมมองการซื้อ ดังนั้นในโมดูลของฉัน ฉันจึงสืบทอดออบเจ็กต์ buy.order

class purchase_order(osv.osv):
_inherit="purchase.order"

//คุณสามารถเพิ่มช่องใดก็ได้ที่คุณต้องการที่นี่ตามปกติ

และฉันสืบทอดมุมมองเช่นนี้ด้านล่าง

<record id="purchase_order_advance_invoice_inherit_form" model="ir.ui.view">
<field name="name">purchase.order.advance.invoice.inherit.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" **ref="purchase.purchase_order_form"**/>

//นี่คือที่ที่ฉันอ้างถึงมุมมองที่ฉันจะได้รับสืบทอด คุณสามารถจบแท็กส่วนที่เหลือได้

person noble_man    schedule 14.10.2015