Hello Karim
please check following code written in odoo.
There are 2 fields customer_rank and supplier_rank and it update values based on res_partner_search_mode context value (customer or supplier).
you can pass customer or supplier in context.
< field name="partner_id" context="{'res_partner_search_mode': 'supplier'}" / >
Another ways : you can apply domain based on supplier_rank(integer) or customer_rank(integer) field available in res_partner model.
< field name="partner_id" domain="[('customer_rank', '>=', 1)]"/>
@api.model_create_multi
def create(self, vals_list):
search_partner_mode = self.env.context.get('res_partner_search_mode')
is_customer = search_partner_mode == 'customer'
is_supplier = search_partner_mode == 'supplier'
if search_partner_mode:
for vals in vals_list:
if is_customer and 'customer_rank' not in vals:
vals['customer_rank'] = 1
elif is_supplier and 'supplier_rank' not in vals:
vals['supplier_rank'] = 1
return super().create(vals_list)
Thanks & Regards,
CandidRoot Solutions Pvt. Ltd.
Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015