Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
onlinesaasecommercewebsite_sale
4 Replies
12197 Views
Avatar
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
Avatar
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

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
Avatar
Discard
Pierre de Giorgio
Author

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.

Avatar
Pierre de Giorgio
Author Best Answer

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
Avatar
Discard
Pierre de Giorgio
Author

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?

Avatar
Piotr Słomkowski
Best Answer

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
Avatar
Discard
Avatar
VS
Best Answer

Hi Pierre

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

1
Avatar
Discard
Pierre de Giorgio
Author

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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Add shop and wishlist buttons on new website theme module
ecommerce website_sale
Avatar
0
Feb 22
2926
Odoo 12 - How to Add Field at template
ecommerce website_sale
Avatar
Avatar
2
Jul 19
7157
Why is there no longer a free website?
online saas
Avatar
0
Mar 15
5866
Can we completely disable new user registration on V17 online version?
online ecommerce v17
Avatar
Avatar
Avatar
Avatar
4
May 25
3936
Display product fields on the product page in Ecommerce
product online ecommerce
Avatar
Avatar
2
Jul 24
4207
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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