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

error in reading from another class

By
layal abishalhla
on 4/10/14, 11:28 AM 708 views
class classA(osv.osv):

 _name="classA"

 def _meth ......


 _columns = {

        'b_id' : fields.one2many('classB', 'a_id'),

        'rem' : fields.function(_meth,type = "float", method=True, multi='sums',store=True,readonly=True),

        }

classA()



class classB(osv.osv):

 _name="classB"


 _columns = {

        'amount' : fields.float ('Paid Amount'),

        'a_id' : fields.many2one('classA'),

    }




 def onchange_amount(self,cr,uid,ids,amount,context=None):

        res={}

        warning = False

        if (self.pool.get("classA").rem - amount <0):

            warning = {

             'title' : ("Warning"),

             'message' : ("!"),

                 }

        return { 'warning' : warning }

classB()

what im gettig is :

Client Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\http.py", line 204, in dispatch File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\controllers\main.py", line 1128, in call_kw File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\controllers\main.py", line 1120, in _call_kw File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\session.py", line 42, in proxy File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\session.py", line 30, in proxy_method File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\session.py", line 103, in send

Server Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\web\session.py", line 89, in send File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server.\openerp\netsvc.py", line 292, in dispatch_rpc File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server.\openerp\service\web_services.py", line 626, in dispatch File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server.\openerp\osv\osv.py", line 188, in execute_kw File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server.\openerp\osv\osv.py", line 131, in wrapper File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server.\openerp\osv\osv.py", line 197, in execute File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server.\openerp\osv\osv.py", line 185, in execute_cr File "C:\Program Files (x86)\OpenERP 7.0-20130703-231023\Server\server\openerp\addons\m.zip\m\m.py", line 58, in onchange_amount AttributeError: 'classA' object has no attribute 'rem'

any help please?

2

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/10/14, 11:41 AM

Issue is self.pool.get("classA").rem here. To get the value of any field, you have to either read or browse the record.

Try this:

for rec in self.browse(cr, uid, ids, context=context):
    if rec.a_id and (rec.a_id.rem - amount < 0):
        #Your code goes here

thank u for ur reply .. i tried it now , no error .. but it does nothing (even if rec.a_id.rem - amount < 0 no warning is displayed !) any help ?

layal abishalhla
on 4/10/14, 11:53 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

0 follower(s)

Stats

Asked: 4/10/14, 11:28 AM
Seen: 708 times
Last updated: 3/16/15, 8:10 AM