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

Hi,

I need to override the function of product view in Odoo website shop for add some additional information to the product page.How can i override the corresponding function.Expecting quick response.

Thanks

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

Hi,

To add more information to corresponding page(products) you have to override the corresponding controller method and pass the necessary information to the template.

For overriding an existing controller see this video: How To Inherit Existing Controller in Odoo

See this example in website_sale_delivery module in which a controller defined in website_sale module is inherited and passing new values ,


from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSaleDelivery(WebsiteSale):

@http.route(['/shop/payment'], type='http', auth="public", website=True)
def payment(self, **post):
order = request.website.sale_get_order()
carrier_id = post.get('carrier_id')
if carrier_id:
carrier_id = int(carrier_id)
if order:
order._check_carrier_quotation(force_carrier_id=carrier_id)
if carrier_id:
return request.redirect("/shop/payment")

return super(WebsiteSaleDelivery, self).payment(**post)

File: https://github.com/odoo/odoo/blob/13.0/addons/website_sale_delivery/controllers/main.py

Thanks

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

Hi,

Try the code below.

from odoo.addons.website_sale.controllers.main import WebsiteSale 

class YourClassName(WebsiteSale):
@http.route()
def product(self, product, category='', search='', **kwargs): res = super(YourClassName, self).product(product, category, search)
# Type Your required codes here
return res

For knowing more about the controllers and website customisation visit the following blogs

Odoo website customization

Controllers in odoo

Thanks and regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 22
7410
0
thg 8 20
4611
4
thg 8 20
9335
3
thg 11 23
17443
3
thg 11 24
25102