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

I create the order form from my custom mudule. But I want to display it automatically in form view after its creation. How to do ?


def createOrder(self):

order = self.env['sale.order'].create({
'partner_id': self.client.id,
'validity_date': self.date_end,
'date_order': str(fields.Datetime.to_datetime(datetime.date.today()))
})

for product in self.product_ids:
self.env['sale.order.line'].create({
'product_id': product.id,
'order_id': order.id,
'price_unit': product.list_price,
'price_subtotal': float(self.prix_ht),
'product_uom_qty': product.uom_id.id,
'product_uom': product.uom_id.id
})

Avatar
Discard
Author Best Answer

is it possible to bind this function to a field of type state ?
So that after having created a sale order in my custom module, I go to the "validate" step and i return the view of the sale order

Avatar
Discard
Best Answer

Hi,

For returning a view from code, you can do like this:

return {
'name': _('Appointment'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'hospital.appointment',
'res_id': appointment_rec.id,
}

See: https://www.youtube.com/watch?v=QpzBdLWEWsE

Thanks

Avatar
Discard