0

I am having trouble in getting data from res.company Can someone tell me why this code gives me an error ?

    def refresh_calculation(self,cr,uid,ids, context=None): 
        company_pool = self.pool.get('res.company')
        company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'res.company', context=context)
        loan = company_pool.browse(cr, uid, company_id)

        administration_fee = loan.administration_fee.id
        interest_rate = percentage_to_float(loan.interest_rate.id)
        trade_mark = percentage_to_float(loan.trade_mark.id)

        return self.write(cr, uid, ids, {'monthly_installment': administration_fee})

Thanks in advance,

3 Answers 3

3

self.pool.get is returning None for "res.company". If that's a dict, it doesn't have that key.

Sign up to request clarification or add additional context in comments.

2 Comments

Could you tell me what to do ? I am new to openerp. Thanks,
That is the right answer in python scope. In openerp scope something is very wrong with your openerp installation when the pool can't get res.company from the pool, because that's an openerp base orm class.
2

company_pool returns the value None. Because self.pool does not have the key value 'res.company'. When company_pool.browse(...) is used -> None.browse(...) is called and this throws an error because NoneType does not have a browse attribute. Populate the value map pool before the refresh_calculation(...) is called or perform a None check before accessing this function -> if company_pool is not None:

3 Comments

what will i do to have the key value 'res.company' ?
Perform a None check before accessing the function or call self.pool.__setitem__( 'res.company','<value>') before calling the function
That is not what stackoverflow is for. Besides that, I don't know what your program is about
1

Your company_pool parameter has None stored in it for some reason. To prevent this error, a simple if statement would suffice.

if company_pool is not None:
    # doSomething
else
    print "You did not enter the parameter res.company"

1 Comment

Now try using it. Replace dosomething with your code starting from company_id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.