Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
8576 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
0
lug 19
3444
2
dic 19
2867
0
nov 18
3203
2
nov 23
7414
2
mag 23
7639