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
    • Validacions
    • 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ó
    • Gestió immobiliària
    • 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

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
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

How to resolve error : time data 'False' does not match format '%Y-%m-%d %H:%M:%S'

Subscriure's

Get notified when there's activity on this post

This question has been flagged
python3odoo11
2 Respostes
82942 Vistes
Avatar
Dhouha

When i'm trying to do an approve action that modify the hr.attendance fields via a modification request this error shows.I tried to search on the net about this error but the major answer was the format of database not the same with the code but in my case i saw the data of my database but i found the same format is used. Any idea on how can i fix this problem ?


here is my code

here is my code

 @api.multi
def modification_approval(self):     attend_signin_ids = self.env['hr.attendance'].search([('employee_id','=',self.employee_id.id)])
    check_in_date = datetime.datetime.strptime(str(self.time_check_in_1), "%Y-%m-%d %H:%M:%S").date()
    check_out_date = datetime.datetime.strptime(str(self.time_check_out_1), "%Y-%m-%d %H:%M:%S").date()
    for obj in attend_signin_ids:
        attendance_check_in_date = datetime.datetime.strptime(str(obj.check_in), "%Y-%m-%d %H:%M:%S").date()
        attendance_check_out_date = datetime.datetime.strptime(str(obj.check_out), "%Y-%m-%d %H:%M:%S").date()
        if (check_in_date == attendance_check_in_date):
            obj.write({'check_in': self.time_check_in_1,
                       'check_out': self.time_check_out_1})

    return self.write({
        'state': 'approved'
    })

Traceback


Traceback (most recent call last):
File "/opt/openhrms/odoo/http.py", line 651, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/openhrms/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/openhrms/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/openhrms/odoo/http.py", line 693, in dispatch
result = self._call_function(**self.params)
File "/opt/openhrms/odoo/http.py", line 342, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/openhrms/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/openhrms/odoo/http.py", line 335, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/openhrms/odoo/http.py", line 937, in __call__
return self.method(*args, **kw)
File "/opt/openhrms/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/opt/openhrms/addons/web/controllers/main.py", line 938, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/openhrms/addons/web/controllers/main.py", line 926, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/openhrms/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/opt/openhrms/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/openhrms/addons/sifast_attendance_modification_request/models/hr_attendance_modification_request.py", line 67, in modification_approval
attendance_check_out_date = datetime.datetime.strptime(str(obj.check_out),"%Y-%m-%d %H:%M:%S").date()
File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime
(data_string, format))
ValueError: time data 'False' does not match format '%Y-%m-%d %H:%M:%S'


0
Avatar
Descartar
Avatar
Thayif kabir
Best Answer

Hi,

Time data 'False' occurs when that field is not date string or it contains null value, So first make sure that field contains value when function is called. you can use any debugger or pycharm to find out when that field getting 'false'.

2
Avatar
Descartar
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

attendance_check_in_date = datetime.datetime.strptime(str(obj.check_in), "%Y-%m-%d %H:%M:%S").date()
attendance_check_out_date = datetime.datetime.strptime(str(obj.check_out), "%Y-%m-%d %H:%M:%S").date()

In the above line of code the value of the obj.check_in or obj,check_out might not contains values. As it does not contain value and when you try to access it or call it, it will return False. So what you have to do is that, use an if statement and check whether it contains value or not.


if obj.check_in:
attendance_check_in_date = datetime.datetime.strptime(str(obj.check_in), "%Y-%m-%d %H:%M:%S").date()
if obj.check_out:
   attendance_check_out_date = datetime.datetime.strptime(str(obj.check_out), "%Y-%m-%d %H:%M:%S").date()


Thanks

0
Avatar
Descartar
Kirollos

thank you,

it`s working with the just date.

How I can calculate duration by date & time

for i in self:

if i.start_date and i.end_date:

s_date=datetime.strptime(str(i.start_date), "%Y-%m-%d %H:%M:%S").date()

e_date=datetime.strptime(str(i.end_date), "%Y-%m-%d %H:%M:%S").date()

if s_date < e_date:

result = (e_date - s_date)

i.duration = result

else:

msg = f'{s_date} Must be older than {e_date}'

raise UserError(msg)

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
Related Posts Respostes Vistes Activitat
How to set a filter as default filter in odoo Solved
python3 odoo11
Avatar
Avatar
Avatar
2
de febr. 24
17030
How to set default stage to when recruitement record is created Solved
python3 odoo11
Avatar
Avatar
1
de des. 22
5949
How to change the value of a field which depends on other fields automatically ? Solved
python3 odoo11
Avatar
Avatar
Avatar
2
de des. 22
15929
how to modify fields of hr.attendance via a modification request automatically Solved
python3 odoo11
Avatar
Avatar
Avatar
2
de juny 22
8172
how to update field of attendance via an attendance request modification
python3 odoo11
Avatar
Avatar
Avatar
2
de juny 22
6010
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 ภาษาไทย 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