Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4 Antwoorden
6228 Weergaven

Hi all:

  I'm trying to change res_partner.py and wanna add some fields in it,but when I restart my pycharm,when I clicked any module,it warns me:


Odoo Server Error

Traceback (most recent call last):
File "D:\odoo\test_1\odoo\api.py", line 1039, in get
value = self._data[key][field][record._ids[0]]
KeyError: 13

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\odoo\test_1\odoo\fields.py", line 980, in __get__
value = record.env.cache.get(record, self)
File "D:\odoo\test_1\odoo\api.py", line 1041, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('res.partner(13,).display_name', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\odoo\test_1\odoo\http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "D:\odoo\test_1\odoo\http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "D:\odoo\test_1\odoo\tools\pycompat.py", line 87, in reraise
raise value
File "D:\odoo\test_1\odoo\http.py", line 696, in dispatch
result = self._call_function(**self.params)
File "D:\odoo\test_1\odoo\http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "D:\odoo\test_1\odoo\service\model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "D:\odoo\test_1\odoo\http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "D:\odoo\test_1\odoo\http.py", line 939, in __call__
return self.method(*args, **kw)
File "D:\odoo\test_1\odoo\http.py", line 517, in response_wrap
response = f(*args, **kw)
File "d:\odoo\test_1\addons\web\controllers\main.py", line 904, in search_read
return self.do_search_read(model, fields, offset, limit, domain, sort)
File "d:\odoo\test_1\addons\web\controllers\main.py", line 926, in do_search_read
offset=offset or 0, limit=limit or False, order=sort or False)
File "D:\odoo\test_1\odoo\models.py", line 4569, in search_read
result = records.read(fields)
File "D:\odoo\test_1\odoo\models.py", line 2787, in read
vals[name] = convert(record[name], record, use_name_get)
File "D:\odoo\test_1\odoo\fields.py", line 2159, in convert_to_read
return (value.id, value.sudo().display_name)
File "D:\odoo\test_1\odoo\fields.py", line 984, in __get__
self.determine_value(record)
File "D:\odoo\test_1\odoo\fields.py", line 1085, in determine_value
record._prefetch_field(self)
File "D:\odoo\test_1\odoo\models.py", line 2832, in _prefetch_field
result = records.read([f.name for f in fs], load='_classic_write')
File "D:\odoo\test_1\odoo\models.py", line 2770, in read
self._read_from_database(stored, inherited)
File "D:\odoo\test_1\odoo\models.py", line 2897, in _read_from_database
cr.execute(query_str, params)
File "D:\odoo\test_1\odoo\sql_db.py", line 148, in wrapper
return f(self, *args, **kwargs)
File "D:\odoo\test_1\odoo\sql_db.py", line 225, in execute
res = self._obj.execute(query, params)
psycopg2.errors.UndefinedColumn: column res_partner.lzqbdk does not exist
LINE 1: ...re" as "partner_share","res_partner"."tz" as "tz","res_partn...
^

  So is there a correct way to change base module?

  Thanks                    

Avatar
Annuleer
Beste antwoord

Hello, 

You can inherit = 'res.partner' and add your field in a python file and In XML file, you can inherit from view base.view_partner_form using XPath you can add in your field and restart your server and upgrade your module using UI as well as a command line for command line you can try this ./odoo-bin -u module_name.

Avatar
Annuleer
Beste antwoord

this is an old question but still a relevant issue with Odoo.


these 2 blog articles explains in detail how to accomplish this. so kudos to the blog owners for providing it, 

https://www.excelroot.com/post/error-upgrading-after-adding-new-field-to-res-users-and-res-company

https://mellowhost.com/blog/how-to-add-fields-to-res-users-or-res-partners-model-in-odoo.html

Avatar
Annuleer
Beste antwoord

Hi,

It is better to inherit and add fields to res.partner than directly changing it in base code. If you're using pycharm you can also directly upgrade by adding '-d databasename -u module' in parameters in pycharm configuration

Avatar
Annuleer
Beste antwoord


There is a solution for this

if you add any new fields to the res_company, res_partner, res_users tables you have to follow the following steps.

1) add new fields

2) open your custom module from the apps list

3) restart server, do immediate upgrade of custom module

Note : Here the problem is if you add any new fields to the res_company, res_partner, res_users tables every request it will check. If you upgrade after restart without any request it will work.

refer: https://www.odoo.com/forum/help-1/question/hi-everyone-here-i-need-the-solution-in-this-error-programmingerror-column-res-partner-instructor-does-not-exist-i-was-trying-to-inherit-res-partner-in-my-custom-module-129222#answer-141953

Avatar
Annuleer