Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
7156 Weergaven

hello,

i need to change the product description. the standard field get "name"+"product_code" from product.sipplierinfo. i would like to show "name"+"custom field" where the custom field is in the product template and show like this in purchase order line ecc

Avatar
Annuleer
Beste antwoord

Hi Mauro,

You have to overwrite name_get function of product.product object for this.You Can check the sample,



class ProductProductInherit(models.Model):
_inherit = 'product.product'

def name_get(self, cr, uid, ids, context=None):
res = super(ProductProductInherit, self).name_get(cr, uid, ids, context=context)
#write the code to here
#then you can return the product name
return res


Avatar
Annuleer
Auteur Beste antwoord

i get a code from another user but i think it refer to odoo 9 because the odoo 8 code is little different.

class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty,
uom_id, partner_id, date_order=False,
fiscal_position_id=False, date_planned=False,
name=False, price_unit=False, state='draft',
context=None):
res = super(PurchaseOrderLine, self).onchange_product_id(
cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id,
date_order=date_order, fiscal_position_id=fiscal_position_id,
date_planned=date_planned, name=name, price_unit=price_unit,
state=state, context=context)
         product_id = res['product_id']
         res['name'] = product_id.name + product_id.default_code
         # for addind  "x_IDfornitore" and x_IDfornitore2 fields
          res['name'] = product_id.name (if needed,) + product_id.x_IDfornitore + IDfornitore2
return res
Avatar
Annuleer

Try this,

class PurchaseOrderInherit(models.Model):

_inherit = 'purchase.order.line'

@api.onchange('product_id')

def product_id_change(self):

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

if self.product_id.custom_field:

self.name = self.product_id.name + self.product_id.custom_field

else:

self.name = self.product_id.name

return res

Auteur

can't find this code on odoo 8 purchase.py

Gerelateerde posts Antwoorden Weergaven Activiteit
1
mei 16
5857
2
mrt. 15
8620
3
jan. 25
13026
0
jul. 22
2445
1
jan. 24
6272