Skip to Content
Menu
This question has been flagged
1 Reply
2646 Views

When making a quotation and selecting a product_id, many fields are automatically prefilled.
For the prefilling of the field 'description' I would like to include only the field description_sale (recorded in product.template) and not product_id + decription_sale.
Where can I change this?
Thank you!

Avatar
Discard
Best Answer

Hi, Maartje

In order to achieve this feature you can simply override "product_id_change" function from "SaleOrderLine" like below,

@api.onchange('product_id')
def product_id_change(self):
    res = super(SaleOrderLine, self).product_id_change() 
    res['name'] = self.product_id.description_sale if self.product_id.description_sale else res.get(''name', '')
    return res
Hope above solution will help you. Feel free to ask in you still have the same query.


Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
Avatar
Discard
Author

Hi Ashish,

Thank you for the description! Unfortunately I don't know the right way to edit the product_id_change function.

I went to Technical -> Models -> SalesOrderLine, However there I don't see the product_id_change function. Could you help me along?

Best,

Maartje

Author

Correction, I went to:

Technical -> models -> sale.order.line

I run Odoo 12

Hi, Maartje

Inside any custom module you can simply override this function like below,

class SaleOrderLine(models.Model):

_inherit = "sale.order.line"

@api.onchange('product_id')

def product_id_change(self):

res = super(SaleOrderLine, self).product_id_change()

res['name'] = self.product_id.description_sale if self.product_id.description_sale else

res.get(''name', '')

return res

Else you can made changes directly inside core addons. You need to made changes inside "addons/sale/models/sale.py",

Inside this file you need to made changes in "product_id_change" method. You simply need to replace this line,

https://github.com/odoo/odoo/blob/2aca220beb131fcfd53a2581fdff3a1ed7165c6c/addons/sale/models/sale.py#L1500

With,

name = self.product_id.description_sale

Feel free to ask in case you have any confusion related to the above point.

Thanks,

Ashish Singh