تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
6939 أدوات العرض

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!

أفضل إجابة

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!

You're welcome!

أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
فبراير 25
1298
0
ديسمبر 24
46
0
ديسمبر 24
1181
1
أكتوبر 24
2461
2
أغسطس 24
1667