what is the phyton error ' TypeError: 'bool' object is unsubscriptable'

Asked by ahmed_hadir

 am a beginner in eprnerp and I currently working on the implementation of the payroll module Moroccan openerp 6.0 ​​on Windows XP, so everything was a wonder until the last step where I wanted to calculate the pay slip every time I Click on the button I get this error message:

Traceback (most recent call last):
  File "netsvc.pyo", line 489, in dispatch
  File "service\web_services.pyo", line 599, in dispatch
  File "osv\osv.pyo", line 122, in wrapper
  File "osv\osv.pyo", line 176, in execute
  File "osv\osv.pyo", line 167, in execute_cr
  File "C:\Program Files\OpenERP 6.0\Server\addons\syst_hr_payroll_ma\hr_payroll_ma.py", line 154, in compute_all_lines
  File "osv\orm.pyo", line 181, in <lambda>
  File "C:\Program Files\OpenERP 6.0\Server\addons\syst_hr_payroll_ma\hr_payroll_ma.py", line 676, in compute_all_lines
  File "C:\Program Files\OpenERP 6.0\Server\addons\syst_hr_payroll_ma\hr_payroll_ma.py", line 520, in get_igr
TypeError: 'bool' object is unsubscriptable

And here is the line of code concern is line 518 :

def get_igr(self, cr, uid, ids, montant, cotisations):
        #print('fonction IGR')
        res = {}
        salaire_net_imposable = 0
        pool = pooler.get_pool(cr.dbname)
        id_bulletin = ids[0]
        bulletin = pool.get('hr.payroll_ma.bulletin').browse(cr, uid, id_bulletin)
        personnes = bulletin.employee_id.chargefam
        logement = bulletin.employee_id.logement
        params = self.pool.get('hr.payroll_ma.parametres')
        ids_params = params.search(cr, uid, [])
        dictionnaire = params.read(cr, uid, ids_params[0])
        fraispro = montant * dictionnaire['fraispro'] / 100
        if fraispro < dictionnaire['plafond']:
            salaire_net_imposable = montant - fraispro - cotisations - logement
        else :
            salaire_net_imposable = montant - dictionnaire['plafond'] - cotisations - logement

    objet_ir = self.pool.get('hr.payroll_ma.ir')
    id_ir = objet_ir.search(cr, uid, [])
    liste = objet_ir.read(cr, uid, id_ir, ['debuttranche', 'fintranche', 'taux', 'somme'])
    for tranche in liste:
        if(salaire_net_imposable >= tranche['debuttranche']/12) and (salaire_net_imposable < tranche['fintranche']/12):
            taux = (tranche['taux'])
            somme = (tranche['somme']/12)

    ir_brute = (salaire_net_imposable * taux / 100) - somme
    if((ir_brute - (personnes * dictionnaire['charge'])) < 0):
        ir_net = 0
        ir_net = ir_brute - (personnes * dictionnaire['charge'])
    res = {'salaire_net_imposable':salaire_net_imposable,
 518------ 'credit_account_id':dictionnaire['credit_account_id'][0], ---------------
         'frais_pro' : fraispro,
         'personnes' : personnes

    return res

So I apologize for the inconvenience and I hope you can help me thank you in advance

Question information

English Edit question
OpenERP Edit question
No assignee Edit question
Solved by:
Serpent Consulting Services
Last query:
Last reply:
Revision history for this message
Best Serpent Consulting Services (serpent-consulting-services) said :

Salam Ahmed,

You get ['credit_account_id'] as False!

Don't do [0] because you read ids_params[0].


Revision history for this message
ahmed_hadir (ahmed-hadir) said :

salam said,

oui c'est juste, merci beaucoup said

Revision history for this message
ahmed_hadir (ahmed-hadir) said :

Thanks Serpent Consulting Services, that solved my question.

Revision history for this message
ahmed_hadir (ahmed-hadir) said :

yes that's right, thank you very much Said