error msg after added invisible attr Added image here depending upon group bellow notepad tree view fields can be change 嗨朋友我是ODOO或OpenERP的初学者,我的情况是基于选择字段记事本树视图可以改变所以我给了我的代码样本 - 我应该添加隐形然后我应该添加到哪里? XML代码:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="feeder_tree_view" model="ir.ui.view">
<field name="name">feeder.data.tree</field>
<field name="model">feeder.data</field>
<field name="arch" type="xml">
<tree string="Feeder">
<field name="date_of1"/>
<!--<field name="folio_num1"/>
<field name="max_mw"/>-->
<field name="company_id1"/>
</tree>
</field>
</record>
<record id="feeder_form_view" model="ir.ui.view">
<field name="name">feeder.data.form</field>
<field name="model">feeder.data</field>
<field name="arch" type="xml">
<form string="Feeder">
<group>
<!--<field name="company_id1"/>-->
<field name="date_of1"/>
<field name="group_name" on_change="get_feeder_catg(group_name)"/>
<!--<field name="folio_num1"/>--></group>
<field name="combine2">
<form string="Enter">
<group>
<!--<field name="company_id1"/>
<field name="Hours"/>
<field name="time_read"/>-->
<field name="Hours"/>
<field name="mega_wat"/>
<field name="current"/>
<field name="wt"/>
<field name="ot"/>
<field name="tp"/>
<!--<field name="Max"/>-->
</group>
</form>
<tree limit='24' string="BoM" editable="bottom">
<!--<field name="company_id1"/>
<field name="Hours"/>
<field name="time_read"/>-->
<field name="Hours"/>
<field name="mega_wat"/>
<field name="current"/>
<field name="wt"/>
<field name="ot" attrs="{'invisible': [('group_name', '=','Feeder')]}"/>
<field name="tp" attrs="{'invisible':[('group_name', '=','Feeder')]}"/>
<!--<field name="Max"/>-->
</tree>
</field>
<!--<group><field name="max_mw"/></group>-->
</form>
</field>
</record>
<record id="feeder_data_action" model="ir.actions.act_window">
<field name="name">Feeder Data</field>
<!--<field name="type">ir.actions.act_window</field>-->
<field name="res_model">feeder.data</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Click to create a new AssetConfigs</p>
</field>
<!--<record model="ir.actions.act_window.view" id="action_feeder_tree_view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="feeder_tree_view"/>
<field name="act_window_id" ref="feeder_data_action"/>
</record>-->
</record>[error msg][2]
class feeder_data(osv.Model):
_name = "feeder.data"
_rec_name= "company_id1"
_columns = {
'company_id1': fields.many2one('res.company', 'Substation', required=True),
'date_of1':fields.datetime('Date',),
'group_name':fields.many2one('feeder.catg','Please Select Group'),
'combine2':fields.one2many('data.value','combine','Details'),
}
def get_feeder_catg(self, cr, uid, ids, group_name,context=None):
val = {}
res = []
res2 = []
res3 = []
if group_name:
for asset in self.pool.get('feeder.catg').browse(cr,uid,group_name,context=context):
for ass in asset.combine_table:
val = {
'Hours' : ass.feeder.folio_num,
'company_id1': ass.company_id1.name,
#'time_read':date.today().strftime('%Y-%m-%d')
}
res.append(val)
logging.info("VAL=%d",val)
logging.info("RES=%d",res)
val.update({'combine2':res,})
return {'value': val}
def _default_company(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
return user.company_id.id
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
_defaults = {
'date_of1': datetime.today().strftime('%Y-%m-%d'),
'company_id1': _default_company,
}
答案 0 :(得分:0)
为它创建一个相关字段,并在attrs中添加该相关字段。
_name = 'feeder.data'
_columns= {'group_name_related' :fields.related('group_name','field_name', type = 'char', relation='target_table_name', string='Name')}
<tree>
<field name='name' attrs="{'invisible' : [('group_name_related','=','GroupName')]}">
</tree>