添加了一个三级菜单,由此创建向导,可选择按照性别分类进行打印,打印符合条件的PDF报表
打印出的PDF表如图所示:
代码部分:先写向导部分,创建一个新的向导 patient_report:【向导文件放在wizard里】
py文件代码:【all_patient_report.py】
from odoo import fields, models, api, _
class PatientReportWizard(models.TransientModel):
_name = "patient.report.wizard"
_description = "这是一个瞬态模型patient_report_wizard"
gender = fields.Selection([('male', '男的'), ('female', '女的'), ('other', '其它')],
required=True, default='other')
age = fields.Integer(string="Age")
def action_print_report(self):
data = {
'form_data': self.read()[0],
'email': '6370@163.com',
}
return self.env.ref('mysale.action_report_all_patient_details').report_action(self, data=data)
xml文件代码:【all_patient_report_view.xml】
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="action_report_patient" model="ir.actions.act_window">
<field name="name">patient_report</field>
<field name="type">ir.actions.act_window</field>
<field name="re