This question has been flagged
2 Replies
6250 Views

Hi,


I have started working recently with Odoo, so I assume that I'm still doing "easy tasks" but I can't find a solution by our own.


I have started creating a new module using scaffolding. In this module I wanted to extend the Sales application adding a new field to the 'sale.order' model, this has been quite easy because is fully documented in many places.


So I have added a new field in the model and inherited the 'sale.view_order_form' view to show/edit our new field. I have also extended 'sale.view_quotation_tree' and 'sale.view_order_tree' to show the data from this field in a column in the tree view.


But now, I'm stuck with filtering. I have seen that is quite similar to how I have extended other views.

        <record id="sale_order_view_search_inherit_quotation_wt" model="ir.ui.view">
            <field name="name">sale.order.search.inherit.quotation.wt</field>
            <field name="model">sale.order</field>
            <field name="mode">primary</field>
            <field name="inherit_id" ref="sale.sale_order_view_search_inherit_quotation"/> <!-- this is the view that we want to extend -->
            <field name="arch" type="xml">
                <!-- We have tried using xpath to locate the place to put the filter -->
                <!--
                <xpath expr="//filter[@name='draft']" position="replace">
                    <filter string="Loading Date" name="loading_date_filter" date="loading_date"/>
                </xpath>
                -->
                <!-- We have tried also using this way -->
                <filter name="draft" position="after">
                    <filter string="Loading Date" name="loading_date_filter" date="loading_date"/>
                </filter>
            </field>
        </record>


I assume that the module is being loaded fine because I can see the info in control panel view editing (in Developer Mode).


I've tried with (and without) primary mode, also adding a priority with different values and using other filters as reference for positioning, but the result is always the same, the new filter is not shown.


Has anybody experienced a similar issue?


Kind regars,

Álvaro

Avatar
Discard
Best Answer

Any solution?

Avatar
Discard
Best Answer

Hi,

 I guess the reference given in the inherit_id field is wrong,

I hope it should be ref='sale.view_sales_order_filter'

Thanks.

Avatar
Discard
Author

Hi,

I thought using the reference at the begining, but revising views definition file:

https://github.com/odoo/odoo/blob/14.0/addons/sale/views/sale_views.xml

and the control panel view editing (in Developer Mode), I saw that the view for quotations is ref="sale.sale_order_view_search_inherit_quotation" and for orders is ref="sale.sale_order_view_search_inherit_sale" and both views inherit from ref='sale.view_sales_order_filter'.

In my case, I want to include the new filter near the filters added in those extended views.