Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Error When Created second records

Odebírat

Get notified when there's activity on this post

This question has been flagged
3257 Zobrazení
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šit
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!

Přihlásit se
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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