Odoo Help


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

Anirudh Lou
on 8/5/15, 4:02 AM 3,300 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)))
# 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)))
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 ?

on 8/5/15, 4:30 AM

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

Vale Trood
on 8/5/15, 5:48 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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