Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
6629 Prikazi

I using Odoo14,

I have a form for student course registration,which is the form is accesible from public (no login require).


When a user register on the form, I want to have an option, there are a button to print a pdf report from their filled data by themself.


So, how to create pdf report from website frontend?


please , any help, source or tutorial how to do that will be very thanks,


Thanks,

Tri Nanda

Avatar
Opusti
Avtor Best Answer

I solved this by using this code:

my controller code

@http.route('/create/course-registration', type="http", auth="public", website=True)
def create_course_registration(self, **kw):
my_other_code...
my_other_ocde...
student_course = request.env['aqur.student.course'].sudo().create(
{'student_id': student_id.id, 'course_id': kw['course_id'], 'course_category_id': kw['course_category_id'],
'requisition_schedule_id': requisition_schedule_id})
return request.render('aqur_core.student_registration_thanks', {'student_course': student_course})


and here is my website template view:









(sorry if  I  screenshot the code above,when I paste my code in this forum it always disapear when I submit answer.

But I got the other problem now, the user must do login to access the pdf,

Is there a way to access or download the pdf with public user that don't require to login?

Please, any help, source or tutorial how to do that will be very thanks,

Thanks,

Tri Nanda


Avatar
Opusti
Best Answer

Hi,
 I hope once the form is filled, you will be recording data in the backend model/table, define a report for that model, and from the website you can call/print that report.

For  printing  from  website,  see this  answer :   How to print/Download report from website ?


Thanks

Avatar
Opusti
Avtor

Hi @Niyas, thank you for the answer,
Yes Niyas, when the form is filled and submited, it will record the data in the backend table/module.

Thank you for the reference answer Niyas,
but Niyas Sory, am still confused in where should I do start to write the code, do you have reference how to do that from stratch Niyas?, or step by step on how to do that?

Thanks,
Tri Nanda

Avtor

Hi @Niyas, I can print the report now from my backend, thank you very much for the tutorial Niyas. I also can print report now from a button that call python function using your tutorial here: # https://www.youtube.com/watch?v=Dc8GDj7ygsI&list=PLqRRLx0cl0hoJhjFWkFYowveq2Zn55dhM&index=67

Now I confuse, how to call the function from Odoo website frontend Niyas.
may you refer me a code, source or tutorial how to do that Niyas, please?
Thanks,
Tri Nanda

Avtor

@Hi Niyas, I solved this problem now, thank you for your tutorial reference. But I got other problem now, my user must do a login to access the pdf,

is there a way how access the pdf from public user thah doesn't require to login?

Thanks,
Tri Nanda

Related Posts Odgovori Prikazi Aktivnost
2
feb. 24
4661
1
apr. 23
1503
1
avg. 22
5983
7
jan. 20
9494
2
maj 25
9348