NeoVe
NeoVe

Reputation: 3907

Inheriting product category in description field - OpenErp

I have this code for a product in my module:

_name = "purchase.requisition.line"
_description="Purchase Requisition Line"
_rec_name = 'product_id'

_columns = {
    'descripcion' : fields.char('Descripcion', size=42),
    'nrodeparte' : fields.integer('Nro. de Parte'),
    'espcifictec' : fields.char('Especificaciones Tecnicas', size=42),
    'maquina' : fields.char('Maquina', size=42),
    'anexo' : fields.float('Anexo NRo.'),
    'product_id': fields.many2one('product.product', 'Product' ),
    'product_uom_id': fields.many2one('product.uom', 'Product Unit of Measure'),
    'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
    'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade'),
    'company_id': fields.related('requisition_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
}

In descripcion I got a char field for a description of the product I've inherited from product.product. Right now it's an independent field, how can I inherit the category of the product I chose in product_id?

I know the object is categ_id in the product module, and I tried this

'descripcion': fields.many2one('product.category','Desripcion')

But it doesn't works, how can I achieve this? I need to load automatically the product description (categ_id) in this field.

Upvotes: 0

Views: 312

Answers (2)

user2327023
user2327023

Reputation: 11

Try this

'descripcion':fields.many2one('product.category', 'Descripcion', required=True, ondelete='cascade'),

Upvotes: 1

simahawk
simahawk

Reputation: 2431

you can replace it with a function field that gets the value from product_id.category_id or setup an on_change on the produtct_id that populates your category. Read the manual and grep the addons folder for a lot of examples.

Upvotes: 1

Related Questions