Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4335 Lượt xem

I have a new model and controller as below:

class CarOnlineBooking(models.Model):
_name = 'car.online.booking'
_description = 'Fleet Rental Management'
_inherit = ['mail.thread', 'ir.needaction_mixin']

pick_location = fields.Many2one(selection="fleet.vehicle.location", string="Pick Up Location", required=False, )
ret_location = fields.Char(string="Return Location", required=False, )
driver_age = fields.Char(string="Driver's Age", required=False,)
book_start_time = fields.Datetime(string="Pick Up Date and Time", required=False, )
book_end_time = fields.Datetime(string="Return Date and Time", required=False, )


class FleetWeb(http.Controller):
@http.route('/home/vehicle_search', type='http', auth='public', website=True)
def render_vehicle_search(self, **kw):
return http.request.render('fleet_rental.vehicle_search', {

})

@http.route('/home/', type='http', auth='public', website=True)
def navigate_to_detail_page(self):
book = http.request.env['car.online.booking'].sudo().search([])
country_list = http.request.env['res.country'].sudo().search([])
fleet_detail = http.request.env['fleet.vehicle'].sudo().search([])
return http.request.render('fleet_rental.detail_page', {'countries': country_list, 'fleet': fleet_detail,
'book_detail': book})

I need to get fields for 'pick up date', 'location', 'driver age' etc which can be inputted by user and when i click a search button,these details need to be saved in the odoo database. As you can see, I am  passing data from three models in http.request.render where the 'book, model is empty. I need to fill it with values entered by the user

Please help on how to write the template in view


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Create a form to input user values and make a post request, write a router to get values. For reference have a look at the odoo website contact forms.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thank You..Could you please give the link to odoo contact website forms..i installed the app

Ảnh đại diện
Huỷ bỏ
Tác giả

I created the form and did the post request.how to get the values i enter in the website at the router side.pls help

you can get values from kwargs

Tác giả

If possible could you pls give a sample code or a link

addons/website_blog, addons/website_form, addons/website_hr, addons/website_sale

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 6 17
2649
1
thg 4 19
4229
3
thg 1 24
17432
0
thg 11 16
3629
2
thg 7 25
4669