Skip to Content
Menu
This question has been flagged
3 Replies
7638 Views

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




Avatar
Discard
Best Answer

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.


Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

Related Posts Replies Views Activity
0
Jul 19
2767
2
Dec 19
1648
0
Nov 18
2263
2
Nov 23
5929
2
May 23
5648