Aller au contenu

V8 : Erreur AttributeError: 'NoneType' object has no attribute 'year'

Featured Replies

Posté(e)

Bonjour

Dans mon module, j'ai mis à la ligne from datetime import date

Dans ma classe, je calcule une date

Citation

@api.onchange('der_Date_chronotachygraphe')
    def _compute_prodatechronota(self):
        
        dt_control1 = fields.Date.from_string(self.der_Date_chronotachygraphe)
        dt_futur1 = date(dt_control1.year + 2, dt_control1.month, dt_control1.day)
        self.pro_Date_chronotachygraphe = fields.Date.to_string(dt_futur1)

Lorsque je crée un nouvel enregistrement, je tombe sur cette erreur.

Citation

 

Odoo Server Error

Traceback (most recent call last):
  File "/odoo/odoo-server/openerp/http.py", line 544, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/odoo/odoo-server/openerp/http.py", line 581, in dispatch
    result = self._call_function(**self.params)
  File "/odoo/odoo-server/openerp/http.py", line 317, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/odoo/odoo-server/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/odoo/odoo-server/openerp/http.py", line 314, in checked_call
    return self.endpoint(*a, **kw)
  File "/odoo/odoo-server/openerp/http.py", line 810, in __call__
    return self.method(*args, **kw)
  File "/odoo/odoo-server/openerp/http.py", line 410, in response_wrap
    response = f(*args, **kw)
  File "/odoo/odoo-server/addons/web/controllers/main.py", line 944, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/odoo/odoo-server/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/odoo/odoo-server/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/odoo/odoo-server/openerp/models.py", line 5989, in onchange
    record._onchange_eval(name, field_onchange[name], result)
  File "/odoo/odoo-server/openerp/models.py", line 5832, in _onchange_eval
    method_res = method(self)
  File "/mesaddons/bxcamion/bxcamion.py", line 77, in _compute_prodatechronota
    dt_futur1 = date(dt_control1.year + 2, dt_control1.month, dt_control1.day)
AttributeError: 'NoneType' object has no attribute 'year'

 

Le hic, c'est qu'il me fait bien de le calcul.

J'arrive à valider mon enregistrement mais celui n'apparait pas à l'écran.

Pouvez vous me donner une idée, une solution

Merci

Cordialement

Rejoindre la conversation

Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.

Invité
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Répondre à ce sujet…

Qui est en ligne (Afficher la liste complète)

  • Il n’y a aucun utilisateur enregistré actuellement en ligne

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.