How to Search Sales Orders for Archived Partner Records in Odoo

Customising the Customer Filter in the Search View

To enable a sales order search for archived partner records in Odoo, customisation of the sales order's customer filter in the search view is required, as Odoo's standard functionality does not include archived partner records in search results.

Here’s the customisation required for the sales order's customer filter in the search view:

To modify the search view so that archived partner records are included in sales order searches, update the partner_id field with a customised domain filter.

Odoo Code for Sales Order Search View

External ID: sale.view_sales_order

<field name='partner_id' operator='child_of'/>
Modify the Search View

Customisation of the partner_id field in the search view to include archived partner records:

<field name='partner_id' operator='child_of'domain
'[|', ('active', '=', True), ('active', '=', False)]'
filter_domain='[('partner_id', 'ilike', self)]'/>
Inheriting the Sales Order Search View

Below is a code sample for inheriting the sales order search view to include archived customer records in search results:

<!-- Sale Order search view inherited to include archived customers. -->
<record model='ir.ui.view' id='view_sales_order_filter_mods'> <field name='view.sale.order.search.inherit.sale_extended'/> <field name='model'='sale.order'/> <field name='inherit_id' ref='sale.view_sales_order_filter'/> <field name='arch' type='xml'> <field name='partner_id' position='attributes'> <attribute name='domain'>['|', ('active', '=', True), ('active', '=', False)]</attribute> <attribute name='filter_domain'>[('partner_id', 'ilike', self)]</attribute> </field> </field> </record>

With this customisation, Odoo will include archived partner records when performing a sales order search, improving the visibility and accessibility of past customer data.

Need more development tips?

Stay tuned to our blog.

Dharmesh Patel 31 يناير, 2025
أرشفة
تسجيل الدخول حتى تترك تعليقاً
Difference Between @api.model, @api.multi, and @api.one Decorators in Odoo