Community mailing list archives

community@mail.odoo.com

RE: Issue with updating res.partner category_id

by
Andreas Pohle
- 11/21/2014 06:19:27

Hello Community

 

I figgured it out. I made a mistypo in vals = {'name', mailgroupcode}

The correct code piece is vals = {'name': mailgroupcode}

 

 

Best regards


Andreas Pohle

 

 

From: Andreas Pohle
Sent: Freitag, 21. November 2014 10:00
To: 'community@mail.odoo.com'
Subject: Issue with updating res.partner category_id

 

Hello Community,

 

I have a problem updating the category_id field at the res.partner model. Any hint that someone can give me would be really appreciated.

 

My task is to parse trough an XML, get some codes and add them as Tags to the partner.

Here is the function that i implemented :

 

    def processgroups(self,cr, uid,  mailgroupnodes, partnerid, context=None):

       

        partnerrec = self.pool.get('res.partner')

        

        mailgroups = mailgroupnodes.findall('GROUP')

        for mailgroup in mailgroups: 

            mailgroupcode = mailgroup.get('CODE')

           

            if mailgroupcode:   

                vals = {'name', mailgroupcode}

                partnerrec.write(cr, uid, partnerid, {'category_id': [(0, 0, vals)]}, context = context)

 

The Error that I get is:

 

2014-11-21 08:48:41 - Processing NAV Mailgroup 01ABCNPDEM - ABC_NON_123456_DEU_EMEA

2014-11-21 08:48:41,534 4840 ERROR development openerp.http: Exception during JSON request handling.

Traceback (most recent call last):

  File "/development/github-odoo/openerp/http.py", line 504, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "/development/github-odoo/openerp/http.py", line 521, in dispatch

    result = self._call_function(**self.params)

  File "/development/github-odoo/openerp/http.py", line 283, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "/development/github-odoo/openerp/service/model.py", line 113, in wrapper

    return f(dbname, *args, **kwargs)

  File "/development/github-odoo/openerp/http.py", line 280, in checked_call

    return self.endpoint(*a, **kw)

  File "/development/github-odoo/openerp/http.py", line 737, in __call__

    return self.method(*args, **kw)

  File "/development/github-odoo/openerp/http.py", line 376, in response_wrap

    response = f(*args, **kw)

  File "/development/github-odoo/addons/web/controllers/main.py", line 952, in call_button

    action = self._call_kw(model, method, args, {})

  File "/development/github-odoo/addons/web/controllers/main.py", line 940, in _call_kw

    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/Itis-OdooAddons/itis_nav_migration/models.py", line 69, in import_file

    self.processPartner(cr,uid, importid, partnernode, context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/Itis-OdooAddons/itis_nav_migration/models.py", line 359, in processPartner

    self.processPersons(cr,uid, importid, personnodes, partner_id, context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/Itis-OdooAddons/itis_nav_migration/models.py", line 523, in processPersons

    self.processMailgroups(cr,uid, importid, mailgroupnodes, person_id, context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/Itis-OdooAddons/itis_nav_migration/models.py", line 99, in processMailgroups

    partnerrec.write(cr, uid, partnerid, {'category_id': [(0, 0, vals)]}, context = context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/github-odoo/addons/account_followup/account_followup.py", line 296, in write

    return super(res_partner, self).write(cr, uid, ids, vals, context=context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 360, in old_api

    result = method(recs, *args, **kwargs)

  File "/development/github-odoo/openerp/addons/base/res/res_partner.py", line 552, in write

    result = super(res_partner, self).write(vals)

  File "/development/github-odoo/openerp/api.py", line 235, in wrapper

    return new_api(self, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 552, in new_api

    result = method(self._model, cr, uid, self.ids, *args, **kwargs)

  File "/development/github-odoo/addons/mail/mail_thread.py", line 427, in write

    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 360, in old_api

    result = method(recs, *args, **kwargs)

  File "/development/github-odoo/openerp/models.py", line 3667, in write

    self._write(old_vals)

  File "/development/github-odoo/openerp/api.py", line 235, in wrapper

    return new_api(self, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 552, in new_api

    result = method(self._model, cr, uid, self.ids, *args, **kwargs)

  File "/development/github-odoo/openerp/models.py", line 3810, in _write

    result += self._columns[field].set(cr, self, id, field, vals[field], user, context=rel_context) or []

  File "/development/github-odoo/openerp/osv/fields.py", line 956, in set

    idnew = obj.create(cr, user, act[2], context=context)

  File "/development/github-odoo/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 332, in old_api

    result = method(recs, *args, **kwargs)

  File "/development/github-odoo/openerp/models.py", line 3946, in create

    vals = self._add_missing_default_values(vals)

  File "/development/github-odoo/openerp/api.py", line 235, in wrapper

    return new_api(self, *args, **kwargs)

  File "/development/github-odoo/openerp/api.py", line 464, in new_api

    result = method(self._model, cr, uid, *args, **kwargs)

  File "/development/github-odoo/openerp/models.py", line 1809, in _add_missing_default_values

    defaults.update(values)

ValueError: dictionary update sequence element #0 has length 10; 2 is required

 

Thanks in advance

 

Best regards


Andreas Pohle

<img width="85" height="85" id="Grafik_x0020_0" src="cid:image001.png@01D00585.285D8070" alt="Description: logo30mmx30mm.png">

IT IS AG

P.O. Box 3141

84037 Landshut

Germany

Phone: +49 8703 9069 0

Fax: +49 8703 9069 200

 

 

 

Siemensstrasse 14, 84051 Altheim

near Munich Airport (MUC)

www.itis.de

contact@itis.de

 

we create

    worlds on the

        web

IT IS US

1660 South Albion Street

Tower 1660, Suite 906

Denver, Colorado 80222

U.S.A.

Phone: +1 720 381 1380

 

 

 

 

near Denver Int. Airport (DEN)

www.itis.us

contact@itis.us

 

IT IS IN

No. 19, 2nd Floor, K.N. Govinda Reddy Layout,

Near Arekere Mico Layout., Bannerghatta Main Rd,

Bangalore – 560076, Karnataka

India

Phone: +91 804 160 6985

 

 

 

 

 

www.itis.de

contact@itis.de

 

CEO: Dipl.-Ing. Joerg Lorenz, Chairman of the board: Anke Lorenz    trade register: Landshut HRB 5072    VAT ID:DE 812896466

 

This message is the property of IT IS AG or its affiliates. It maybe legally privileged and/or confidential and is intended only for the use of the addressee's. No addressee should forward, print, copy, or otherwise reproduce this message in any manner that would allow it to be viewed by any individual not originally listed as a recipient. If you are not the intended recipient, you must not copy, disclose or use its contents. If you have received it in error, please inform us immediately by return email and delete the document..

 

Dieses E-Mail ist vertraulich. Wenn Sie nicht der rechtmaessige Empfaenger sind, duerfen Sie den Inhalt weder kopieren, verbreiten oder benutzen. Sollten Sie dieses E-Mail versehentlich erhalten haben, senden Sie es bitte an uns zurueck und loeschen es anschliessend.