ผลต่างระหว่างรุ่นของ "Tutorial Odoo 9.0 Part 14 : Reporting"
จาก Morange Wiki
Sirawich (คุย | มีส่วนร่วม) (หน้าที่ถูกสร้างด้วย '<h2>Reporting</h2> *<h3>Printed reports</h3> แก้ไขไฟล์ดังนี้ <br/><br/> openacademy/__openerp__.py <pre> ...') |
Sirawich (คุย | มีส่วนร่วม) |
||
แถว 56: | แถว 56: | ||
[[ไฟล์:Odoo14-2.png]] | [[ไฟล์:Odoo14-2.png]] | ||
<br/><br/> | <br/><br/> | ||
− | *<h3> | + | *<h3>Dashboards</h3> |
แก้ไขไฟล์ดังนี้ | แก้ไขไฟล์ดังนี้ | ||
<br/><br/> | <br/><br/> | ||
openacademy/__openerp__.py | openacademy/__openerp__.py | ||
+ | <br/> | ||
+ | ส่วนที่ 1 | ||
+ | <pre> | ||
+ | 'version': '0.1', | ||
+ | |||
+ | # any module necessary for this one to work correctly | ||
+ | 'depends': ['base', 'board'], | ||
+ | |||
+ | # always loaded | ||
+ | 'data': [ | ||
+ | </pre> | ||
+ | <br/> | ||
+ | ส่วนที่ 2 | ||
<pre> | <pre> | ||
− | |||
− | |||
'views/openacademy.xml', | 'views/openacademy.xml', | ||
'views/partner.xml', | 'views/partner.xml', | ||
+ | 'views/session_workflow.xml', | ||
+ | 'views/session_board.xml', | ||
+ | 'reports.xml', | ||
], | ], | ||
# only loaded in demonstration mode | # only loaded in demonstration mode | ||
− | |||
</pre> | </pre> | ||
− | |||
<br/> | <br/> | ||
− | openacademy/views/ | + | openacademy/views/session_board.xml |
<pre> | <pre> | ||
− | <?xml version="1.0 | + | <?xml version="1.0"?> |
− | + | <openerp> | |
<data> | <data> | ||
− | + | <record model="ir.actions.act_window" id="act_session_graph"> | |
− | <record model="ir. | + | <field name="name">Attendees by course</field> |
− | <field name="name"> | + | <field name="res_model">openacademy.session</field> |
− | <field name=" | + | <field name="view_type">form</field> |
− | <field name=" | + | <field name="view_mode">graph</field> |
− | <field name=" | + | <field name="view_id" |
− | + | ref="openacademy.openacademy_session_graph_view"/> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</record> | </record> | ||
− | + | <record model="ir.actions.act_window" id="act_session_calendar"> | |
− | <record model="ir.actions.act_window" id=" | + | <field name="name">Sessions</field> |
− | <field name="name"> | + | <field name="res_model">openacademy.session</field> |
− | <field name="res_model"> | + | <field name="view_type">form</field> |
− | <field name="view_mode"> | + | <field name="view_mode">calendar</field> |
+ | <field name="view_id" ref="openacademy.session_calendar_view"/> | ||
</record> | </record> | ||
− | < | + | <record model="ir.actions.act_window" id="act_course_list"> |
− | + | <field name="name">Courses</field> | |
− | + | <field name="res_model">openacademy.course</field> | |
− | + | <field name="view_type">form</field> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | < | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | < | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | <field name=" | ||
− | <field name=" | ||
<field name="view_mode">tree,form</field> | <field name="view_mode">tree,form</field> | ||
</record> | </record> | ||
− | < | + | <record model="ir.ui.view" id="board_session_form"> |
− | + | <field name="name">Session Dashboard Form</field> | |
− | + | <field name="model">board.board</field> | |
− | + | <field name="type">form</field> | |
− | + | <field name="arch" type="xml"> | |
− | + | <form string="Session Dashboard"> | |
+ | <board style="2-1"> | ||
+ | <column> | ||
+ | <action | ||
+ | string="Attendees by course" | ||
+ | name="%(act_session_graph)d" | ||
+ | height="150" | ||
+ | width="510"/> | ||
+ | <action | ||
+ | string="Sessions" | ||
+ | name="%(act_session_calendar)d"/> | ||
+ | </column> | ||
+ | <column> | ||
+ | <action | ||
+ | string="Courses" | ||
+ | name="%(act_course_list)d"/> | ||
+ | </column> | ||
+ | </board> | ||
+ | </form> | ||
+ | </field> | ||
</record> | </record> | ||
− | <record model=" | + | <record model="ir.actions.act_window" id="open_board_session"> |
− | + | <field name="name">Session Dashboard</field> | |
+ | <field name="res_model">board.board</field> | ||
+ | <field name="view_type">form</field> | ||
+ | <field name="view_mode">form</field> | ||
+ | <field name="usage">menu</field> | ||
+ | <field name="view_id" ref="board_session_form"/> | ||
</record> | </record> | ||
+ | |||
+ | <menuitem | ||
+ | name="Session Dashboard" parent="base.menu_reporting_dashboard" | ||
+ | action="open_board_session" | ||
+ | sequence="1" | ||
+ | id="menu_board_session" icon="terp-graph"/> | ||
</data> | </data> | ||
</openerp> | </openerp> | ||
</pre> | </pre> | ||
− | |||
<br/> | <br/> | ||
− | + | จากโค้ดข้างต้นเป็นการเพิ่ม dashboard ของ openacademy ซึ่งแสดงภาพรวมต่างๆ ดังภาพ | |
<br/> | <br/> | ||
− | [[ไฟล์: | + | [[ไฟล์:Odoo14-3.png]] |
<br/><br/> | <br/><br/> | ||
− | หัวข้อถัดไป [[Tutorial Odoo 9.0 Part | + | หัวข้อถัดไป [[Tutorial Odoo 9.0 Part 15 : WebServices]] |
รุ่นแก้ไขเมื่อ 11:11, 19 กรกฎาคม 2559
Reporting
Printed reports
แก้ไขไฟล์ดังนี้
openacademy/__openerp__.py
'views/openacademy.xml', 'views/partner.xml', 'views/session_workflow.xml', 'reports.xml', ], # only loaded in demonstration mode 'demo': [
openacademy/reports.xml
<openerp> <data> <report id="report_session" model="openacademy.session" string="Session Report" name="openacademy.report_session_view" file="openacademy.report_session" report_type="qweb-pdf" /> <template id="report_session_view"> <t t-call="report.html_container"> <t t-foreach="docs" t-as="doc"> <t t-call="report.external_layout"> <div class="page"> <h2 t-field="doc.name"/> <p>From <span t-field="doc.start_date"/> to <span t-field="doc.end_date"/></p> <h3>Attendees:</h3> <ul> <t t-foreach="doc.attendee_ids" t-as="attendee"> <li><span t-field="attendee.name"/></li> </t> </ul> </div> </t> </t> </t> </template> </data> </openerp>
จากการแก้ไขโค้ดข้างต้น จะมีตัวเลือก print ปรากฏ และสามารถออกรายงานเป็นไฟล์ pdf ดังภาพ
ตัวอย่างไฟล์ pdf
Dashboards
แก้ไขไฟล์ดังนี้
openacademy/__openerp__.py
ส่วนที่ 1
'version': '0.1', # any module necessary for this one to work correctly 'depends': ['base', 'board'], # always loaded 'data': [
ส่วนที่ 2
'views/openacademy.xml', 'views/partner.xml', 'views/session_workflow.xml', 'views/session_board.xml', 'reports.xml', ], # only loaded in demonstration mode
openacademy/views/session_board.xml
<?xml version="1.0"?> <openerp> <data> <record model="ir.actions.act_window" id="act_session_graph"> <field name="name">Attendees by course</field> <field name="res_model">openacademy.session</field> <field name="view_type">form</field> <field name="view_mode">graph</field> <field name="view_id" ref="openacademy.openacademy_session_graph_view"/> </record> <record model="ir.actions.act_window" id="act_session_calendar"> <field name="name">Sessions</field> <field name="res_model">openacademy.session</field> <field name="view_type">form</field> <field name="view_mode">calendar</field> <field name="view_id" ref="openacademy.session_calendar_view"/> </record> <record model="ir.actions.act_window" id="act_course_list"> <field name="name">Courses</field> <field name="res_model">openacademy.course</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> </record> <record model="ir.ui.view" id="board_session_form"> <field name="name">Session Dashboard Form</field> <field name="model">board.board</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Session Dashboard"> <board style="2-1"> <column> <action string="Attendees by course" name="%(act_session_graph)d" height="150" width="510"/> <action string="Sessions" name="%(act_session_calendar)d"/> </column> <column> <action string="Courses" name="%(act_course_list)d"/> </column> </board> </form> </field> </record> <record model="ir.actions.act_window" id="open_board_session"> <field name="name">Session Dashboard</field> <field name="res_model">board.board</field> <field name="view_type">form</field> <field name="view_mode">form</field> <field name="usage">menu</field> <field name="view_id" ref="board_session_form"/> </record> <menuitem name="Session Dashboard" parent="base.menu_reporting_dashboard" action="open_board_session" sequence="1" id="menu_board_session" icon="terp-graph"/> </data> </openerp>
จากโค้ดข้างต้นเป็นการเพิ่ม dashboard ของ openacademy ซึ่งแสดงภาพรวมต่างๆ ดังภาพ
หัวข้อถัดไป Tutorial Odoo 9.0 Part 15 : WebServices