Search code examples
odooodoo-14

Sale Quotation Line's Quantity (product_uom_qty) is not triggering onchange


In Sale Quotation Line, there is a field Quantity (product_uom_qty). I want to customize something in its onchange event, but it does not seem to be triggering it when I change its value.

This is what I tried:

class sale_order_line_inherit(models.Model):
    _inherit = 'sale.order.line'

    @api.onchange('product_uom', 'product_uom_qty')
    def product_uom_change(self):
        print(res)
        print(self.price_unit)
        res = super(sale_order_line_inherit, self).product_uom_change()
        print(res)
        print(self.price_unit)

Nothing gets printed at all. I already included 'sale' in manifest as well. What did I do wrong?


Solution

  • Few points to consider,

    • How to change quantity from the frond end or script?
    • Can you verify field name on the list/form view?
    • Put print statement on the Odoo core sale module
    • If still not working, put error code on the file and upgrade the module to identify file execute at all or not.

    I don't have any issue in your code. This is alternative of your code.

    @api.onchange('product_uom', 'product_uom_qty')
    def product_uom_change(self):
        print(self.price_unit)
        super().product_uom_change()
        print(self.price_unit)