Search code examples
pythonxmlodooodoo-12pos

Odoo 12 - How to add Unit of Measure from Products in PoS receipt?


Our client wants the PoS receipt to show the Unit of Measure of the products being sold. How would I go about doing this?

This is for a clients Odoo 12 instance. In the XML file from the which the receipt looks at to print after a sale is made I've tried adding the following:

<t t-esc="orderline.get_product().uom"/>

But when I print the receipt it shows the field empty even though in the Point of Sale UI you can choose the unit of measure of the product.

This is from where the system looks at to print the product name, comment & discount.

<td width="35%">
     <t t-esc="orderline.get_product().display_name"/>
     <t t-if="widget.pos.config.on_product_line">
        <div class="pos-disc-font">
           <t t-esc="orderline.get_order_line_comment()"/>
        </div>
     </t>
     <t t-if="orderline.get_discount() &gt;0">
       <div class="pos-disc-font">With a <t t-esc="orderline.get_discount()"/>% discount 
</div>
</t>
</td>

In the model the following is declared:

class UomCateg(models.Model):
    _inherit = 'uom.category'

    is_pos_groupable = fields.Boolean(string='Group Products in POS',
        help="Check if you want to group products of this category in point of sale orders")


class Uom(models.Model):
    _inherit = 'uom.uom'

    is_pos_groupable = fields.Boolean(related='category_id.is_pos_groupable', readonly=False)

I've also tried calling these classes but no result.

The expected result should be able to call the Unit of Measure of the product being sold to appear in the PoS receipt.


Solution

  • Solved the issue by doing the following:

    <t t-esc="orderline.get_product().uom_id[1]"/>
    

    uom_id is an array so whenever I was calling it, it brought the ID and nothing was displayed. So making it uom_id[1] brought the next element I was interested in, which was the Unit of Measure.