Hi i am using odoo 14 CE, when we enable display quantity in website for products it shows the quantity in form view , what custom code should i add in my custom module so it displays the quantity in list or Kanban view also in odoo website . Thank you
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
3
Replies
2272
Views
Hi
You can try this code
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="stock_qty" inherit_id="website_sale.products_item" customize_show="True" name="Stock Quantity">
<xpath expr="//div[hasclass('o_wsale_product_information_text')]" position="before">
<div class="col" style="width:300px; height:30px; background: Lavender; color: black; display: -webkit-box;">
<t t-if="product.sudo().qty_available <= 0">
<i class="fa fa-ban" role="img" aria-label="Ban" title="Ban"
style="font-size:20px;color:red"/>
<span style="color:Red;"> Out of Stock </span></t>
<t t-if="product.sudo().qty_available >= 1 and product.sudo().qty_available <= 5">
<i class="fa fa-warning" role="img" aria-label="Warning" title="Warning"
style="font-size:20px;"/>
<span style="color:Green;"> Only Left
<t t-esc="product.sudo().qty_available"/> Quantity
</span>
</t>
<t t-if="product.sudo().qty_available >= 5">
<i class="fa fa-cubes" role="img" aria-label="Stock" title="Stock"/>
<span style="color:Blue;"> In Stock </span></t>
</div>
</xpath>
</template>
</odoo>
<odoo>
<template id="stock_qty" inherit_id="website_sale.
<xpath expr="//div[hasclass('o_wsale_
<div class="col" style="width:300px; height:30px; background: Lavender; color: black; display: -webkit-box;">
<t t-if="product.sudo().qty_
<i class="fa fa-ban" role="img" aria-label="Ban" title="Ban"
style="font-size:20px;color:
<span style="color:Red;"> Out of Stock </span></t>
<t t-if="product.sudo().qty_
<i class="fa fa-warning" role="img" aria-label="Warning" title="Warning"
style="font-size:20px;"/>
<span style="color:Green;"> Only Left
<t t-esc="product.sudo().qty_
</span>
</t>
<t t-if="product.sudo().qty_
<i class="fa fa-cubes" role="img" aria-label="Stock" title="Stock"/>
<span style="color:Blue;"> In Stock </span></t>
</div>
</xpath>
</template>
</odoo>
Hope it helps
✌️Thank you Cybrosys it helps me, your code works on V16 I had the same need as Jomin Joseph
I just replaced it by a ribbon
span t-attf-class="o_ribbon o_not_editable text-bg-error o_ribbon_left"
and put it inside (and not before) the class oe_product_image
Works perfectly
You can review this module 2dx_qoh_by_location_list_view in apps store