Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

[Odoo 12.0]: fields.Date.from_string(payslip.date_from).year "NoneType" object has no attribute "year"

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
Version
3 Respuestas
6552 Vistas
Avatar
Ermin Trevisan

I have installed the following module:

https://apps.odoo.com/apps/modules/12.0/l10n_ch_payroll/

When I try to create a new payslip, the following error happens (unfortunately, I did not get any feedback from the author yet):

Here is the code

class HrPayslip(models.Model):

_inherit = 'hr.payslip'

is_correction_final_payslip = fields.Boolean(string="Bulletin final de correction")
other_year_payslip_ids = fields.Many2many('hr.payslip', string="Autres salaires de l'années", compute="_get_other_payslips")

@api.multi
def _get_other_payslips(self):
for payslip in self:
current_year = fields.Date.from_string(payslip.date_from).year
date_from = "%s-01-01" % current_year
date_to = "%s-12-31" % current_year
other_payslips = self.search([
('employee_id', '=', payslip.employee_id.id),
('id', '!=', payslip.id),
('date_from', '>=', date_from),
('date_to', '<=', date_to)
])
payslip.other_year_payslip_ids = other_payslips

Here the field definition payslip.date_from:

    date_from = fields.Date(string='Date From', readonly=True, required=True,default=lambda self:fields.Date.to_string(date.today().replace(day=1)), states={'draft': [('readonly', False)]})
      
      
        

      
       

And this is the traceback:

Odoo Server ErrorTraceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 1049, in get
    value = self._data[key][field][record._ids[0]]
KeyError: <odoo.models.NewId object at 0x7f1b49640ca8>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1005, in __get__
    value = record.env.cache.get(record, self)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 1051, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('hr.payslip(<odoo.models.NewId object at 0x7f1b49640ca8>,).other_year_payslip_ids', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 656, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 314, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 698, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 346, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 941, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 962, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 759, in call_kw
    return _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 746, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5492, in onchange
    record = self.new(values)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 4954, in new
    record._cache.update(record._convert_to_cache(values, update=True))
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 4824, in _convert_to_cache
    for name, value in values.items()
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 4825, in <dictcomp>
    if name in fields
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2278, in convert_to_cache
    ids = OrderedSet(record[self.name]._ids)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5134, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1011, in __get__
    self.determine_draft_value(record)
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1133, in determine_draft_value
    self._compute_value(record)
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1067, in _compute_value
    getattr(records, self.compute)()
  File "/usr/lib/python3/dist-packages/odoo/custom/addons/l10n_ch_payroll/models/hr_payslip.py", line 24, in _get_other_payslips
    current_year = fields.Date.from_string(payslip.date_from).year
AttributeError: 'NoneType' object has no attribute 'year'

Any help is appreciated, thanks

-1
Avatar
Descartar
Ibrahim Boudmir

1- check payslip.date_from Value then

2- check fields.Date.from_string(payslip.date_from) Value

what do these 2 points return ?

Ermin Trevisan
Autor

@Ibrahim

Thanks for your feedback. I'm not a developer and have no developing environment, so I do not know how to get this information. But I have amended my question and have added the module, which produces the error when trying to create a new payslip.

Avatar
Ibrahim Boudmir
Mejor respuesta

Hi Ermin, 
Thank you for the link to the module. I have installed it to debug the code. Actually the solution is simple. 

The problem occurs because the field date_from is empty. 

Solution: 

Add if payslip.date_from to the function that computes the field other_year_payslip_ids.
So it does compute the field only if date_from exists.

I'll try to contact the author to fix this bug. 

Regards.

1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
504 Gateway Time-out nginx/1.14.0 (Ubuntu) odoo12 Resuelto
Version
Avatar
Avatar
1
dic 22
14650
Odoo 13.0+e Update One2Many values based on record change Resuelto
Version
Avatar
Avatar
1
may 22
7577
OpenERP 7 : Make many to one field read only Resuelto
Version
Avatar
Avatar
3
mar 20
3528
Invoicing Purchases To Customer not working as expected (V13)
Version
Avatar
Avatar
1
mar 20
2835
How to set Openeducat V13 on Ubuntu server 18.04
Version
Avatar
Avatar
3
mar 20
5556
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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