Skip to Content
Menu
This question has been flagged
2 Replies
2628 Views


Hi,




While editing or creating a quotation, odoo allows the user to choose the Customer of that quotation to be either "just a company" or "an employee of a company"


I would to display only "an employee of a company", like this:




How can I do that?


Thanks in advance for your help!



Avatar
Discard
Best Answer

Hi Hugo,

You just need to add a domain on a Customer field to hide the Company data.

<field name="partner_id" domain="[('parent_id', '!=', False)]"/>

This will show the partner records having a company with it.

Avatar
Discard
Best Answer

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

Avatar
Discard