Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
8678 Lượt xem

I want to know what's the best way to replace a standard tree view for odoo10.

for example this:

<record id="purchase_order_tree" model="ir.ui.view">
<field name="name">purchase.order.tree</field>
<field name="model">purchase.order</field>
<field name="arch" type="xml">
<tree decoration-bf="message_unread==True" decoration-muted="state=='cancel'" decoration-info="state in ('wait','confirmed')" string="Purchase Order">
<field name="message_unread" invisible="1"/>
<field name="name" string="Reference"/>
<field name="date_order" />
<field name="partner_id"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="date_planned" invisible="context.get('quotation_only', False)"/>
<field name="origin"/>
<field name="amount_untaxed" sum="Total Untaxed amount" string="Untaxed" widget="monetary"/>
<field name="amount_total" sum="Total amount" widget="monetary"/>
<field name="currency_id" invisible="1"/>
<field name="state"/>
<field name="invoice_status" invisible="not context.get('show_purchase', False)"/>
</tree>
</field>
</record>

How can I replace this view ?

I need an other order of the fields in my tree view.


Thank you




Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Not sure what you want to do with that. You can modify it with debug mode and edit form view. Here I could show you how I have modify mine:

<record id="purchase_order_tree" model="ir.ui.view">
<field name="name">purchase.order.tree</field>
<field name="model">purchase.order</field>
<field name="arch" type="xml">
<tree decoration-bf="message_unread==True" decoration-muted="state=='cancel'" decoration-info="state in ('wait','confirmed')" string="Purchase Order">
<field name="message_unread" invisible="1"/>
<field name="name" string="Reference"/>
           <field name="date_order" widget="date"/>
<field name="partner_id"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="date_planned" invisible="context.get('quotation_only', False)" widget="date"/>
<field name="origin"/>
<field name="amount_untaxed" sum="Total Untaxed amount" string="Untaxed" widget="monetary" invisible="1"/>
<field name="amount_total" sum="Total amount" widget="monetary"/>
<field name="currency_id" invisible="1"/>
<field name="state"/>
<field name="invoice_status" invisible="not context.get('show_purchase', False)"/>
</tree>
</field>
</record>

As you can see, I switched those two datetime to date only and hide a column, for a clear display. You may also like to add a column as you like to display on the View. Perhaps you could share more information of HOW you wanna see.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

To replace the above tree view , what you have to do is that, just change the id of the record with module_name.original_id . Then you can make the necessary changes inside the record. You can change the order of field etc....

<record id="module_name.purchase_order_tree" model="ir.ui.view">
<field name="name">purchase.order.tree</field>
<field name="model">purchase.order</field>
<field name="arch" type="xml">
<tree decoration-bf="message_unread==True" decoration-muted="state=='cancel'" decoration-info="state in ('wait','confirmed')" string="Purchase Order">
<field name="message_unread" invisible="1"/>
<field name="name" string="Reference"/>
<field name="date_order" />
<field name="partner_id"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="date_planned" invisible="context.get('quotation_only', False)"/>
<field name="origin"/>
<field name="amount_untaxed" sum="Total Untaxed amount" string="Untaxed" widget="monetary"/>
<field name="amount_total" sum="Total amount" widget="monetary"/>
<field name="currency_id" invisible="1"/>
<field name="state"/>
<field name="invoice_status" invisible="not context.get('show_purchase', False)"/>
</tree>
</field>
</record>

 To override any xml views,  just need to make exact id of view to be override following the module name ie, id="module_name.id".

That will replace your original view with the newly created one .

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

if I do that, I have problems with other modules that inherit in this view.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 19
3523
2
thg 12 19
3104
0
thg 11 18
3337
2
thg 11 23
7635
2
thg 5 23
7924