Here I have asset.asset inherited module in this field. I have one company_id1 which has A,B Value. If the selected company_id1 is B then 'manna_svg' should be invisible from the form.
class asset_asset(osv.osv): _inherit = "asset.asset" #_name = "asset_asset" _rec_name= "folio_num" #_rec_name = "assetmodelid_add" CRITICALITY_SELECTION = [ ('0', 'General'), ('1', 'Important'), ('2', 'Very important'), ('3', 'Critical') ] _columns = { 'name': fields.char('Asset Name', size=64), 'numbers': fields.char('Numbers', size=64), 'company_id1': fields.many2one('res.company', 'Substation', required=True), 'tcomp': fields.char('Type of Substation'), 'bcomp': fields.char('Substation Belongs to'), #'place1': fields.many2one('asset.parentlocation', 'Location'), 'asset_catg_id' : fields.many2one('asset.catg', 'Asset Catg ',select=True, required=True), 'area_id' : fields.many2one('asset.name', 'Asset Name ', domain="[('asset_catg_id', '=', asset_catg_id)]", select=True, required=True), 'assetmodelid_add' : fields.many2one('agile.portfolio1','Asset Model Code',domain="[('area_id', '=', area_id)]",), 'user_id': fields.many2one('res.users', 'Assigned to', track_visibility='onchange'), 'criticality': fields.selection(CRITICALITY_SELECTION, 'Criticality'), 'active': fields.boolean('Active'), 'folio_num' : fields.char('Folio No',), 'asse_line':fields.one2many('asset.line','emp_id','Name Plate'), 'asse_line2':fields.one2many('asset.part','emp_id1','Parts'), #'assed_modelid':fields.many2one('agile.portfolio1','Asset Model ID',select=True, required=True), 'quantity': fields.char('Quantity',size=64), 'uom': fields.char('Uinit of Measure',size=64), 'model_no' : fields.char('Model', size=64), 'msr_hour' : fields.one2many('hour.attr','hour_msr1','Inspection Attr',), 'manna_svg' : fields.many2one('svg.form','Single Line Diagram',) #'asset_id':fields.many2one('agile.portfolio','Asset ID'), }
The following code is asset_view.xml file
<xpath expr="//form/sheet/div/field[@name='name']" position="after"> <group><field name="asset_catg_id"/> <field name="area_id" options="{'no_create': True, 'no_create_edit':True}"/> <field name="assetmodelid_add" on_change="get_asset_parts(assetmodelid_add)" options="{'no_create': True, 'no_create_edit':True}"/> <field name="company_id1" on_change="onchange_first_last(company_id1)" options="{'no_create': True, 'no_create_edit':True}"/> <field name="tcomp"/> <field name="bcomp"/> <!--<field name="model_no" on_change="get_asset_parts(assetmodelid_add)"/>--> <field name="folio_num" /> <field name="criticality"/> <field name="user_id" options="{'no_create': True, 'no_create_edit':True}"/> <field name="active"/> <field name="manna_svg" attrs="{'invisible':[('company_id1', '!=', '0')]}"/> </group> </xpath>
No comments:
Post a Comment