Ive created some delivery methods (from Inventory > Configuration > Shipping methods) which I want to assign to my sale order records. Manually this can be done by clicking on "Add Shipping" button from sale order create view. but How can I do this using ORM?
I know that shipping method object is an instance of delivery.carrier model and I already know sale order record has a carrier_id field. So I tried this (here I'm creating a new sale order object and I want to assign a shipping method to it):
carrier = self.env['delivery.carrier'].search([(...)], limit=1)
order = self.env['sale.order'].create({..., 'carrier_id' : carrier.id,...})
but it doesn't work. how can I assign a shipping method to a sale order record using ORMs?