Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

QWebException: "13 Permission denied" Error in Qweb report(with barcode)

By
bhavik vyas
on 11/3/15, 12:33 AM 1,122 views

I have developed one qweb report with barcode .I have tested it on four different system and it works perfectly ,but on client's server it gives following error during report printing


File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 315, in render_element
g_inner.append(self.render_node(current_node, qwebcontext))
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 315, in render_element
g_inner.append(self.render_node(current_node, qwebcontext))
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 315, in render_element
g_inner.append(self.render_node(current_node, qwebcontext))
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 274, in render_node
self, element, attribute_name, attribute_value, qwebcontext)
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 351, in render_att_att
return [(attribute_name[6:], self.eval(attribute_value, qwebcontext))]
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 197, in eval
raise_qweb_exception(message="Could not evaluate expression %r" % expr, expression=expr, template=template)
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 194, in eval
return qwebcontext.safe_eval(expr)
File "/opt/openerp/odoo/openerp/addons/base/ir/ir_qweb.py", line 80, in safe_eval
return eval(expr, None, locals_dict, nocopy=True, locals_builtins=True)
File "/opt/openerp/odoo/openerp/tools/safe_eval.py", line 313, in safe_eval
return eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
File "/home/ols1/extra_addons/product_barcode_qweb/report/product_barcode_print.py", line 62, in _generateBarcode
Code128().getImage(barcode_string, path="./").save(fp, "PNG")
File "/home/ols1/extra_addons/product_barcode_qweb/report/Code128.py", line 234, in getImage
decodeFontFile(courB08_pil ,path+"courB08.pil")
File "/home/ols1/extra_addons/product_barcode_qweb/report/Code128.py", line 276, in decodeFontFile
open (file, "wb").write(decompress(decodestring(data)))
QWebException: "13
Permission denied" while evaluating
"'data:image/png;base64,'+generateBarcode(label_data['default_code'])"

Stuck around this problem from last 3 days!Even a single clue will be great help!

bhavik vyas
on 11/3/15, 12:35 AM
3

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 11/3/15, 2:42 AM

see the fragment from your error log in the question post above:

File "/home/ols1/extra_addons/product_barcode_qweb/report/product_barcode_print.py", line 62, in _generateBarcode
Code128().getImage(barcode_string, path="./").save(fp, "PNG")

here you try to save file to current directory, but you do not have necessary permissions on the current directory. I suggest following changes in product_barcode_print.py:

import os

from openerp.tools import config

my_data_directory = os.path.join(config['data_dir'], "custom_filestore", "your_module_name")

if not os.path.exists(my_data_directory):
    os.makedirs(my_data_directory)

then, in the code at line 62: Code128().getImage(barcode_string, path="./").save(fp, "PNG") -Use my_data_directory instead of "./" -local directory:

Code128().getImage(barcode_string, path=my_data_directory ).save(fp, "PNG")

also adapt the rest of code to accordingly use my_data_directory instead of local directory to read from and write to file(s) you create in your module. that's it, after this change you save files to directory where you have all necessary permissions. 


NOTE:

Above changes should be enough in your case, but, in the best case you should append database name to data_directory path, so you'll have separated directory for each database in a multidatabase environment. in v8 it may be implemented as:

@api.model
def get_custom_data_dir(self):
return os.path.join(config['data_dir'], "custom_filestore", "module_name", self.env.cr.dbname)

optionally you can use this approach, if it's necessary.

Thank you very much Temur! you understood my issues perfectly! i followed your instructions and issue solved!

bhavik vyas
on 11/4/15, 7:18 AM

You're welcome!

Temur
on 11/4/15, 8:11 AM
0
jhony
On 11/3/15, 2:07 AM

This is pretty simple @bhavik you don't have required permission on file.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/3/15, 12:33 AM
Seen: 1122 times
Last updated: 11/3/15, 7:09 AM