How can i solve this error Odoo throws a MissingError on TreeView Second line button when clicked . The first Record line works but i need such that for each record on the tree the code below will be able to pass the contexts and open the appropriate view . Kindly assist
Here is the code called on the button
@api.multi
def action_four_weeks_schedule_form(self):
self.ensure_one()
res = {}
ids = self._ids
cr = self._cr
uid = self._uid
context = self._context.copy()
for id in self.browse(self.ids):
print 'id in ++++ ' , id
order_obj = self.pool.get('ratecard.multiple').browse(cr,uid,ids)[0]
ratecard_multiple_id=order_obj.id #int(order_obj.id)
# self.copy(cr,uid, id,ids, {},context)
print '##############################################'
print 'ratecard_multiple_id', ratecard_multiple_id
print 'action_four_weeks_schedule_form ratecard_multiple_id ' , ratecard_multiple_id
scheduled_for= order_obj.scheduled_for
code= order_obj.code
print 'order_obj.multiple_ratecard_id.code' ,[ x.code for x in order_obj.multiple_ratecard_id[0]]
print '##################################################################'
for lineitems in order_obj.multiple_ratecard_id:
print 'Ratecard Codes of selected ' , lineitems.code
singular_code = [ x.code for x in order_obj.multiple_ratecard_id[0]]
for ln in lineitems:
print '***************************************'
print 'ratecard singular name' , ln.name
print 'ratecard singular code' , ln.code
print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
# self.copy(cr,uid,id, ids , {},context)
scheduled_for= order_obj.scheduled_for
code= order_obj.code
singular_code = [ x.code for x in order_obj.multiple_ratecard_id[0]]
print '[ x.code for x in order_obj.multiple_ratecard_id[0]]' , singular_code
# for line in id:
# line_obj = self.pool.get('ratecard.multiple').browse(cr,uid,ids)[0]
# print 'line_obj contains' , line_obj
# print '***************************************'
# print 'INNER LOOP action_four_weeks_schedule_form scheduled_for ' , line_obj.scheduled_for
# print ' INNER LOOP action_four_weeks_schedule_form code ' , line_obj.code
# print 'Can i get code of selected line_obj.multiple_ratecard_id.code ' , line_obj.multiple_ratecard_id.code
# print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
# ratecard_multiple_id=line.id
# print 'inner line_obj action_four_weeks_schedule_form ratecard_multiple_id ' , ratecard_multiple_id
# scheduled_for= line_obj.scheduled_for
# code= line_obj.code
scheduled_for= order_obj.scheduled_for
code= order_obj.code
singular_code = [ x.code for x in order_obj.multiple_ratecard_id[0]]
print 'action_four_weeks_schedule_form scheduled_for ' , scheduled_for
print 'action_four_weeks_schedule_form code ' , code
print 'singular ratecard selected is ' , singular_code
res = {}
if scheduled_for == 2:
view_id = self.env.ref('ragtimeorder.view_two_weeks_schedule_form').id
form_id = self.env.ref('ragtimeorder.view_two_weeks_schedule_form').id
tree_id = self.env.ref('ragtimeorder.view_two_weeks_schedule_tree').id
res = {
'name': _('TWO WEEKS SCHEDULE FOR RATECARD'),
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form'), ],
'res_model': 'two.weeks.schedule',
# 'res_id':self.id,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'domain': '[]',
'context':{'default_scheduled_for':scheduled_for,'default_code':code , 'default_singular_code':singular_code},
'flags': {'form': {'action_buttons': True}}
}
elif scheduled_for == 3:
view_id = self.env.ref('ragtimeorder.view_three_weeks_schedule_form').id
form_id = self.env.ref('ragtimeorder.view_three_weeks_schedule_form').id
tree_id = self.env.ref('ragtimeorder.view_three_weeks_schedule_tree').id
res = {
'name': _('THREE WEEKS SCHEDULE FOR RATECARD'),
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form'), ],
'res_model': 'three.weeks.schedule',
# 'res_id':self.id,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'domain': '[]',
'context': context,
'flags': {'form': {'action_buttons': True}}
}
elif scheduled_for == 4:
view_id = self.env.ref('ragtimeorder.view_four_weeks_schedule_form').id
form_id = self.env.ref('ragtimeorder.view_four_weeks_schedule_form').id
tree_id = self.env.ref('ragtimeorder.view_four_weeks_schedule_tree').id
res = {
'name': _('FOUR WEEKS SCHEDULE FOR RATECARD'),
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form'), ],
'res_model': 'four.weeks.schedule',
# 'res_id':self.id,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'domain': '[]',
'context':{'default_scheduled_for':scheduled_for,'default_code':code ,'default_singular_code':singular_code },
'flags': {'form': {'action_buttons': True}}
}
elif scheduled_for == 1:
view_id = self.env.ref('ragtimeorder.view_one_week_schedule_form').id
form_id = self.env.ref('ragtimeorder.view_one_week_schedule_form').id
tree_id = self.env.ref('ragtimeorder.view_one_week_schedule_tree').id
res = {
'name': _('ONE WEEK SCHEDULE FOR RATECARD'),
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form'), ],
'res_model': 'one.week.schedule',
# 'res_id':self.id,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'domain': '[]',
'context':{'default_scheduled_for':scheduled_for,'default_code':code , 'default_singular_code':singular_code},
'flags': {'form': {'action_buttons': True}}
}
else:
view_obj = self.pool.get('ir.ui.view')
view_id = view_obj.search(cr, uid, [('model', '=', self._name), \
('name', '=', self._name + '.view')])
res = {
'view_mode': 'form',
'view_type': 'form',
'view_id': view_id or False,
'res_model': self._name,
'context': context,
'type': 'ir.actions.act_window',
'target': 'new',
'flags': {'form': {'action_buttons': True}}
}
id.update({
'radio_scheduled_for': scheduled_for,
'update_code' : code,
'singular_code' : singular_code ,
})
return res
This is the screenshot of the error the button pressed throws this error
来源:https://stackoverflow.com/questions/34335376/odoo-throws-a-missingerror-on-treeview-second-line-record