Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

AttributeError: 'int' object has no attribute 'get'

Odoberať

Get notified when there's activity on this post

This question has been flagged
fleet
3 Replies
46730 Zobrazenia
Avatar
Lady Sharmane Udtuhan

Here is my onchange code that gets the error :

def onchange_asset_id(self,cr,uid,asset_id,qty,bal_units,context=None ):
    tot = 0
    rem = 0


    rental_id = None


    value = {'value':{'asset_id': ''}}
    with_asset = 0.0
    rental_obj = self.pool.get('fleet.rentals')            
    rental_id = context.get('rent_id')
    if rental_id:
        for rid in rental_obj.browse(cr,uid,[rental_id],context=None):

            sqlreq = "select sum(qty), asset_id " \
                     "from fleet_rentals fr ,fleet_rentals_line frl " \
                      "where fr.id = frl.rent_id and asset_id = " + str(asset_id) + " " \
                      "and frl.id != " +str(rental_id) + " " \
                      "group by  asset_id "


            cr.execute(sqlreq)

            resline =  cr.fetchall()

The error message is this :

      Server Traceback (most recent call last):
    File "/opt/openerp/server-70/openerp/addons/web/session.py", line 90, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/opt/openerp/server-70/openerp/netsvc.py", line 293, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/server-70/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/server-70/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp/server-70/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/server-70/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/server-70/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/openerp/biz1_addons_70/biz1_cmms/fleet.py", line 331, in onchange_asset_id
    rental_id = context.get('rent_id')
AttributeError: 'NoneType' object has no attribute 'get'
0
Avatar
Zrušiť
Avatar
Subhin P V
Best Answer
 rental_id = context.get('rent_id')

The error is from this part of the code. .get function used on context is a dictionary function. But The type of context in the function here is Not a dictionary and thats why the error.

it would be better to use this code..

def onchange_asset_id(self,cr,uid,asset_id,qty,bal_units,context=None ):
    tot = 0
    rem = 0
    if context == None:
        context = {}

rental_id = None
value = {'value':{'asset_id': ''}}
with_asset = 0.0
rental_obj = self.pool.get('fleet.rentals')            

if  type(context) == dict and context.get('rent_id'):
    rental_id = context.get('rent_id')
    for rid in rental_obj.browse(cr,uid,[rental_id],context=None):

        sqlreq = "select sum(qty), asset_id " \
                 "from fleet_rentals fr ,fleet_rentals_line frl " \
                  "where fr.id = frl.rent_id and asset_id = " + str(asset_id) + " " \
                  "and frl.id != " +str(rental_id) + " " \
                  "group by  asset_id "


        cr.execute(sqlreq)

        resline =  cr.fetchall()
1
Avatar
Zrušiť
Lady Sharmane Udtuhan
Autor

Thanks for the answer it solves my problem in context :D

Avatar
Turkesh Patel (tpa)
Best Answer

do it like this. you are getting None in context thats why you got this error.

 def onchange_asset_id(self,cr,uid,asset_id,qty,bal_units,context=None ):
     if context is None:
         context = {}
1
Avatar
Zrušiť
Lady Sharmane Udtuhan
Autor

Thanks for the answer it also solves my problem :D

Avatar
Francesco OpenCode
Best Answer

The line:

for rid in rental_obj.browse(cr,uid,[rent_id],context=None):

must be

for rid in rental_obj.browse(cr,uid,[rental_id],context=None):
0
Avatar
Zrušiť
Lady Sharmane Udtuhan
Autor

Thanks for the answer.. But it seems that, that is not the reason why I got my error.. I updated my post and add the error message that appears..

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
fleet management offline
fleet
Avatar
Avatar
Avatar
2
okt 25
612
Fleets - Vehicle refueling Management.
fleet
Avatar
0
apr 25
1313
Fleet App - Cost Report (V.14 EE)
fleet
Avatar
0
júl 22
2967
Fleet Management Driver linked to Human Reources Employee instead of Contact
fleet
Avatar
Avatar
Avatar
Avatar
Avatar
6
mar 18
6472
Fleet invoicing
fleet
Avatar
0
mar 15
4305
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now