İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
3022 Görünümler

What would be causing this error? The override code does not do anything but print values. When I comment it out, it works fine. Anyone got any clues??

@api.model
def create(self, vals):
print("CREATE....", vals)
super(ResPartner, self).create(vals)


Here is the error:

Traceback (most recent call last):
  File "/opt/odoosrc/16.0/odoo/odoo/models.py", line 5739, in concat
    if arg._name != self._name:
AttributeError: 'NoneType' object has no attribute '_name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoosrc/16.0/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoosrc/16.0/odoo/odoo/service/model.py", line 134, in retrying
    result = func()
  File "/opt/odoosrc/16.0/odoo/odoo/http.py", line 1611, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoosrc/16.0/odoo/odoo/http.py", line 1808, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoosrc/16.0/odoo/odoo/addons/base/models/ir_http.py", line 149, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoosrc/16.0/odoo/odoo/http.py", line 699, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoosrc/16.0/odoo/addons/web/controllers/dataset.py", line 42, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoosrc/16.0/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoosrc/16.0/odoo/odoo/api.py", line 459, in call_kw
    result = _call_kw_model_create(method, model, args, kwargs)
  File "/opt/odoosrc/16.0/odoo/odoo/api.py", line 439, in _call_kw_model_create
    result = method(recs, *args, **kwargs)
  File "", line 2, in create
  File "/opt/odoosrc/16.0/odoo/odoo/api.py", line 409, in _model_create_multi
    return create(self, [arg])
  File "/opt/odoosrc/16.0/odoo/addons/account/models/partner.py", line 625, in create
    return super().create(vals_list)
  File "", line 2, in create
  File "/opt/odoosrc/16.0/odoo/odoo/api.py", line 410, in _model_create_multi
    return create(self, arg)
  File "/opt/odoosrc/16.0/odoo/addons/partner_autocomplete/models/res_partner.py", line 163, in create
    partners = super(ResPartner, self).create(vals_list)
  File "", line 2, in create
  File "/opt/odoosrc/16.0/odoo/odoo/api.py", line 390, in _model_create_single
    return self.browse().concat(*(create(self, vals) for vals in arg))
  File "/opt/odoosrc/16.0/odoo/odoo/models.py", line 5743, in concat
    raise TypeError(f"unsupported operand types in: {self} + {arg!r}")
TypeError: unsupported operand types in: res.partner() + None

The above server error caused the following client error:
null


Avatar
Vazgeç
En İyi Yanıt

You can try one of the below codes, and make sure to restart the Odoo service and upgrade your module after "Update App Lists"


Note: Both codes are tested in Odoo 16 and working properly.


from odoo import models, api

class ResPartner(models.Model):
_inherit = 'res.partner'

@api.model
def create(self, vals):
print("CREATE....", vals)
return super().create(vals)

   from odoo import models, api

class ResPartner(models.Model):
_inherit = 'res.partner'

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
print("CREATE..", %vals)
return super().create(vals_list)


   
Avatar
Vazgeç
Üretici

Awesome! that worked!
I still don't understand why the original one did not work but I am very grateful that this one did. Thank you Waleed.

En İyi Yanıt

Hi,

Try this Code snippet

class ResPartnerInherit(models.Model):
_inherit='res.partner'

@api.model
def create(self, vals):
print("CREATE....", vals)
return super(ResPartnerInherit, self).create(vals)

Regards

Avatar
Vazgeç
Üretici

Thank you but same error unfortunately.

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
May 25
1508
1
Mar 25
1650
MERGING CONTACTS Çözüldü
1
Şub 25
3926
2
Şub 25
3115
2
Şub 25
2348