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

Error When Created second records

Odoberať

Get notified when there's activity on this post

This question has been flagged
3253 Zobrazenia
Avatar
philip

Is there anyone can figure out what has to be done. When I created My first record,
everything is fine then created the second record I got error message below. and I don't know how to fix.
Is this a bug or something wrong with my module/code.

Thank you

python functions------

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
import time
from osv import osv, fields

class xyz_product(osv.Model):
    _name = "xyz.product"

            ## Beginning Selling Area
    def totalbegsellingarea(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.begsellingareaboxpcs=='12':
                res[xyzprod.id] = xyzprod.begsellingarea * 12
            if xyzprod.begsellingareaboxpcs=='1':
                res[xyzprod.id] = xyzprod.begsellingarea * 1
            return res
            ## Beginning Warehouse
    def totalbegwarehouse(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.begwarehousboxpcs=='12':
                res[xyzprod.id] = xyzprod.begwarehouse * 12
            if xyzprod.begwarehousboxpcs=='1':
                res[xyzprod.id] = xyzprod.begwarehouse * 1
            return res
            
            ## Ending Selling Area
    def totalendsellingarea(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.endsellingareaboxpcs=='12':
                res[xyzprod.id] = xyzprod.endsellingarea * 12
            if xyzprod.endsellingareaboxpcs=='1':
                res[xyzprod.id] = xyzprod.endsellingarea * 1
            return res
            ## Ending Warehouse
    def totalendwarehouse(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.endwarehousboxpcs=='12':
                res[xyzprod.id] = xyzprod.endwarehouse * 12
            if xyzprod.endwarehousboxpcs=='1':
                res[xyzprod.id] = xyzprod.endwarehouse * 1
            return res

    def get_daysales1(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales1 in self.browse(cr, uid, ids, context):
            res[daysales1.id] = daysales1.price * daysales1.offtake1
            return res

    def get_daysales2(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales2 in self.browse(cr, uid, ids, context):
            res[daysales2.id] = daysales2.price * daysales2.offtake2
            return res

    def get_daysales3(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales3 in self.browse(cr, uid, ids, context):
            res[daysales3.id] = daysales3.price * daysales3.offtake3
            return res

    def get_daysales4(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales4 in self.browse(cr, uid, ids, context):
            res[daysales4.id] = daysales4.price * daysales4.offtake4
            return res

    def get_daysales5(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales5 in self.browse(cr, uid, ids, context):
            res[daysales5.id] = daysales5.price * daysales5.offtake5
            return res
    
    def get_daysales6(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales6 in self.browse(cr, uid, ids, context):
            res[daysales6.id] = daysales6.price * daysales6.offtake6
            return res

    def get_daysales7(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales7 in self.browse(cr, uid, ids, context):
            res[daysales7.id] = daysales7.price * daysales7.offtake7
            return res

    def get_totaldelivery(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzdelivery in self.browse(cr, uid, ids, context):
            res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7
            return res

    def get_totalreturn(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzreturn in self.browse(cr, uid, ids, context):
            res[xyzreturn.id] = xyzreturn.return1 + xyzreturn.return2 + xyzreturn.return3 + xyzreturn.return4 + xyzreturn.return5 + xyzreturn.return6 + xyzreturn.return7
            return res

    def get_totalpullout(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzpullout in self.browse(cr, uid, ids, context):
            res[xyzpullout.id] = xyzpullout.pullout1 + xyzpullout.pullout2 + xyzpullout.pullout3 + xyzpullout.pullout4 + xyzpullout.pullout5 + xyzpullout.pullout6 + xyzpullout.pullout7
            return res

    def get_totalofftake(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzofftake in self.browse(cr, uid, ids, context):
            res[xyzofftake.id] = ((xyzofftake.begwarehouse + xyzofftake.begsellingarea) + xyzofftake.totaldelivery + xyzofftake.totalreturn - (xyzofftake.endwarehouse + xyzofftake.endsellingarea)) - xyzofftake.totalpullout
            return res

    def get_totalweeklysales(self, cr, uid, ids, name, arg, context):
        res = {}
        for totalweeklysales in self.browse(cr, uid, ids, context):
            res[totalweeklysales.id] = totalweeklysales.price * totalweeklysales.totalofftake
            return res

    _columns = {

.......

}

error in ubuntu version OpenERP7/odoo7---------------

Client Traceback (most recent call last):
 

     File "/home/philip/ws/openerp/web/addons/web/http.py", line 204, in dispatch
        response["result"] = method(self, **self.params)
      File "/home/philip/ws/openerp/web/addons/web/controllers/main.py", line 1051, in search_read
        return self.do_search_read(req, model, fields, offset, limit, domain, sort)
      File "/home/philip/ws/openerp/web/addons/web/controllers/main.py", line 1086, in do_search_read
        records = Model.read(ids, fields or False, req.context)
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 42, in proxy
        result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 30, in proxy_method
        result = self.session.send(self.service_name, method, *args)
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 103, in send
        raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)


    Server Traceback (most recent call last):
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 89, in send
        return openerp.netsvc.dispatch_rpc(service_name, method, args)
      File "/home/philip/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
        result = ExportService.getService(service_name).dispatch(method, params)
      File "/home/philip/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch
        res = fn(db, uid, *params)
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
        return self.execute(db, uid, obj, method, *args, **kw or {})
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper
        return f(self, dbname, *args, **kwargs)
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 199, in execute
        res = self.execute_cr(cr, uid, obj, method, *args, **kw)
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
        return getattr(object, method)(cr, uid, *args, **kw)
      File "/home/philip/ws/openerp/server/openerp/osv/orm.py", line 3674, in read
        result = self._read_flat(cr, user, select, fields, context, load)
      File "/home/philip/ws/openerp/server/openerp/osv/orm.py", line 3798, in _read_flat
        record[f] = res2[record['id']]
    KeyError: 2

error in Windows version OpenERP7/odoo7-----------------

Client Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\http.py", line 204, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\controllers\main.py", line 1051, in search_read
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\controllers\main.py", line 1086, in do_search_read
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 42, in proxy
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 30, in proxy_method
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\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-20140622-231040\Server\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\netsvc.py", line 296, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 190, in execute_kw
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 132, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 199, in execute
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 187, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 3679, in read
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 3803, in _read_flat
KeyError: 2

But if I remove the folowing line:

    def get_totaldelivery(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzdelivery in self.browse(cr, uid, ids, context):
            res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7
            return res

    def get_totalreturn(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzreturn in self.browse(cr, uid, ids, context):
            res[xyzreturn.id] = xyzreturn.return1 + xyzreturn.return2 + xyzreturn.return3 + xyzreturn.return4 + xyzreturn.return5 + xyzreturn.return6 + xyzreturn.return7
            return res

    def get_totalpullout(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzpullout in self.browse(cr, uid, ids, context):
            res[xyzpullout.id] = xyzpullout.pullout1 + xyzpullout.pullout2 + xyzpullout.pullout3 + xyzpullout.pullout4 + xyzpullout.pullout5 + xyzpullout.pullout6 + xyzpullout.pullout7
            return res

    def get_totalofftake(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzofftake in self.browse(cr, uid, ids, context):
            res[xyzofftake.id] = ((xyzofftake.begwarehouse + xyzofftake.begsellingarea) + xyzofftake.totaldelivery + xyzofftake.totalreturn - (xyzofftake.endwarehouse + xyzofftake.endsellingarea)) - xyzofftake.totalpullout
            return res

    def get_totalweeklysales(self, cr, uid, ids, name, arg, context):
        res = {}
        for totalweeklysales in self.browse(cr, uid, ids, context):
            res[totalweeklysales.id] = totalweeklysales.price * totalweeklysales.totalofftake
            return res

even if i only add like below, I got desame  above error.

is there someone who can create to compute the following field in the different way but same result

    def get_totaldelivery(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzdelivery in self.browse(cr, uid, ids, context):
            res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7
            return res

 

0
Avatar
Zrušiť
philip
Autor

is there someone who can create to compute the following field in the different way of coding but same result in below code? ----def get_totaldelivery(self, cr, uid, ids, name, arg, context): --------res = {} --------for xyzdelivery in self.browse(cr, uid, ids, context): ------------res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7 ------------return res

philip
Autor

Hi all, my apologies to my last post, I found out that the error occurred when I add my functional field to my tree view, but in form view is working but I needto show in tree view
'totaldelivery': fields.function(get_totaldelivery, 'Total Delivery'), Thanks

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
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