Search code examples
pythonodooodoo-13

Create a delivery order in inventory from custom module odoo 13


I have created a custom module, in this module, I have a button. The button should create a delivery order in the inventory module ( just like the confirm button in the Sales module). But when I click it, It gives me the error in the pic, and this is my code.

 def delivery_order(self):
    delivery = self.env['stock.picking'].create({
        # 'type': 'out_invoice',
        'state': 'assigned',
        'picking_type_id': 1,
        'partner_id': self.partner_id.id,
        'location_id': 1,
        'location_dest_id': 1,
        'origin': self.name,
        'move_ids_without_package': [(0, 0, {
            'product_id': self.product_id.id,
            'product_uom_qty': self.selected_weight,
            'picking_type_id': 1,

        })]})
    return delivery

enter image description here


Solution

  • You should add name field in the create method because it is a mandatory field, which causes the error.