0
votes

error msg after added invisible attrAdded image here depending upon group bellow notepad tree view fields can be change Hi friends I am beginner to ODOO or OpenERP, I have scenario in that based on selection field notepad tree view can be changed so I have given my code sample- should I add invisible then where should I add? XML Code:

<?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,
    }
1

1 Answers

0
votes

Create an related field for it and add that related field in 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>