Here is the function I want to call. It is part of another model.
def get_domain_for_onchange_partner_id(self, sale_or_picking_id):
domain = {'carrier_id': [],
'delivery_service_id': []}
if sale_or_picking_id.partner_id.id or sale_or_picking_id.carrier_id.id:
result = self.get_delivery_option_default(sale_or_picking_id.carrier_id, sale_or_picking_id.partner_id)
if result and result["level"]:
default = result['delivery_option_default']
# ignore carrier related default values when defaults come from a carrier itself
if result["level"] != "carrier":
sale_or_picking_id.carrier_id = default.delivery_carrier_id
domain['carrier_id'].append(('id', 'in', default.allowed_carrier_ids.ids))
domain['delivery_service_id'].append(('id', 'in', default.allowed_service_ids.ids))
self.set_default_options(sale_or_picking_id, default)
if sale_or_picking_id.carrier_id.id:
domain['delivery_service_id'].append(('carrier_id', '=', sale_or_picking_id.carrier_id.id))
return domain