Search code examples
pythonxmlodooodoo-15

Add quantity on hand and the suppliers of product to sale order lines from product.template in Odoo 15


Products in odoo have informations like name,type,price,Internal Reference ect..

enter image description here

here I want to add quantity on hand and the suppliers of a product in sale order lines Sale Order Lines enter image description here as you see in the picture we have in order lines product,description,qty,price ect.. i want to add quantity on hand and the suppliers to this infos.

how can i add quantity on hand from image 1 (product) to image 2 (Order lines), and the suppliers too

i tried this code

qty_on_hand = fields.Char(related="product_id.qty_available")

but i got this error

odoo type of related field sale.order.line.qty_on_hand is inconsistent with product.product.qty_available


Solution

  • what is suppliers explain that please. i mean what will that field contain.. and for the quantity available you are doing it a bit wrong. see the code below... you have to do like this...

    inherit sale.order.line and add a field

    qty_on_hand = fields.Float('On Hand Qty', related='product_id.qty_available')
    

    add this qty_available field in xml by inheriting the the order_lines view thats all for on hand quantity.