Skip to content

Instantly share code, notes, and snippets.

@michaelcoyote
Created April 9, 2015 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelcoyote/8c50a2a2a893cf547609 to your computer and use it in GitHub Desktop.
Save michaelcoyote/8c50a2a2a893cf547609 to your computer and use it in GitHub Desktop.
Odoo error on editing a product within sales.

Getting this error when editing a product from the "sales" page.

Using the following version of odoo installed from packages on Mint 17 (Ubuntu Trusty) Version 8.0-20150408

Odoo Server Error

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 567, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 928, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3125, in read
    result = BaseModel.read(records, fields, load=load)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3160, in read
    self._read_from_database(stored, inherited)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3338, in _read_from_database
    res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
  File "/usr/lib/python2.7/dist-packages/openerp/osv/fields.py", line 1446, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/sale/sale.py", line 1296, in _sales_count
    res[template.id] = sum([p.sales_count for p in template.product_variant_ids])
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 817, in __get__
    self.determine_value(record)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 910, in determine_value
    record._prefetch_field(self)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3215, in _prefetch_field
    result = records.read(list(fnames), load='_classic_write')
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3160, in read
    self._read_from_database(stored, inherited)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3338, in _read_from_database
    res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
  File "/usr/lib/python2.7/dist-packages/openerp/osv/fields.py", line 1446, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/sale/sale.py", line 1276, in _sales_count
    for group in self.pool['sale.report'].read_group(cr, uid, domain, ['product_id','product_uom_qty'], ['product_id'], context=context):
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 2137, in read_group
    cr.execute(query, where_clause_params)
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
ProgrammingError: relation "sale_report" does not exist
LINE 3:             FROM "sale_report" LEFT JOIN "product_product" a...
@sergueikp
Copy link

Hi, did you managed to resolve this problem ? I'am facing the same problem with my custom module, unable to edit the product when install my custom module, I can't understand what is the cause!

@nikolaiiii
Copy link

Hello. I had the very same error, and I manage to get rid of it by installing the "purchase" module (which is in "Local Modules" (Purchase Orders, Receipts, Supplier Invoices).

I guess this module added the missing relation in the database.

HTH.

@EdyKend
Copy link

EdyKend commented Apr 4, 2016

Hi All
I found the cause of the same error in my custom module, below is the part that caused the error.

class sale_order(models.Model):
_inherit ='sale.order'
.......
date_confirm = fields.Datetime('Confirmation Date', readonly=True, help="Date on which sales order is payment confirmed.", copy=False)
...........

I tried to replace the official field type from the date to datetime in field date_confirm.
if I do not replace this field type, then update the sale module, everything will be normal.

I hope this can help a little solution

@traviswaelbro
Copy link

Hello,

I was trying to accomplish the same as @EdyKend when I got this error, but I found the solution.

In order to change the date_confirm attribute into a datetime field (instead of just date), we have to change the field definition in two places:

The obvious place is in the sale module's sale.py file:

'date_confirm': fields.datetime('Confirmation Date', readonly=True, select=True, help="Date on which sales order is confirmed.", copy=False),

However, you must also change in the sale module's sale_report.py file:
'date_confirm': fields.datetime('Date Confirm', readonly=True),

(This is obviously v7 API version, but same can be achieved easily with v8 API)

@pstisoluciones
Copy link

this error was caused when I added the integrations of DHL/FEDEX on WAREHOUSE, solution, update the module Sales.

@abdell2
Copy link

abdell2 commented Jun 24, 2021

Odoo Server Error
Odoo Server Error
Traceback (most recent call last):
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\api.py", line 1032, in get
value = self._data[field][record.id][key]
KeyError: <odoo.api.Environment object at 0x05639610>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\fields.py", line 970, in get
value = record.env.cache.get(record, self)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\api.py", line 1034, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('product.template(2447,).sales_count', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\api.py", line 1032, in get
value = self._data[field][record.id][key]
KeyError: <odoo.api.Environment object at 0x0532DAB0>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\fields.py", line 970, in get
value = record.env.cache.get(record, self)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\api.py", line 1034, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('product.product(2441,).sales_count', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\tools\pycompat.py", line 87, in reraise
raise value
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 696, in dispatch
result = self._call_function(**self.params)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\service\model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 939, in call
return self.method(*args, **kw)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\http.py", line 517, in response_wrap
response = f(*args, **kw)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\addons\web\controllers\main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\addons\web\controllers\main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\api.py", line 749, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\api.py", line 736, in call_kw_multi
result = method(recs, *args, **kwargs)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\models.py", line 2770, in read
values[name] = field.convert_to_read(record[name], record, use_name_get)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\models.py", line 5049, in getitem
return self.fields[key].get
(self, type(self))
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\fields.py", line 974, in get
self.determine_value(record)
File "C:\Program Files (x86)\BALICOM 12.0\server\odoo\fields.py", line 1085, i…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment