Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to resolve: TypeError: 'int' object has no attribute '__getitem__'?

By
Anirudh Lou
on 8/5/15, 4:02 AM 1,081 views

Code below is my method definition that will calculate/get the next date depends on the terms entered by the user. What i encountered is upon running an error pops up saying: TypeError: 'int' object has no attribute '__getitem__' . This is somehow related with my previous question, but this time I put on a button.

def calculate_history(self, cr, uid, ids, context=None):
schedule_obj = self.pool.get('installment.schedule')
sequence_obj = self.pool.get('ir.sequence')
id = []
_logger.info("\n\t\t\t1st .. IDS %s"%(str(ids)))
for record in self.browse(cr, uid, ids, context=context):
itb = record.name or sequence_obj.get(cr, uid, 'crm.lead')
_logger.info("\n\t\t\t2nd .. ITB %s"%(str(itb)))
old_history = schedule_obj.search(cr, uid, [('lead_id','=',record.id)],context=context)
_logger.info("\n\t\t\t3rd .. OLD HISTORY %s"%(str(old_history)))
if old_history:
schedule_obj.unlink(cr, uid, old_history, context=context)
factor = self._get_factor(cr, uid, ids, record.payment_terms, context=context)
i = 0
seq = 1
range = 24
# while seq <= 24:
while i < factor:
date = datetime.strptime(record.payable_start_on, '%Y-%m-%d') + relativedelta(months=+i)
_logger.info("\n\t\t\t4th .. Date %s"%(str(date)))
key = str(record.id)
temp_dict = {
'regular_date' : date.strftime('%Y-%m-%d'),
'seq' : seq,
'parent_id' : record.id,
}

_logger.info("\n\t\t\t5th .. TEMP DICT %s"%(str(temp_dict)))
schedule_obj.create(cr,uid,temp_dict,context=context)
# seq += 1
i += 1
list = schedule_obj.search(cr,uid,[('parent_id','=',record.id)])
lines = [line.id if line.id else False for line in schedule_obj.browse(cr,uid,list,context=context)]
_logger.info("\n\t\t\t7th .. LINES %s"%(str(lines)))
self.write(cr,uid,record.id,{'sched_ids':lines},context=context)
return True

  This is what the log said:

     
File "/opt/openerp/server-7/openerp/osv/orm.py", line 4255, in write
result += self._columns[field].set(cr, self, id, field, vals[field], user, context=rel_context) or []
File "/opt/openerp/server-7/openerp/osv/fields.py", line 557, in set
if act[0] == 0:
TypeError: 'int' object has no attribute '__getitem__'


Any help/suggestion is much appreciated

Can you edit your question and post the full traceback ?

PY
on 8/5/15, 4:30 AM

try to print the act[0] to know what it does contain please.

Drees Far
on 8/5/15, 5:48 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/5/15, 4:02 AM
Seen: 1081 times
Last updated: 8/5/15, 5:48 AM