Skip to Content
Menu
This question has been flagged
3 Replies
7567 Views

Hi everyone,
Is there a way of removing the internal reference shown in product descriptions? So just to display product name and not the internal reference?
Kindly post the function..

Thanku

Avatar
Discard
Best Answer

For sales I recommend using sales description. Those are also searchable. I just think the "internal name" is either wrongly named or should work differently. 

Avatar
Discard

Yes sales decsription and purchase description we can use newer versions

Best Answer

Hi,

You can do it as follows,

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

@api.onchange('product_id')
def product_id_change(self):
res = super(testclass, self).product_id_change()
if self.product_id.description_sale:
self.name = self.product_id.description_sale
else:
self.name = self.product_id.name
return res
Avatar
Discard

This should've been accepted two years ago as it is the cleanest solution to do this (even in V12 today). Accepted.

Where exactly do you implement this function? I want to remove product_id from the product description (and only show description_sales), so I thought I would use something similar, but I don't quite know how to do it

Hello sir. How do I edit this? should I go to SETTINGS>TECHNICAL>VIEWS to find this?

this will be problem for product with variant

Author Best Answer

Hi everyone,

Got the ans.

@api.multi
    @api.onchange('product_id')
    def product_id_change(self):
        if not self.product_id:
            return {'domain': {'product_uom': []}}

        vals = {}
        domain = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
        if not self.product_uom or (self.product_id.uom_id.category_id.id != self.product_uom.category_id.id):
            vals['product_uom'] = self.product_id.uom_id

        product = self.product_id.with_context(
            lang=self.order_id.partner_id.lang,
            partner=self.order_id.partner_id.id,
            quantity=self.product_uom_qty,
            date=self.order_id.date_order,
            pricelist=self.order_id.pricelist_id.id,
            uom=self.product_uom.id
        )

        name = product.name
        if product.description_sale:
            name += '\n' + product.description_sale
        vals['name'] = name

        self._compute_tax_id()

        if self.order_id.pricelist_id and self.order_id.partner_id:
            vals['price_unit'] = self.env['account.tax']._fix_tax_included_price(product.price, product.taxes_id, self.tax_id)
        self.update(vals)
        return {'domain': domain}


Thanku

Avatar
Discard