【问题标题】:Odoo 12 - How to add Unit of Measure from Products in PoS receipt?Odoo 12 - 如何在 PoS 收据中添加产品的计量单位?
【发布时间】:2020-01-29 02:35:07
【问题描述】:

我们的客户希望 PoS 收据显示所售产品的计量单位。我该怎么做呢?

这是针对客户端 Odoo 12 实例的。在销售完成后收据要打印的XML 文件中,我尝试添加以下内容:

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

但是当我打印收据时,它显示该字段为空,即使在销售点 UI 中您可以选择产品的计量单位。

这是系统查看打印产品名称、评论和折扣的地方。

<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>

在模型中声明了以下内容:

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)

我也尝试调用这些类,但没有结果。

预期的结果应该能够调用所售产品的计量单位出现在 PoS 收据中。

【问题讨论】:

    标签: python xml odoo odoo-12 pos


    【解决方案1】:

    通过执行以下操作解决了问题:

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

    uom_id 是一个数组,所以每当我调用它时,它都会带上 ID,但没有显示任何内容。因此,uom_id[1] 带来了我感兴趣的下一个元素,即度量单位。

    【讨论】:

    • 它适用于 odoo 14 吗? ...我可以用它来显示内部引用吗?
    • 嗨,我停止使用 Odoo,因此没有在 Odoo 14 中对其进行测试,但我相信它应该可以工作。 @SalemAhmed
    猜你喜欢
    • 2020-08-06
    • 2021-09-11
    • 1970-01-01
    • 1970-01-01
    • 2022-12-17
    • 2020-07-02
    • 1970-01-01
    • 2022-12-03
    • 2018-08-20
    相关资源
    最近更新 更多