Odoo 도움말


2 응답

Serpent Consulting Services Pvt. Ltd. India

--Serpent Consulting Services Pvt. Ltd.--
Serpent Consulting Services Pvt. Ltd.
| 7 6 10
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. is an Official Odoo Partner, working on Odoo ever since 2007, experience of 11+ years and witnessed the growth of Odoo.

We are a team of 80+ experts on various verticals. Our portfolio of products can be seen at http://www.serpentcs.com and http://www.serpentcs.in

Our Expertise and Services:

  • Odoo Support

  • Odoo Development

  • Odoo Training

  • Odoo Migration

  • Odoo Implementation

  • Odoo Consulting

Our 290+ Apps on Appstore : https://apps.odoo.com/apps/modules/browse?author=Serpent Consulting Services Pvt. Ltd.


Serpent Consulting Services Pvt. Ltd. India
13. 11. 14. 오전 1:59

Hello Julian Solorzano,

You may make take reference of following code.

The following code generates the report and creates the attachment.

def cover_print(self, cr, uid, ids, context=None):
    attachment_obj = self.pool.get('ir.attachment')
    for record in self.browse(cr, uid, ids, context=context):
        ir_actions_report = self.pool.get('ir.actions.report.xml')
        matching_reports = ir_actions_report.search(cr, uid, [('name','=','report_service_name_given_in_xml')])
        if matching_reports:
            report = ir_actions_report.browse(cr, uid, matching_reports[0])
            report_service = 'report.' + report.report_name
            service = netsvc.LocalService(report_service)
            (result, format) = service.create(cr, uid, [record.id], {'model': self._name}, context=context)
            eval_context = {'time': time, 'object': record}
            if not report.attachment or not eval(report.attachment, eval_context):
                # no auto-saving of report as attachment, need to do it manually
                result = base64.b64encode(result)
                file_name = re.sub(r'[^a-zA-Z0-9_-]', '_', 'Your Report Name')
                file_name += ".pdf"
                attachment_id = attachment_obj.create(cr, uid,
                        'name': file_name,
                        'datas': result,
                        'datas_fname': file_name,
                        'res_model': self._name,
                        'res_id': record.id,
                        'type': 'binary'
                    }, context=context)
    return True

Hope this will help you.


Serpent Consulting Services.

4 의견
Zenpar S.A. de C.V., Julian Solorzano Mexico
13. 11. 14. 오전 2:13

Perfect, thanks

Sayed Anisul Hoque 방글라데시
15. 9. 18. 오후 4:04

matching_reports = ir_actions_report.search(cr, uid, [('name','=','report_service_name_given_in_xml')]) --> this returning as "matching_reports::: []" can you please tell why empty list is created ?? moreover can you please tell what is report_service_name_given_in_xml ?

Sayed Anisul Hoque 방글라데시
15. 10. 15. 오전 7:25

report_service = 'report.' + report.report_name service = netsvc.LocalService(report_service) (result, format) = service.create(cr, uid, [record.id], {'model': self._name}, context=context) Above line was giving me error since the openerp.netsvc.LocalService() function is deprecated. This could be solved as per below editing result, format = openerp.report.render_report(cr, uid, [record.id], report.report_name, {'model': self._name}, context=context)

Sebin Siby India
18. 1. 10. 오전 3:36

From where I have to call this function?

I have a wizard for the report to be generated.


Navrang Oza India

--Navrang Oza--
Navrang Oza
| 3 2 8
Gandhinagar, India
--Navrang Oza--

Having 13+ years of experience in Odoo, Magento, Wordpress, Android, PHP Expert.

Skype : acespritech

Email : info@acespritech.com

Navrang Oza India
13. 11. 14. 오전 2:01


I think Invoices report is the best example of attaching a generated report in OpenERP interface.
You can get it from here.

    attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"

To save report as attachment attachment and attachment_use are compulsory or you can manually add your generated report to attachment by following steps :

  1. Generate report and save in your file system.
  2. Then go to the form view of the record and click on Attachment(s) on top and add there. Below is the screenshot.
  3. You can see all your attachments which are saved in OpenERP in Knowledge -> Documents -> Documents.

image description

Keep Informed
1 팔로워
About This Community

This platform 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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now