Using rest API, I am connecting Redmine with Python Script and Populating the data in the ODOO.
In Redmine assigned_to value in issue is empty i.e NULL, while Reading those value.
Traceback (most recent call last):
File "/home/vignesh/PycharmProjects/vignesh/vigred.py", line 23, in <module>
redmine_asssigned_to = id.assigned_to
File "/usr/local/lib/python2.7/dist-packages/python_redmine-1.5.1-py2.7.egg/redmine/resources.py", line 424, in __getattr__
return super(Issue, self).__getattr__(item)
File "/usr/local/lib/python2.7/dist-packages/python_redmine-1.5.1-py2.7.egg/redmine/resources.py", line 193, in __getattr__
return self._action_if_attribute_absent()
File "/usr/local/lib/python2.7/dist-packages/python_redmine-1.5.1-py2.7.egg/redmine/resources.py", line 294, in _action_if_attribute_absent
raise ResourceAttrError
redmine.exceptions.ResourceAttrError: Resource doesn't have the requested attribute
Short answer: Use getattr(id, 'assigned_to', None) instead of id.assigned_to.
Long answer: Python-Redmine raises ResourceAttrError if you're trying to access an attribute that doesn't exist. The problem here is that assigned_to may or may not exist on the resource object depending on if it is set in Redmine or not, also Python-Redmine doesn't hardcode any attributes inside itself, i.e. it gets them dynamically from Redmine, that is why you have this problem.
Related
in order to develop my script in an external IDE, I'm trying to automatically reload a text in blender when it is modified from outside of Blender. I think I've got the idea of how it works, but there must be one tiny detail that completely blocks me from achieving my goal.
My script is the following:
import bpy
import sys
ctx = bpy.context.copy()
for area in ctx['screen'].areas:
if area.type == 'TEXT_EDITOR':
textEditor = area
for text in bpy.data.texts:
if text.name == 'main.py':
textEditor.spaces[0].text = text
bpy.ops.text.reload()
Output:
>>> exec(bpy.data.texts['reload.py'].as_string())
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "<string>", line 13, in <module>
File "/Applications/Blender.app/Contents/Resources/3.3/scripts/modules/bpy/ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.text.reload.poll() failed, context is incorrect
I cannot get what part of the context is correct. I found no solution on the Internet, even the doc recommends reading the source code to understand what might be the cause of this error, but I couldn't find it anyway in the source code.
Can someone tell me what I am missing here please?
I am getting key error in the accessing custom model data in shell command. I have added custom addons_path in odoo.conf. For example,
addons_path = E:\Odoo\odoogithub\odoo\addons, E:\Odoo\odoogithub\odoo\custom
Below I added the exception I got while accessing the custom model.
env['srcil.product'].search([])
Traceback (most recent call last):
File "", line 1, in
File "E:\Odoo\odoogithub\odoo\odoo\api.py", line 473, in getitem
return self.registry[model_name]._browse(self, (), ())
File "E:\Odoo\odoogithub\odoo\odoo\modules\registry.py", line 177, in getitem
return self.models[model_name]
KeyError: 'srcil.product'
Additionally, I have checked the model in the settings. It is showing fine also I can create data using the create button.
Do I need to add the custom module path or model path anywhere to access the model data?
I am using a third-party module in Odoo to do mass label printing (https://www.odoo.com/apps/modules/12.0/label/) and despite the fact that the module claims to be compatible with version 12, I am getting server errors when trying to run the pdf rendering:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1677, in report_download
response = self.report_routes(reportname, converter=converter, **dict(data))
File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1614, in report_routes
pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 677, in render_qweb_pdf
html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 710, in render_qweb_html
data = self._get_rendering_context(docids, data)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 723, in _get_rendering_context
data.update(report_model._get_report_values(docids, data=data))
AttributeError: 'report.label.report_label' object has no attribute '_get_report_values'
Screenshot:
It may be an error related to the change of some Odoo version (or not, I don’t really know).
Does anyone know if this attribute exist? I haven’t been able to find this information in the Odoo documentation (it doesn’t seem very complete regarding these topic).
Here are some screenshots of the configurations I’m using:
Thank you for your help!
From the traceback you shared on first screenshot, the problem seems to be with report_model variable which is reference to report.label.report_label object, defined in label/report/dunamic_model.py file which contains the method get_report_values. But from odoo 12 community code, ir.actions.report is looking for _get_report_values, the mismatch between this two method name is actually causing the problem.
When I assign a new sharing permission level to any user,
I get this error
It seems that any folder or user produces this error. There are some users with sharing permissions already, which means this used to work before. I'm not sure what happened from then until now that changed this.
Have any of you encountered this problem before?
Error log :
Traceback (innermost last):
Module ZPublisher.Publish, line 115, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 41, in call_object
Module Products.CMFCore.FSPythonScript, line 108, in __call__
Module Shared.DC.Scripts.Bindings, line 311, in __call__
Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
Module Products.CMFCore.FSPythonScript, line 164, in _exec
Module None, line 14, in folder_localrole_edit
- <FSPythonScript at /intranet/folder_localrole_edit used for /intranet/service-areas/management-services>
- Line 14
Module <string>, line 4, in _facade
Module Products.Hotfix_20070320, line 68, in _curried
Module Products.CMFCore.MembershipTool, line 437, in setLocalRoles
Module Products.Archetypes.CatalogMultiplex, line 70, in reindexObjectSecurity
Module Products.ZCatalog.CatalogBrains, line 52, in _unrestrictedGetObject
Module OFS.Traversable, line 187, in unrestrictedTraverse
- __traceback_info__: (['mailer', 'formfolder.2009-03-22.3253705634', 'FormFolder', 'portal_factory'], 'one-melville-brand-update-2009-1')
Module Products.Five.traversable, line 126, in __bobo_traverse__
AttributeError: one-melville-brand-update-2009-1
It seems like your portal_catalog tool is inconsistent.
This means you have catalog entries (brain), with no real content (Archetype object).
You can solve this by "Clear and Rebuild" your catalog.
http://localhost:8080/${PATH_TO_PLONE}/portal_catalog/manage_catalogAdvanced -> Clear and rebuilt.
This action can take long time, depending on how many content you have.
Short explanation what seems to happen in your case:
After changing the local roles on a specific object, Plone tries to reindex the security relevant portal catalog indexes on the object itself and on all subobjects. While reindexing the subcontent it tries to get some data of a inexistent object (AttributeError while traversal).
With a fresh catalog you can avoid such errors.
In python you can compile() string to be executed faster with exec(). But as soon as i use it, we lost information when an exception happen in the exec.
For example, here is a code snippet that calling a unknown method (for demo purposes):
code = 'my_unknown_method()'
bytecode = compile(code, '<string>', 'exec')
And later, i'm calling exec on that bytecode:
exec bytecode
The traceback showed is:
Traceback (most recent call last):
File "test.py", line 3, in <module>
exec bytecode
File "<string>", line 1, in <module>
NameError: name 'my_unknown_method' is not defined
The "exec()" frame is now obscure. I would like to have a better exception like:
Traceback (most recent call last):
File "test.py", line 3, in <module>
exec "my_unknown_method()"
File "<string>", line 1, in <module>
NameError: name 'my_unknown_method' is not defined
Any thoughts ?
Notes:
I don't want to use the second argument of compile (the filename)
I have tested to play with inspect and modify f_code on the frame, but it's readonly attribute.
EDIT: after looking more to sys.excepthook, i've seen that in python source code/traceback.c, when python want to show the line content, they are fopen() directly the file if found. No hook available at all to display our own content. The only way would be to create in real fake filename on disk ? Anyone ?
EDIT2: i checked some jinja2 debug code, and they are rewriting traceback too, but not for content. Would i need a custom except hook ? My concerns with it is since it's not in the traceback itself, if an user/module/whatever take the exception, the traceback will not contain valuable information.
You should have a look at this talk by Armin Ronacher. He's the author of Jinja2 and in this talk he explained, how he manipulates stack traces in Jinja2. If I remember correctly, he's using ctypes, to manipulate the data structures on the C level of Python. The talk was in my opinion the best talk of the whole Europython 2011 by the way.
After a deep search, it's not possible, CPython is using its own API to determine where the file is etc, and it cannot be patched in pure Python.
How about something like this:
import sys
def mkexec(code_str):
bc = compile(code, '<string>', 'exec')
def run():
try:
exec bc
except: # Yes I know a bare except
t, v, tb = sys.exc_info()
raise MyUsefullException("%s raised %s" % (code_str, v))
return run
exe = mkexec("some_unknown_something()")
exe()