I'm trying to create dellivery orders based on warehouses selected
i created a function on sale order to create multi delivery orders , but delivery orders not found
This is the code:
import random
from odoo import models , fields,api,_
class SaleOrder(models.Model):
_name='sale.order'
_inherit = 'sale.order'
warehouse_ids = fields.Many2many('stock.warehouse', string='Warehouses')
@api.model
def create(self, vals):
res = super(SaleOrder, self).create(vals)
for line in res.order_line.warehouse_ids:
for w in line:
picking_vals = {
'partner_id': res.partner_shipping_id.id,
'location_id': w.lot_stock_id.id,
'location_dest_id': res.partner_shipping_id.property_stock_customer.id,
'picking_type_id':random.randint(1,6),
}
self.env['stock.picking'].create(picking_vals)
print(picking_vals)
return res
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
warehouse_ids = fields.Many2many('stock.warehouse',string="Warehouses ")
class ProductTemplate(models.Model):
_inherit = 'product.template'
warehouse_id = fields.Many2one('stock.warehouse',string="Warehouse ")
class ProductProduct(models.Model):
_inherit = 'product.product'
warehouse_id = fields.Many2one('stock.warehouse',string="Warehouse ")
it is not exist:
only one delivery and i select two warehouses:
How can i create it from action_confirm method?