hello odoo community
I have one2many filed(line_ids) in purchase requisition form that contains product name, product category,... and I want make product category readonly
I try to use attr in XML code but it does not save product category value
my python code:
in purchase.requisition
'line_ids' : fields.one2many('purchase.requisition.line','requisition_id','Products to Purchase',states={'done': [('readonly', True)]}),
in purchase.requisition.line
_columns = {
'product_id': fields.many2one('product.product', 'Product' ),
'product_uom_id': fields.many2one('product.uom', 'Product UoM'),
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM')),
'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),
'categ' : fields.many2one('product.category', 'categ' ,store=True),
}
my XML code:
<field name="line_ids" colspan="4" nolabel="1">
<tree string="Products" editable="bottom">
<field name="product_id" on_change="onchange_product_id(product_id,product_uom_id)"/>
<field name="categ" attrs="{'readonly':[('product_id','!=',False)]}"/>
<field name="product_qty"/>
<field name="product_uom_id"/>
</tree>
openerp v6.1