Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

How do I add a field (internal reference) to products page on webiste?

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
onlinesaasecommercewebsite_sale
4 Trả lời
12218 Lượt xem
Ảnh đại diện
Pierre de Giorgio

I'm trying to figure out how to add a field, in this case "internal reference" to my ecommerce products.

I would like to have it in the product tiles under the product name.  I would also like to have it show up next to the product name in the shopping cart lines.

I'm using Odoo online.

I was able to add it to the html for the product detail page by simply adding the following to the html code.

<span t-field="product.default_code"/>

I'm not sure where to go to edit it on the main products page and in the shopping cart description.

I'm guessing I need to edit the respective views but I'm not sure which.  Any help is greatly appreciated.    


1
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Cybrosys Techno Solutions Pvt.Ltd
Câu trả lời hay nhất

Hi,

Hi, While changing the product variant a javascript function (_onChangeCombination) is running behind to get the product detail of the variant. You can overide the function to change the default product code according to the attribute change.
First add the following code in the html view (<template id="product">) inside the div

<div class="js_product js_main_product">
<span t-attf-class="default_code" t-field="product.default_code"/>
</div>

then inherit the javascript function (_onChangeCombination) and find the html element.

var $default_code = $parent.find(".default_code");

provide the value for the variable.

$default_code.text(combination.default_code);

You can pass the default_code from the python fuction _get_combination_info()

'default_code': product.default_code

Regards

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

Thanks so much for the response. So am I able to do this since I'm using Odoo online? I'm not sure where to inherit the javascript function and pass the defualt_code from the python function. Could you elaborate more on this please.

Aung Ko Ko Lin

Is this the correct way?
<div class="js_product js_main_product">
<span t-attf-class="default_code" t-field="product.default_code"/>
</div>

I also extend the JS you mentioned and I found my JS is called but the value is not changed when we change variant.

Ảnh đại diện
Pierre de Giorgio
Tác giả Câu trả lời hay nhất

Ok, I figured it out.  Here is what I did in case it helps anyone else.

On the shopping cart, edit HTML, from the dropdown select Shopping Cart Lines.

<div>
    <t t-call="website_sale.cart_line_product_link">
        <strong t-field="line.product_id.product_tmpl_id"/>
    </t>
</div>

I changed the field in bold so that it now shows [internal reference] Product Name

On the product detail view:

<h1 itemprop="name" t-field="product.name">Product Name</h1>
<span t-field="product.default_code"/>

I added the line in bold so that the internal reference is now displayed underneath the product name.

On the main product page (table view):

<div class="oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
    <t t-set="product_image_big" t-value="td_product['x']+td_product['y'] &gt; 2"/>
        <t t-call="website_sale.products_item"/>
</div>
<div style="margin-left:10px">
    <t t-if="product.default_code">
        <t t-set="int_ref" t-value="'pn: '+product.default_code" />
            <p t-esc="int_ref" class="text-muted"/>
        </t>
</div>

I added the code in bold. This is the best I could do here.  This will display the Internal Reference at the bottom of each tile.  I would have prefered to show it under the Product Name, but was not able to figure that out.  If anyone has any ideas here that would be great.  I just added the "pn: " to simply prefix the default code with.

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

So although this works, on the product detail view, if you use products with variants it does not show properly. I can see that the images for the variants are fetched, but the variant_id is not passed to the qweb view.

I tried to use product_variant.default_code but it will only show the initial internal reference. When you change a variant option, the default_code is not updated.

Does anyone know how to get the default_code for the variant?

Ảnh đại diện
Piotr Słomkowski
Câu trả lời hay nhất

Simplest way without coding:

On backend: Website -> Configuration (on top menu) -> Websites -> YourWebsiteName -> Product Page Extra Fields (Tab) ->Add Line (Internal Reference).

Go to product page and there is displayed Internal Reference.

Thats all ;)

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

Hi Pierre

Were you able to find a solution to your default_code value with variants?

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

Unfortunately no. We have Odoo Online (SaaS) version, so we don't necessarily have full access to the source code as suggested below.

Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Add shop and wishlist buttons on new website theme module
ecommerce website_sale
Ảnh đại diện
0
thg 2 22
2935
Odoo 12 - How to Add Field at template
ecommerce website_sale
Ảnh đại diện
Ảnh đại diện
2
thg 7 19
7171
Why is there no longer a free website?
online saas
Ảnh đại diện
0
thg 3 15
5881
Can we completely disable new user registration on V17 online version?
online ecommerce v17
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
4
thg 5 25
3951
Display product fields on the product page in Ecommerce
product online ecommerce
Ảnh đại diện
Ảnh đại diện
2
thg 7 24
4227
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now