How to inherit and modify "Name" in Sale Order lines - Odoo14

Viewed 207

My goal is to make the "Description" (name) field located in sale.order.line in order to show the products "Sales Description"(description_sale)....and NOT the products "Name"+"Sales Description" as per default.

I've seen someone said i have to override the function product_id_change but i don't know how to do it.

Thanks in advance,

1 Answers

Try this:

@api.onchange('product_id')
def product_id_change(self):
    res = super(classname, self).product_id_change()
    self.name = self.product_id.description_sale if self.product_id and self.product_id.description_sale else self.product_id.name
    return res
Related