Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4347 Vistas

Hi,

I have added a new field in product template like below

_name='product.template'

_inherit='product.template'

_columns={

'buy_price' : fields.float('Prix Achat',digits_compute=dp.get_precision('Price')),}

now in the supplier invoice I want to call this field so I have use this code:

_name='account.invoice.line'
_inherit='account.invoice.line'

 _columns= {

            'product_tmpl_id': fields.many2one('product.template', 'Product'),
            'price_buy': fields.related('product_tmpl_id','buy_price',type="float",relation="product.template",string="PUHT",store=True,readonly=True),
                }

when I update my module and create a new supplier invoice I get nothing in the new added field as shown in the picture


Any help please

Thanks



Avatar
Descartar

delete relation="product.template" in fields.related. fields.related('product_tmpl_id','buy_price',type="float",string="PUHT",store=True)

Mejor respuesta

Try in this way:

fields.related('product_id','buy_price',type="float",relation="product.template",string="Price Buy",store=True)

Just use product_id field which is already there in account.invoice.line.

Rather than managing a separate many2one field product_tmpl_id  ,  product_id will solve your problem.

Avatar
Descartar