Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Odoo Server Error

Subscriure's

Get notified when there's activity on this post

This question has been flagged
3 Respostes
12437 Vistes
Avatar
Mozamel
Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/api.py", line 899, in get
    return field_cache[record._ids[0]]
KeyError: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/odoo/src/odoo/odoo/api.py", line 902, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'pos.config(1,).last_session_closing_date'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 242, in _dispatch
    result = request.dispatch()
  File "/home/odoo/src/odoo/odoo/http.py", line 702, in dispatch
    result = self._call_function(**self.params)
  File "/home/odoo/src/odoo/odoo/http.py", line 368, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/odoo/src/odoo/odoo/http.py", line 357, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/odoo/src/odoo/odoo/http.py", line 925, in __call__
    return self.method(*args, **kw)
  File "/home/odoo/src/odoo/odoo/http.py", line 546, in response_wrap
    response = f(*args, **kw)
  File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1282, in search_read
    return self.do_search_read(model, fields, offset, limit, domain, sort)
  File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1301, in do_search_read
    return Model.web_search_read(domain, fields, offset=offset, limit=limit, order=sort)
  File "/home/odoo/src/odoo/addons/web/models/models.py", line 62, in web_search_read
    records = self.search_read(domain, fields, offset=offset, limit=limit, order=order)
  File "/home/odoo/src/odoo/odoo/models.py", line 5091, in search_read
    result = records.read(fields, **read_kwargs)
  File "/home/odoo/src/odoo/odoo/models.py", line 3243, in read
    return self._read_format(fnames=fields, load=load)
  File "/home/odoo/src/odoo/odoo/models.py", line 3263, in _read_format
    vals[name] = convert(record[name], record, use_name_get)
  File "/home/odoo/src/odoo/odoo/models.py", line 5936, in __getitem__
    return self._fields[key].__get__(self, self.env.registry[self._name])
  File "/home/odoo/src/odoo/odoo/fields.py", line 1132, in __get__
    self.compute_value(recs)
  File "/home/odoo/src/odoo/odoo/fields.py", line 1295, in compute_value
    records._compute_field_value(self)
  File "/home/odoo/src/odoo/odoo/models.py", line 4277, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/odoo/src/odoo/odoo/fields.py", line 88, in determine
    return needle(*args)
  File "/home/odoo/src/odoo/addons/point_of_sale/models/pos_config.py", line 240, in _compute_last_session
    pos_config.last_session_closing_date = session[0]['stop_at'].astimezone(timezone).date()
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/http.py", line 658, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo/src/odoo/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
AttributeError: 'bool' object has no attribute 'astimezone'

0
Avatar
Descartar
Avatar
CodeWasher
Best Answer

The root cause of the issue is that the code in the _compute_last_session method doesn’t handle cases where session[0]['stop_at'] might be False or missing. Adding a check to ensure session[0]['stop_at'] is a valid datetime object before calling astimezone() should resolve the problem. Additionally, reviewing the POS session data to ensure integrity will help prevent this issue in the future.

1
Avatar
Descartar
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Mozamel,


I hope you are doing well.


I wanted to explain the following code snippet:


1 Conditional Check:

- The line session and session[0]['stop_at'] checks if the session list is not empty and verifies that the stop_at key exists in the first dictionary of the list.


2 Time Zone Conversion:


- The expression session[0]['stop_at'].astimezone(timezone) converts the stop_at datetime to the specified timezone.


3 Data Extraction:

- The .date() method extracts only the date part from the datetime object.


The final result is assigned to pos_config.last_session_closing_date. If the session is not valid, it assigns False.


Here's the code for your reference:


//Code in comment//

I hope this helps!


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

0
Avatar
Descartar
Jainesh Shah(Aktiv Software)

Code :

self.pos_config.last_session_closing_date = (
session[0]['stop_at'].astimezone(timezone).date()
if session and session[0]['stop_at']
else False
)

Avatar
Yahoo Baba Innovations Pvt.Ltd
Best Answer

Hi Mozamel,

You cannot access the session[0]['stop_at'] value directly. Print the result to check the output:

python Copy code print ( '\n session :' , session[ 0 ][ 'stop_at' ])

If the result is False , you need to ensure the condition is set correctly. Verify that session[0]['stop_at'] has the expected value before assigning it:

python Copy code if session[ 0 ][ 'stop_at' ]:
    pos_config.last_session_closing_date = session[ 0 ][ 'stop_at' ].astimezone(timezone).date()

Thanks & Regards,

Name: Yahoo Baba

Email: yahoobaba077@gmail.com

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

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

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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