Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
8534 Widoki

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




Awatar
Odrzuć
Najlepsza odpowiedź

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.


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
0
lip 19
3398
2
gru 19
2689
0
lis 18
3171
2
lis 23
7278
2
maj 23
7480