from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order.line'
size = fields.Char(string="Product Size")
box_size = fields.Float(string="Box Quantity")
box_calculate = fields.Float(string="Total sq. ft./Box")
square_feet = fields.Float(string="Sq. Feet/Tiles")
categ_id = fields.Many2one('product.category', 'Product Category')
@api.onchange('product_id')
def onchange_product_id(self):
for row in self:
row.size = row.product_id.size
@api.onchange('product_id')
def onchange_product_id(self):
for row in self:
if row.product_id:
row.categ_id = row.product_id.categ_id
@api.onchange('product_id')
def onchange_product_id(self):
for row in self:
row.square_feet = row.product_id.square_feet
@api.onchange('product_id')
def onchange_product_id_box_size(self):
for row in self:
row.box_size = row.product_id.box_size
@api.onchange('product_id')
def onchange_product_id_box_calculate(self):
for row in self:
if row.product_id:
row.box_calculate = row.product_id.box_calculate
@api.onchange('product_id')
def onchange_product_size(self):
for row in self:
if row.product_id:
row.size = row.product_id.size
Here this code how can I onchange product_id with categ_id. That means When I select a product the category will show automatically. Please help me