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

error in timesheet.py

Subscriure's

Get notified when there's activity on this post

This question has been flagged
errortimesheetodoo8.0
5 Respostes
4788 Vistes
Avatar
wizardz

What is this error? How can I fix it: 


File "/opt/custom_addons/hr_presence/hr_timesheet.py", line 81, in _holidays
    start_date = datetime.datetime.strptime(record.date_from, '%Y-%m-%d')
0
Avatar
Descartar
Priyesh Solanki

Can you please provide the whole traceback ?

Avatar
Bhavik Bagadiya
Best Answer

Hello Wizardz

Try this code 

first import 

from datetime import datetime

from openerp.tools import DEFAULT_SERVER_DATE_FORMAT

then use

start_date = datetime.strptime(record.date_from, DEFAULT_SERVER_DATE_FORMAT)

Thanx

0
Avatar
Descartar
wizardz
Autor

start_date = datetime.datetime.strptime(record.date_from, str(DEFAULT_SERVER_DATE_FORMAT)) TypeError: must be string, not bool How can I make this column in a string ?

wizardz
Autor

when I say date_from and date_to at the beginning of the record with a string '2000-01-01' it works.

Bhavik Bagadiya

can you tell what record.date_from returns value? because if record.date_from returns datetime then only it converts in date, if it returns true,false then not possible in date

wizardz
Autor

The return of record.date_from and record.date_to are "False"

Avatar
wizardz
Autor Best Answer

Traceback (most recent call last):
  File "/opt/odoo/src/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/src/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/src/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/src/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/src/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/src/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/src/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/src/openerp/addons/web/controllers/main.py", line 944, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/src/openerp/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoo/src/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/src/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/src/openerp/models.py", line 5920, in onchange
    record = self.new(values)
  File "/opt/odoo/src/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/src/openerp/models.py", line 5484, in new
    record._cache.update(record._convert_to_cache(values, update=True))
  File "/opt/odoo/src/openerp/models.py", line 5379, in _convert_to_cache
    for name, value in values.iteritems()
  File "/opt/odoo/src/openerp/models.py", line 5380, in <dictcomp>
    if name in fields
  File "/opt/odoo/src/openerp/fields.py", line 1572, in convert_to_cache
    return record.env[self.comodel_name].new(value)
  File "/opt/odoo/src/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/src/openerp/models.py", line 5484, in new
    record._cache.update(record._convert_to_cache(values, update=True))
  File "/opt/odoo/src/openerp/models.py", line 5379, in _convert_to_cache
    for name, value in values.iteritems()
  File "/opt/odoo/src/openerp/models.py", line 5380, in <dictcomp>
    if name in fields
  File "/opt/odoo/src/openerp/fields.py", line 1640, in convert_to_cache
    ids = OrderedSet(record[self.name].ids)
  File "/opt/odoo/src/openerp/models.py", line 5641, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/opt/odoo/src/openerp/fields.py", line 834, in __get__
    self.determine_draft_value(record)
  File "/opt/odoo/src/openerp/fields.py", line 942, in determine_draft_value
    self._compute_value(record)
  File "/opt/odoo/src/openerp/fields.py", line 881, in _compute_value
    self.compute(records)
  File "/opt/odoo/src/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/saas_addons/hr_presence/hr_timesheet.py", line 84, in _holidays
    start_date = datetime.datetime.strptime(record.date_from, '%Y-%m-%d')
TypeError: must be string, not bool


and this is the modul where the error comes from:


@api.multi

def _holidays(self):

for record in self:

start_date = datetime.datetime.strptime(str(record.date_from), '%Y-%m-%d') #error this line

end_date = datetime.datetime.strptime(record.date_to, '%Y-%m-%d') #error this line

end_date = end_date.replace(hour=23, minute=59, second=59)

date_start = str(start_date)

date_end = str(end_date)

record.holiday_ids = self.env['hr.holidays'].search(

['&', '&', ('employee_id', '=', record.employee_id.id), ('state', 'in', ['confirm', 'validate1', 'validate']),

'|',

'|',

'&', ('date_from', '>=', date_start), ('date_from', '<=', date_end),

'&', ('date_to', '>=', date_start), ('date_to', '<=', date_end),

'&', ('date_from', '<=', date_start), ('date_to', '>=', date_end)

])

0
Avatar
Descartar
Pawan

Wizards, Please check if you have set date_from value, as its getting date_from as False

wizardz
Autor

how ?

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
Integrity error while adding calendar view.
error odoo8.0
Avatar
0
d’ag. 15
3815
After creating a new database, why am I unable to log in it?
error database odoo8.0
Avatar
Avatar
Avatar
3
de juny 22
15064
Sending an email with the employee's timesheet by clicking button 'confirm'
email timesheet odoo8.0
Avatar
0
de set. 19
5142
How to make timesheet creation monthly in odoo 8 Solved
hr timesheet odoo8.0
Avatar
Avatar
1
de nov. 16
4261
Problems with Product module
error product odoo8.0
Avatar
Avatar
4
de set. 16
3847
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