def action_create_sale_order(self):
self.ensure_one()
if not self.product_ids:
raise ValidationError("Please select a product to create a Sale Order.")
return {
'name': 'Sale Order',
'view_mode': 'form',
'res_model': 'sale.order',
'type': 'ir.actions.act_window',
'target': 'new',
'context': {
'default_partner_id': self.partner_id.id,
'default_order_line': [(0, 0, {'product_id': product.id, 'product_uom_qty': 1}) for product in
self.product_ids],
'default_helpdesk_ticket_id': self.id,
},
}
This solution looks simple and makes sense. However,matter what field I pass to order line it doesn’t work
New contributor
Jay Gadhiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.