跳至內容
選單
此問題已被標幟
3 回覆
7579 瀏覽次數

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

頭像
捨棄
最佳答案

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. 

頭像
捨棄

Yes sales decsription and purchase description we can use newer versions

最佳答案

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
頭像
捨棄

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

作者 最佳答案

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

頭像
捨棄