Hi,
If you need to apply this everywhere in the system where there is a many2one field of the res.partner, better you can override the name_search method and add the domain.
Code sample:
@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
if args is None:
args = []
context = dict(self._context or {})
if not context.get('show_all_partners'):
args += [('parent_id', '=', True)]
return super(ResPartner, self).name_search(name, args, operator=operator, limit=limit)
If you need to apply only on the sales form, you can add a domain for the corresponding field.
Domain:
('parent_id', '=', True)
If you are doing from code, create a inherited record like this,
<record id="sale_order_inherit" model="ir.ui.view">
<field name="name">sale.order.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="partner_id" position="attributes">
<attribute name="domain">[('parent_id','=', True)]</attribute>
</field>
</field>
</record>
Thanks