repeatIn(list, varname[, tagname]) -> NameError: name 'o' is not defined in openerp - openerp-7

I have got this information from the official link of odoo documentation below:
repeatIn(list, varname[, tagname]) : repeat the current part of the template (whole document, current section, current row in the table) for each object in the list. Use varname in the template's tags. Since versions 4.1.X, you can use an optional third argument that is the name of the .RML tag you want to loop on.
https://doc.odoo.com/v6.0/developer/3_11_reports/11_1_openoffice_report.html
I want to know how to use this repeatin because i have tried it like this:
<para style="P7">[[ repeatIn(get_employee_lines((example.company_id,example.date_start,example. date_end), o[,td]) ]]</para>
<para style="P7">[[ o['name'] ]]</para>
And i have got this error:
2015-09-02 11:37:00,027 8110 ERROR openerp openerp.tools.safe_eval: Cannot eval
'repeatIn(get_employee_lines((example.company_id,example.date_start,example.date_end), o[,td])'
Traceback (most recent call last):
File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 288, in safe_eval
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 162, in test_expr
code_obj = compile(expr, "", mode)
File "<string>", line 1
repeatIn(get_employee_lines((example.company_id,example.date_start,example.date_end), o[,td])
^
SyntaxError: invalid syntax
2015-09-02 11:37:00,027 8110 ERROR openerp openerp.tools.safe_eval: Cannot eval "o['name']"
Traceback (most recent call last):
File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 288, in safe_eval
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
File "", line 1, in <module>
NameError: name 'o' is not defined
Please, who can resolve this problem.
Regards.

first, the syntax is wrong, opened three paranthesis and closed only two.
<para style="P7"> [[ repeatIn(get_employee_lines(example.company_id,example.date_start,example. date_end), 'o') ]] </para>
if o is an object then user dot notation to access the values. If its a dictionary then use o['key']
here, dont know what get_employee_lines function returns, but it must return a list of [objects, or dictionaries etc]
you can compare repeatIn to for loop in python

Related

External ID not found

Odoo Server Error
Traceback (most recent call last):
File "/home/odoo/src/odoo/14.0/odoo/tools/cache.py", line 85, in lookup
r = d[key]
File "/home/odoo/src/odoo/14.0/odoo/tools/func.py", line 71, in wrapper
return func(self, *args, **kwargs)
File "/home/odoo/src/odoo/14.0/odoo/tools/lru.py", line 34, in getitem
a = self.d[obj]
KeyError: ('ir.model.data', <function IrModelData.xmlid_lookup at 0x7f5794273a60>, 'account.account_invoices_without_payment')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/14.0/addons/web/controllers/main.py", line 2121, in report_download
response = self.report_routes(reportname, docids=docids, converter=converter, context=context)
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 532, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/odoo/14.0/addons/web/controllers/main.py", line 2056, in report_routes
pdf = report.with_context(context)._render_qweb_pdf(docids, data=data)[0]
File "/home/odoo/src/odoo/14.0/addons/account/models/ir_actions_report.py", line 41, in _render_qweb_pdf
invoice_reports = (self.env.ref('account.account_invoices_without_payment'), self.env.ref('account.account_invoices'))
File "/home/odoo/src/odoo/14.0/odoo/api.py", line 511, in ref
return self['ir.model.data'].xmlid_to_object(xml_id, raise_if_not_found=raise_if_not_found)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/ir_model.py", line 1944, in xmlid_to_object
t = self.xmlid_to_res_model_res_id(xmlid, raise_if_not_found)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/ir_model.py", line 1928, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "", line 2, in xmlid_lookup
File "/home/odoo/src/odoo/14.0/odoo/tools/cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/ir_model.py", line 1921, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system:
account.account_invoices_without_payment
The error occurs when I tried to print an invoice. It happens even if I choose an empty print template. Any help?Thanks.
In my opinion, you should be check table ir_model_data with name=account.account_invoices_without_payment. If you can find, you must update module account. If you can't find, you can be insert new record table ir_model_data with name and res_id = id view account_invoices_without_payment in ir_ui_view.
May be help you.
Please upgrade the module account and make sure that the db using correctly. You can give db-filter to choose the db correctly
After checking in the settings-> external id. I find that somehow this external id got deleted for unknown reason. I opened an new database and compared and find that this is the case then I create a new eternal id according to the new db's value.

Check that `name_expressions` is iterable

When trying out the new jitify support planned for CuPy v9.x, I found that the name_expressions named argument to cupy.RawModule needs to be iterable for the NVRTC to not fail when later calling get_function. Question stemming out of cupy.RawModule using name_expressions and nvcc and/or path.
def mykernel():
grid = (...)
blocks = (...)
args = (...)
with open('my_cuda_cpp_code.cu') as f:
code = f.read()
kers = ('nameofkernel')
mod = cp.RawModule(code=code, jitify=True, name_expressions=kers, ...)
mod.get_function('nameofkernel')(grid, block, args)
The code above produces the following error output:
Traceback (most recent call last):
File "/home/mikaeltw/env/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 586, in compile
nvrtc.compileProgram(self.ptr, options)
File "cupy_backends/cuda/libs/nvrtc.pyx", line 108, in cupy_backends.cuda.libs.nvrtc.compileProgram
File "cupy_backends/cuda/libs/nvrtc.pyx", line 120, in cupy_backends.cuda.libs.nvrtc.compileProgram
File "cupy_backends/cuda/libs/nvrtc.pyx", line 58, in cupy_backends.cuda.libs.nvrtc.check_status
cupy_backends.cuda.libs.nvrtc.NVRTCError: NVRTC_ERROR_COMPILATION (6)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./jitify_test.py", line 62, in <module>
test_mykernel()
File "./jitify_test.py", line 57, in test_mykernel
mykernel(x_out, x_in)
File "./jitify_test.py", line 50, in mykernel
mod.get_function('nameofkernel')(grid, block, args)
File "cupy/core/raw.pyx", line 470, in cupy.core.raw.RawModule.get_function
File "cupy/core/raw.pyx", line 394, in cupy.core.raw.RawModule.module.__get__
File "cupy/core/raw.pyx", line 402, in cupy.core.raw.RawModule._module
File "cupy/_util.pyx", line 53, in cupy._util.memoize.decorator.ret
File "cupy/core/raw.pyx", line 547, in cupy.core.raw._get_raw_module
File "cupy/core/core.pyx", line 1829, in cupy.core.core.compile_with_cache
File "cupy/core/core.pyx", line 1883, in cupy.core.core.compile_with_cache
File "/home/mikaeltw/env/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 393, in compile_with_cache
return _compile_with_cache_cuda(
File "/home/mikaeltw/env/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 472, in _compile_with_cache_cuda
ptx, mapping = compile_using_nvrtc(
File "/home/mikaeltw/env/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 229, in compile_using_nvrtc
return _compile(source, options, cu_path,
File "/home/mikaeltw/env/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 213, in _compile
ptx, mapping = prog.compile(options, log_stream)
File "/home/mikaeltw/env/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 597, in compile
raise CompileException(log, self.src, self.name, options,
cupy.cuda.compiler.CompileException: __nv_name_map(2): error: expected an expression
__nv_name_map(2): error: Error in parsing name expression for lowered name lookup. Input name expression was: " :"
__nv_name_map(3): error: identifier "_" is undefined
--||--
Setting kers to an iterable, e.g. ['nameofkernel'] or ('nameofkernel',) and it works.
According to the docs https://docs.cupy.dev/en/stable/reference/generated/cupy.RawModule.html, the name_expressions should be given as a sequence of strings. My suggestion is to check that name_expressions is iterable (not just a single str, even though str is iterable), to catch an otherwise cryptic error when calling get_function.
Well, first of all, we did say it's a sequence (ex: list/tuple) of strings and gave an example in the doc page you quoted:
name_expressions (sequence of str) – A sequence (e.g. list) of strings referring to the names of C++ global/template kernels. For example, name_expressions=['func1<int>', 'func1<double>', 'func2'] for the template kernel func1<T> and non-template kernel func2. Strings in this tuple must then be passed, one at a time, to get_function() to retrieve the corresponding kernel.
So I don't see any ambiguity. There is no doubt that it's such a common pitfall in Python to write ('abc') and thinking it's a 1-element tuple containing the string 'abc', for which it should been written as ('abc',) with comma. But checking for such pitfall everywhere in the codebase would be a pain in the ass IMHO.
Second, even if we add a check to ensure the input is iterable, it still doesn't solve your issue as strings are also iterable/sequence:
>>> import collections.abc
>>> isinstance((1,2), collections.abc.Iterable)
True
>>> isinstance((1,2), collections.abc.Sequence)
True
>>> isinstance('abc', collections.abc.Iterable)
True
>>> isinstance('abc', collections.abc.Sequence)
True
So there is no good way to enforce this check other than checking it explicitly via isinstance(name_expressions, str), which circles back to the pain I mentioned above.

What does "Received a NULL pointer" mean by?

I attempted to execute gdal_array.SaveArray, while the error prompted as follows:
Traceback (most recent call last):
File "D:/Python34/Mycase/gdalarray_use.py", line 5, in
gdal_array.SaveArray(band1,"D:/PyGDAL_Case/dem_cjz.tif",format="GTiff")
File "D:\Python34\lib\site-packages\osgeo\gdal_array.py", line 240, in SaveArray
return driver.CreateCopy( filename, OpenArray(src_array,prototype) )
File "D:\Python34\lib\site-packages\osgeo\gdal.py", line 1478, in CreateCopy
return _gdal.Driver_CreateCopy(self, *args, **kwargs)
ValueError: Received a NULL pointer.
The issue seems to be related to _gdal.Driver_CreateCopy,right? And I don't konw what is the meaning of "Received a Null pointer".
What measures should I take to tackle this problem?

mnist_with_summaries.py error: 'Graph' object has no attribute 'SerializeToString'

When I try to run mnist_with_summaries.py I get the following error:
Traceback (most recent call last):
File "/home/rob/tf_from_source/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py", line 110, in
tf.app.run()
File "/home/rob/.virtualenvs/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/default/_app.py", line 30, in run
sys.exit(main(sys.argv))
File "/home/rob/tf_from_source/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py", line 85, in main
writer = tf.train.SummaryWriter(FLAGS.summaries_dir, sess.graph)
File "/home/rob/.virtualenvs/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/summary_io.py", line 104, in init
self.add_graph(graph_def)
File "/home/rob/.virtualenvs/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/summary_io.py", line 168, in add_graph
graph_bytes = graph_def.SerializeToString()
AttributeError: 'Graph' object has no attribute 'SerializeToString'
I'm also seeing this error on some of my own code when I try to generate a tensorboard graph. Any ideas about the problem and solution would be appreciated.
Looks like the answer was provided here. I rolled back to the r0.7 branch and the problem was resolved.

FeedparserDict object doesn't have 'content' attribute

I am trying to get familiar with the feedparser library, but I don't seem to be able to access the content attribute of entries in the feedparser object:
d = feedparser.parse('http://www.reddit.com/r/python/.rss')
post = d.entries[2]
post.content
the above code block gives me this error:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\feedparser.py", line 414, in __getattr__
return self.__getitem__(key)
File "C:\Python34\lib\site-packages\feedparser.py", line 375, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'content'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
content = post.content[0].value
File "C:\Python34\lib\site-packages\feedparser.py", line 416, in __getattr__
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'content'
Just do a print(post) and you will probably see that it doesn't have a content attribute.
RSS feeds do not guarantee that it will have one.