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

I'm trying to create order deliveries for sale order
What can i set the value of picking_type_id in the following function to work correctly when i click on confirm button?

def action_confirm(self):
res = super(SaleOrder, self)
locations = []
for line in res.order_line:
if line.warehouse_ids not in locations:
locations.append(line.warehouse_ids)
picking_vals = {
'partner_id': res.partner_shipping_id.id,
'location_id': line.warehouse_ids.id,
'location_dest_id': res.partner_shipping_id.property_stock_customer.id,
'picking_type_id': ,
'sale_id': res.id

}
self.env['stock.picking'].create(picking_vals)
return res


Avatar
Discard
Best Answer

Hi 

You can search the picking_type_id of Outgoing ,which gives the delivery orders.

self.env['stock.picking.type'].search([
('code', '=', 'outgoing'),
('warehouse_id.company_id', '=', company_id),
], limit=1).id

Regards

Avatar
Discard
Author

it doesn't work for me it putted all delivery orders in the same warehouse that is named YourCompany
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.model
def action_confirm(self):
res = super(SaleOrder, self)
oreders = res.order_line
for loc in oreders.mapped('warehous_id'):
line = oreders.filtered(lambda o: o.warehous_id.id == loc.id)
picking_vals = {
'origin': res.name,
'partner_id': res.partner_shipping_id.id,
'location_id': loc.lot_stock_id.id,
'location_dest_id': res.partner_shipping_id.property_stock_customer.id,
'picking_type_id':self.env['stock.picking.type'].search([
('code', '=', 'outgoing'),('warehouse_id.company_id', '=', loc.company_id.id),], limit=1).id,

Author Best Answer

it doesn't work for me it putted all delivery orders in the same warehouse that is named YourCompany
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.model
def action_confirm(self):
res = super(SaleOrder, self)
oreders = res.order_line
for loc in oreders.mapped('warehous_id'):
line = oreders.filtered(lambda o: o.warehous_id.id == loc.id)
picking_vals = {
'origin': res.name,
'partner_id': res.partner_shipping_id.id,
'location_id': loc.lot_stock_id.id,
'location_dest_id': res.partner_shipping_id.property_stock_customer.id,
'picking_type_id':self.env['stock.picking.type'].search([
('code', '=', 'outgoing'),('warehouse_id.company_id', '=', loc.company_id.id),], limit=1).id,


Avatar
Discard

picking_vals = {
'partner_id': res.partner_shipping_id.id,

'picking_type_id':self.env['stock.picking.type'].search([
('code', '=', 'outgoing'),('warehouse_id.company_id', '=', loc.company_id.id),], limit=1).id,}

Only you need the above fields

Related Posts Replies Views Activity
1
Dec 24
36
2
Mar 24
1333
2
May 23
197
0
Jan 22
2058
1
Mar 15
6212