Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
7808 Lượt xem

```

@api.multi 

 def button_export_pdf(self): 

 self.ensure_one()

 return self._export()


def _prepare_activity_statement(self): 

 self.ensure_one() 

 return 

{ 'date_start': self.date_start, 

 'date_end': self.date_end,

 'company_id': self.company_id.id,

 'partner_ids': self._context['active_ids'], 

 'show_aging_buckets': self.show_aging_buckets,

 'filter_non_due_partners': self.filter_partners_non_due,

 'account_type': self.account_type, }


def _export(self): 

 data = self._prepare_activity_statement()

 return self.env.ref( 'customer_activity_statement' '.action_print_customer_activity_statement').report_action( self, data=data)

```

Error is 

File "/home/usman/Documents/odoo12/odoo/odoo/addons/base/models/ir_actions_report.py", line 738, in _get_rendering_context
    data.update(report_model._get_report_values(docids, data=data))
AttributeError: 'report.customer_activity_statement.statement' object has no attribute '_get_report_values'

Ảnh đại diện
Huỷ bỏ

are you looking for how to create a new PDF report ?

I'm working with a ticketing system and I need to print/ extract PDF to be able to have the entire case in pdf format... Whats the way to achieve this? Right now by using Crtl+p if the tickets has to many logs it gets pretty ugly. Any recommendations are very welcome. Thanks

Câu trả lời hay nhất

Hello Usman,

You can call any Qweb report by the following way, you can also pass parameters using context for validation or calculation for qweb side:

# Get report
report = self.env.ref('module_name.report_name')

# Set Context
ctx = self.env.context.copy()
ctx['flag'] = True

# Call report with context
pdf = report.with_context(ctx).render_qweb_pdf(ids)

# Get report file
file = base64.b64encode(pdf[0])

You can put this file to any binary field or store anywhere. Also if you want report as HTML then use render_qweb_html() and store to html field.

Hope it will helpful for you.


Thanks and regards

Haresh Kansara

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 12 23
19863
6
thg 3 16
25933
1
thg 3 15
8492
2
thg 1 20
15693
0
thg 1 17
11252