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

In odooV8, I don't understand the "file" field in the xml <report declaration (where report is the shortcut for ir.action.report).

For instance, with: 

[code]<report

      id="contract_fibra_30 "

      string="Contract fibra 30 Mb/s"

      name="contract_fibra_print.contract_f_30"

      model="res.partner"

      report_type="qweb-pdf"

      file="contract_fib_30" 

        />[/code]

id  is the unique name of the action.report declaration

string is the human readable name of the action.report declaration 

name is the template name is used for the report

model is the model used to get the data

report_type is the pdf or html type

file ???

Is not the name of the downloaded file.

Andrea

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Thanks Axel,

if I set 

attachment="contract_fibra_30Mb.pdf"            

I have got this error 

            ValueError: "name 'contract_fibra_30Mb' is not defined" while evaluating

            u'contract_fibra_30Mb.pdf'


I think because I have to declare the name as a string, like this: 

attachment=" 'contract_fibra_30Mb.pdf' "     or

attachment=" 'contract_fibra_30Mb' + '.pdf' "     

      

Anyway, even in the second type of declaration, the output pdf still doesn't take the right name,ç

but still has this name: "contract_fibra_print.contract_f_30.pdf" 

الصورة الرمزية
إهمال
أفضل إجابة

Hi Andrea Alessandrini

The file attribute of the report definition tag it used to save it's value for the field report_rml of the model ir.actions.report.xml that have the following definition were you could read it's help

'report_rml': fields.char('Main Report File Path/controller', help="The path to the main report file/controller (depending on Report Type) or NULL if the content is in another data field"),

so it's not intended to be used with qweb reports since it will not be used at all.

To specify the report filename to be generated you need to use the attachment attribute that it will end in the attachment field of the same model that have the following definition:

'attachment': fields.char('Save as Attachment Prefix', help='This is the filename of the attachment used to store the printing result. Keep empty to not save the printed reports. You can use a python expression with the object and time variables.'),

Hope this helps

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أغسطس 16
7635
1
أكتوبر 15
3472
3
سبتمبر 15
3694
3
فبراير 24
12615
5
يناير 20
8202