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

I have placed a print button in a newly developed module warranty info.The module for reports in the warranty module is added separately in the addons directory.All the other things are working fine.But when I click on the print button in the form,following error appears.The screenshot is attached.Screenshot-2.png.The corresponding file in addons/module/reports.xml have the code

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <report auto="False" id="collection_docket" model="warranty.warranty" name="warranty.warranty.collection_docket" rml="print/report/collection_docket.rml" string="Warranty Details" />
</data>
</openerp>
الصورة الرمزية
إهمال

Can you please show the parser section of your report?

الكاتب

Is this the section you mean?# -- coding: utf-8 -- import time from openerp.report import report_sxw

class warranty(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(warranty, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, }) report_sxw.report_sxw( 'report.warranty', 'warranty', 'addons/print/report/collection_docket.rml', parser=warranty )

الكاتب

I am not sure about the whether the .py code is correct or not.Here warranty is the name of the module for which the report is to be made

I think you have given the name of the report as "report.warranty" in your py file of the report and in xml you have given it as "warranty.warranty.collection_docket". If you are giving the name as "warranty.warranty.collection_docket" in xml file, the name of the report in py file should be "report.warranty.warranty.collection_docket".

الكاتب

Is there any naming convention or specific name to be given here?

There is no naming convention. If you are giving the name of the report as say "example_report_name", the name of the report should be in "report.example_report_name". Prefix should be "report."

الكاتب

I tried as per your instructions but still the same error occurs. report.warranty.warranty.collection_docket

(<type 'exceptions.KeyError'>, KeyError(u'report.warranty.warranty.collection_docket',), <traceback object at 0xb3f46c0c>)

الكاتب

Have doubt regarding coding . report_sxw.report_sxw( 'report.warranty.warranty.collection_docket', 'warranty.warranty', 'addons/print/report/collection_docket.rml', parser=warranty ). Here what do report.warranty.warranty.collection_docket and warranty.warranty represent?

Can you please tell me where the location of the files for this report are like the location of py, xml and rml files.

Please read https://doc.openerp.com/v6.1/developer/05_reports/ . Its a document on how to create rml reports in openerp.

الكاتب

I have added a separate module 'print' in the addons directory and the reports.xml is in that module while collection_docket.rml and .py file are inside a folder named report in the module print.

Please check if you have added py file in __init__.py file.

الكاتب

Yes I have added .py file in __init__.py as import warranty_info

Can you share your module files like py file, xml file, __init__.py files and __openerp__.py file?

الكاتب

I have added a new module print.The folder print contains __init__.py __openerp__.py report folder & reports.xml.

الكاتب

__init.py__

import report

الكاتب

__openerp__.py { 'name': 'Extra Warranty Reports', 'version': '0.01', 'category': 'Reports for WARRANTY', 'description': """ The extra sales reports needed for our project,

  • Reports

    • Collection Docket

    """, 'author': 'OpusVL', 'website': 'http://www.opusvl.com', 'init_xml': [], 'update_xml': [ 'reports.xml', ], 'demo_xml': [], 'test': [], 'installable': True, 'active': False, }

الكاتب

reports.xml <?xml version="1.0" encoding="utf-8"?> <openerp> <data> <report auto="False" id="report_collection_docket" model="warranty.warranty" name="collection_docket" rml="print/report/collection_docket.rml" string="Warranty Details" /> </data> </openerp>

الكاتب

print/report/collection_docket.rml - code for the print layout(not designed yet).

الكاتب

print/report/__init__.py import warranty_info

الكاتب

print/report/warranty_info.py # -- coding: utf-8 -- import time from openerp.report import report_sxw class warranty(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(warranty, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, }) report_sxw.report_sxw( 'report.collection_docket', 'warranty.warranty', 'addons/print/report/collection_docket.rml', parser=warranty )

الكاتب

-- coding: utf-8 --

import time from openerp.report import report_sxwclass warranty(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(warranty, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, }) report_sxw.report_sxw( 'report.collection_docket', 'warranty.warranty', 'addons/print/report/collection_docket.rml', parser=warranty )

vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

I followed exactly the same steps as you mentioned and i was able to generate report. Please try updating your module.

الكاتب

I am still working on it any no improvement at all.Did you restarted the server or anything like that?I tried and tried and tried and still the same error (<type 'exceptions.KeyError'>, KeyError(u'report.collection_docket',), <traceback object at 0xb3b7439c>) is being displayed

yes. I restarted the server, updated the module in db..

الكاتب

ok.How to update the module in db

Go to settings > Modules > Installed Modules. Search for your module here. Open the record you get after searching for module. You can find your module details here. You can also find a button named "Update".

الكاتب

I tried that too.In openerp version that I am using,it is upgrade button.After making changes I saved tose files then updated the modules list,from the installed modules list the module has been searched out and then upgraded that module.Then refreshed and tried to print the report again but still the error remains.

الكاتب

I tried the module and was installed successfully.But the I cant understand the changes that module made in the openerp.Where is the button placed?I didnt see any new button in any of the modules.

الكاتب

I find the button.It is not placed as a separate button but the module installed produced another heading in the print button in the Quotations.When the second string "Warranty Details" is clicked,the old error report.collection_docket

(<type 'exceptions.KeyError'>, KeyError(u'report.collection_docket',), <traceback object at 0xd12ca04>) appers

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مارس 15
10414
0
يوليو 22
3504
2
يوليو 20
7930
1
مايو 22
5233
2
أكتوبر 20
12256