Related
I want to get the product binding and show it in a view (this works). If it has no binding I have to check if that product is part of a bill of materials and if it is, I have to look for the binding of the parent and show that binding (this is what doesn't work, it doesn't give error but it doesn't assign the value of the parent to the child).
class ProductProduct(models.Model):
_inherit = 'product.product'
main_endado_bind = fields.Char(
string='Main Endado Bind',
store=True,
compute='_get_endado_bind'
)
#api.multi
#api.depends('endado_bind_ids', 'bom_ids.bom_line_ids')
def _get_endado_bind(self, external_id=''):
for product in self:
if product.endado_bind_ids:
parent_external_id = product.endado_bind_ids[0].external_id
product.main_endado_bind = parent_external_id
for line_product in product.bom_ids.bom_line_ids:
line_product.product_id._get_endado_bind(external_id=parent_external_id)
elif external_id:
product.main_endado_bind = external_id
When modifying a BOM I want to assign the binding id of the parent to the new material but it is the parent that triggers the compute as it is its BOM that is modified.
If instead of the last line I use a write I get this error:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/mnt/environment/odoo-server/odoo/fields.py", line 967, in __get__
value = record.env.cache.get(record, self)
File "/mnt/environment/odoo-server/odoo/api.py", line 1041, in get
value = self._data[key][field][record._ids[0]]
KeyError: 79
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/environment/odoo-server/odoo/http.py", line 653, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/mnt/environment/odoo-server/odoo/http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/mnt/environment/odoo-server/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/mnt/environment/odoo-server/odoo/http.py", line 695, in dispatch
result = self._call_function(**self.params)
File "/mnt/environment/odoo-server/odoo/http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/mnt/environment/odoo-server/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/mnt/environment/odoo-server/odoo/http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "/mnt/environment/odoo-server/odoo/http.py", line 939, in __call__
return self.method(*args, **kw)
File "/mnt/environment/odoo-server/odoo/http.py", line 517, in response_wrap
response = f(*args, **kw)
File "/mnt/develop/odoo-server/addons/web/controllers/main.py", line 935, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/mnt/develop/odoo-server/addons/web/controllers/main.py", line 927, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/mnt/environment/odoo-server/odoo/api.py", line 756, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/mnt/environment/odoo-server/odoo/api.py", line 743, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/mnt/develop/odoo-server/addons/mail/models/mail_thread.py", line 283, in write
result = super(MailThread, self).write(values)
File "/mnt/environment/connector/component_event/models/base.py", line 102, in write
result = super(Base, self).write(vals)
File "/mnt/environment/odoo-server/odoo/models.py", line 3208, in write
self._write(store_vals)
File "/mnt/environment/odoo-server/odoo/models.py", line 3430, in _write
self.recompute()
File "/mnt/environment/odoo-server/odoo/models.py", line 5096, in recompute
vals = {n: rec[n] for n in ns}
File "/mnt/environment/odoo-server/odoo/models.py", line 5096, in
vals = {n: rec[n] for n in ns}
File "/mnt/environment/odoo-server/odoo/models.py", line 4944, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/mnt/environment/odoo-server/odoo/fields.py", line 974, in __get__
value = record.env.cache.get(record, self)
File "/mnt/environment/odoo-server/odoo/api.py", line 1041, in get
value = self._data[key][field][record._ids[0]]
KeyError: 79
The KeyError: 79 is the id of the bom line.
Any idea? Thanks!
Here are some ideas about your error.
main_endado_bind has been declared with char data type. So it always stores char values.
According to your code, it seems parent_external_id has integer value. And you are assigning integer values to char data type fields. So it doesn't work.
To resolve this issue, we have to explicitly type cast into char. For example,
product.main_endado_bind = str(parent_external_id)
I have installed "Sales Management" app on my Odoo v11 community edition. Everything was working fine until a few days ago. Now whenever I click on the "sales" tab, I get this server error:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/cache.py", line 84, in lookup
r = d[key]
File "/usr/lib/python3/dist-packages/odoo/tools/func.py", line 68, in wrapper
return func(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.actions.actions', <function IrActions.get_bindings at 0x7efe15cfc0d0>, frozenset({1, 3, 4, 38, 39, 8, 7, 12, 13, 14, 47, 48, 22, 23, 25, 30}), 'sale.order')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 940, in __get__
value = record.env.cache.get(record, self)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 967, in get
value = self._data[key][field][record._ids[0]]
KeyError: 291
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 651, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 693, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 342, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 335, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 937, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 934, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 926, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 687, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 672, in call_kw_model
result = method(recs, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 1297, in load_views
for [v_id, v_type] in views
File "/usr/lib/python3/dist-packages/odoo/models.py", line 1297, in <dictcomp>
for [v_id, v_type] in views
File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 374, in fields_view_get
res = super(MailThread, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 1389, in fields_view_get
bindings = self.env['ir.actions.actions'].get_bindings(self._name)
File "<decorator-gen-27>", line 2, in get_bindings
File "/usr/lib/python3/dist-packages/odoo/tools/cache.py", line 89, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_actions.py", line 120, in get_bindings
result[binding_type].append(action.read()[0])
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_actions.py", line 207, in read
result = super(IrActionsActWindow, self).read(fields, load=load)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 2609, in read
vals[name] = convert(record[name], record, use_name_get)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4786, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 944, in __get__
self.determine_value(record)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1055, in determine_value
self.compute_value(recs)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1011, in compute_value
self._compute_value(records)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1002, in _compute_value
getattr(records, self.compute)()
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_actions.py", line 167, in _compute_search_view
fvg = self.env[act.res_model].fields_view_get(act.search_view_id.id, 'search')
File "/usr/lib/python3/dist-packages/odoo/api.py", line 761, in __getitem__
return self.registry[model_name]._browse((), self)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 179, in __getitem__
return self.models[model_name]
KeyError: 'sale.advance.payment.inv'
The only code change I made was adding an if-else statement in product_template to add a constraint and it was working perfectly fine along with the sales module, but now all of a sudden the sales module throws this exception.
What could be causing this?
Check your manifest.py for dependencies. If you are using a field from another module you must add it.
I'm running to_csv command as follows to an ouput file on a s3 bucket with ServerSideEncryption enabled:
to_csv("s3://mys3bucket/result.csv",
storage_option={'s3_additional_kwargs':
{'ServerSideEncryption': 'AES256'}})
I'm getting the following attribute error:
File "/usr/lib/python2.7/site-packages/dask/dataframe/core.py", line 1091, in to_csv
return to_csv(self, filename, **kwargs)
File "/usr/lib/python2.7/site-packages/dask/dataframe/io/csv.py", line 577, in to_csv
delayed(values).compute(get=get, scheduler=scheduler)
File "/usr/lib/python2.7/site-packages/dask/base.py", line 156, in compute
(result,) = compute(self, traverse=False, **kwargs)
File "/usr/lib/python2.7/site-packages/dask/base.py", line 400, in compute
results = schedule(dsk, keys, **kwargs)
File "/usr/lib/python2.7/site-packages/distributed/client.py", line 2159, in get
direct=direct)
File "/usr/lib/python2.7/site-packages/distributed/client.py", line 1562, in gather
asynchronous=asynchronous)
File "/usr/lib/python2.7/site-packages/distributed/client.py", line 652, in sync
return sync(self.loop, func, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/distributed/utils.py", line 275, in sync
six.reraise(*error[0])
File "/usr/lib/python2.7/site-packages/distributed/utils.py", line 260, in f
result[0] = yield make_coro()
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 260, in result
raise_exc_info(self._exc_info)
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/lib/python2.7/site-packages/distributed/client.py", line 1439, in _gather
traceback)
File "/usr/lib/python2.7/site-packages/dask/dataframe/io/csv.py", line 439, in _to_csv_chunk
df.to_csv(f, **kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/core/frame.py", line 1745, in to_csv
formatter.save()
File "/usr/lib64/python2.7/site-packages/pandas/io/formats/csvs.py", line 161, in save
buf = f.getvalue()
File "/usr/lib/python2.7/site-packages/dask/bytes/utils.py", line 136, in __getattr__
return getattr(self.file, key)
AttributeError: 'S3File' object has no attribute 'getvalue'
I searched for this error, but couldn't find a relevant solution.
Do you have any idea?
Any ideas on the following odoo error? I Installed the Accounting module and instead of modifying the default Sales and Purchase Taxes entries ODOO created, made my own and deleted theirs. This error started happening when I try accessing different parts of the accounting module. I could try to reinstall the module but have had bad experiences with that.
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/http.py", line 646, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/http.py", line 319, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/http.py", line 312, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/http.py", line 962, in __call__
return self.method(*args, **kw)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/http.py", line 512, in response_wrap
response = f(*args, **kw)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/addons/web/controllers/main.py", line 897, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/addons/web/controllers/main.py", line 889, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/api.py", line 381, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/models.py", line 6054, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/models.py", line 5911, in _onchange_eval
method_res = method(self)
File "/opt/odoo-9.0.20160620-2/apps/odoo/lib/odoo-9.0rc20160620-py2.7.egg/openerp/addons/account/models/res_config.py", line 169, in onchange_company_id
self.default_sale_tax_id = isinstance(taxes_id, list) and taxes_id[0] or taxes_id
IndexError: list index out of range
This was a bug that was fixed on commit 1d843884e861252e395e0818b0fbf8aa074cd9d2.
Do a git pull on your branch to update your server files,restart the server and try again.
The problem is that in "res_config.py" you have a list you work with the first element is probably empty
To avoid this problem, you can use taxes_id[0] inside if taxes_id:
I am using Odoo 8 on Ubuntu.
I have problem opening some customers (some are OK). When I try to open it for editing I get Odoo Server Error...IndexError: list index out of range.
Any idea what could cause this problem ? I tried to search for similar problems but I have not found any solution. So when I want to edit the client I have to create new one, I also tried to merge them after creating new one but the error reappears again.
thank you and here is complete traceback:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo/openerp/http.py", line 530, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/openerp/http.py", line 567, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo/openerp/http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/openerp/http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo/odoo/openerp/http.py", line 796, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 949, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 932, in _call_kw
records = getattr(request.session.model(model), method)(*args, **kwargs)
File "/opt/odoo/odoo/openerp/http.py", line 900, in proxy
result = meth(cr, request.uid, *args, **kw)
File "/opt/odoo/odoo/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 3109, in read
result = BaseModel.read(records, fields, load=load)
File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 3141, in read
self._read_from_database(stored)
File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 3305, in _read_from_database
res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
File "/opt/odoo/odoo/openerp/osv/fields.py", line 1361, in get
result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
File "/opt/odoo/odoo/addons/account/partner.py", line 246, in _invoice_total
result[partner.id] = sum(inv.user_currency_price_total for inv in invoices)
File "/opt/odoo/odoo/addons/account/partner.py", line 246, in <genexpr>
result[partner.id] = sum(inv.user_currency_price_total for inv in invoices)
File "/opt/odoo/odoo/openerp/fields.py", line 760, in __get__
self.determine_value(record)
File "/opt/odoo/odoo/openerp/fields.py", line 853, in determine_value
record._prefetch_field(self)
File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 3196, in _prefetch_field
result = records.read(list(fnames), load='_classic_write')
File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 3141, in read
self._read_from_database(stored)
File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 3292, in _read_from_database
res2 = self._columns[fs[0]].get(cr, self._model, ids, fs, user, context=context, values=result)
File "/opt/odoo/odoo/openerp/osv/fields.py", line 1361, in get
result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
File "/opt/odoo/odoo/addons/account/report/account_invoice_report.py", line 40, in _compute_amounts_in_user_currency
currency_rate_id = currency_rate_obj.search(cr, uid, [('rate', '=', 1)], limit=1, context=context)[0]
IndexError: list index out of range
in the searching of currency_rate_id, the search function is getting an empty list and you are trying to select the first element from the empty list which causes the error
The solution is to add an exchange rate for the currency.
1 - Settings->Companies
2 - Edit your commpany
3 - Modify the Currency update configuration
4 - Add values for "Currencies to update" tab
Image 1
Image 2
Image 3