Hi Buddies.
Good morning.
I am trying this from the couple of days but no luck..
I read the data from the table and split that into selection fields list and try to return through the function..
The Function was working Fine , But I am unable to see or edit the Selection field ..
Here is My XML Code..
<record id="hr_team_action" model="ir.actions.act_window">
<field name="name">Team</field>
<field name="res_model">hr.employee</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_hr_team_tree"/>
</record>
<record model="ir.ui.view" id="view_hr_team_form">
<field name="name">hr.team.form</field>
<field name="model">hr.employee</field>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Team">
<group col="4">
<field name="name_related"/>
<field name="department_id"/>
<field name="work_location"/>
<field name="job_id"/>
<button name="%(act_view_hr_performancegoals_tree)d" type="action" string="Assign Goals" class="oe_link oe_edit_only" icon="STOCK_DIRECTORY_MENU"/>
</group>
</page>
</notebook>
</field>
</record>
<record model="ir.ui.view" id="view_hr_team_tree">
<field name="name">hr.team.form</field>
<field name="model">hr.employee</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Team" editable="bottom" >
<field name="name_related"/>
<field name="department_id"/>
<field name="work_location"/>
<field name="job_id"/>
<button name="%(act_view_hr_performancegoals_tree)d" type="action" string="Assign Goals" class="oe_link oe_edit_only" icon="STOCK_DIRECTORY_MENU"/>
</tree>
</field>
</record>
...................................................................................
.py file
class hr_performancegoals(osv.osv): _name = "hr.performancegoals" _description = "Performance Goals"
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if context is None:
context = {}
print "Sateesh testing here",uid
result = super(hr_performancegoals, self).fields_view_get(cr, uid, view_id,view_type, context, toolbar,submenu)
data = result['arch']
if uid == 1:
L=[]
ldata = data.split("\n")
for var in ldata:
if re.search("parent_id",var):
pass
else:
L.append(var)
reqdata =''.join(L)
result['arch']=reqdata
else:
L=[]
ldata = data.split("\n")
for var in ldata:
if re.search("strategic_goals",var):
pass
else:
L.append(var)
reqdata =''.join(L)
result['arch']=reqdata
return result
def _get_objectives(self,cr,uid,ids,name,args,context=None):
res= dict.fromkeys(ids,'')
print "In Objectives"
cr.execute("select objectives from hr_performancegoals")
data = cr.dictfetchall()
L=[]
for i,values in enumerate(data):
a=unicodedata.normalize('NFKD', values['objectives']).encode('ascii','ignore')
rest=a.split(',')
print "Here is the List:",rest
if len(rest)!=0:
for j,val in enumerate(rest):
L.append((j,val))
i=j
else:
L.append((i,rest))
print "Value Here :",L
res['values']=L
return res
def _get_employee_id(self,cr,uid,ids,name,arg,context=None):
res = dict.fromkeys(ids, uid)
print "sateesh testing employee_id",res #res['employee_id'], type(res['employee_id'])
return res
_columns = {
'employee_id': fields.function(_get_employee_id,method=True, type='integer', string="Employee",store=True),
'strategic_goals': fields.char('Strategic Goals', required=True),
'parent_id': fields.function(_get_objectives, type='selection',method=True, string="Stratergic Goals Parent"),
'objectives' : fields.text('Objectives'),
'completion_date' : fields.date('Completion Date'),
'specific_actions_required_to_deliver_strategic_goal' : fields.text('Specific Actions Required To Deliver Strategic Goal'),
'status': fields.selection([('1','Yet To Start'),
('2','In Progress'),
('3','Invalid'),
('4','Completed'),
('5','Closed'),],
'Status', required=True),
}
Working with Human Resource Module