ผลต่างระหว่างรุ่นของ "Openerp/histest"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
(แทนทีข้อความทั้งหมดด้วย '== ปรับแก้โมเดล Patient ให้รองรับการถ่ายภาพผู้ป่ว...')
 
(ไม่แสดง 30 รุ่นระหว่างกลางโดยผู้ใช้ 2 คน)
แถว 1: แถว 1:
 +
== ปรับแก้โมเดล Patient ให้รองรับการถ่ายภาพผู้ป่วย ==
  
== สร้างโมเดล Department และเชื่อมโยงกับ Appointment เพื่อค้นหาและสร้างรายงาน ==
+
ดาวน์โหลดมอดูล Web Camera [[File:web_camera.zip]]
 
 
=== histest.py ===
 
 
 
<syntaxhighlight lang="python">
 
class HISAppointment(osv.Model):
 
    _name = 'histest.appointment'
 
    _columns = {
 
        'date': fields.date(string=u'วันที่',
 
                            required=True),
 
        'patient_id': fields.many2one('histest.patient',
 
                                      'Patient'),
 
        'department_id': fields.many2one('histest.department',
 
                                        'Department'),
 
    }
 
 
 
class HISDepartment(osv.Model):
 
    _name = 'histest.department'
 
    _columns = {
 
        'name': fields.char(size=200,
 
                            string=u'แผนก',
 
                            required=True),
 
        'appointment_ids': fields.one2many('histest.appointment',
 
                                          'department_id',
 
                                          'Appointments'),
 
    }
 
 
 
class HISDepartmentSearch(osv.TransientModel):
 
    _name = 'histest.departmentsearch'
 
 
 
    def appointment_search(self, cr, uid, ids, field_name=None,
 
                          arg=None, context=None):
 
 
 
        appointment_obj = self.pool.get('histest.appointment')
 
 
 
        dsearches = self.browse(cr, uid, ids)
 
        result = {}
 
        for dsearch in dsearches:
 
            result[dsearch.id] = (
 
                appointment_obj.search(cr, uid,
 
                                      [('department_id','=',dsearch.department_id.id),
 
                                        ('date','=',dsearch.search_date)],
 
                                      context=context))
 
        return result
 
 
 
    _columns = {
 
        'department_id': fields.many2one('histest.department',
 
                                        'Department'),
 
        'search_date': fields.date(string=u'วันที่ต้องการหา'),
 
 
 
        'appointment_ids': fields.function(appointment_search,
 
                                          type='one2many',
 
                                          relation='histest.appointment',
 
                                          string='Appointment by date'),
 
    }
 
</syntaxhighlight>
 
 
 
=== histest_view.xml ===
 
 
 
'''ส่วน department form:'''
 
 
 
<syntaxhighlight lang="xml">
 
    <record model="ir.ui.view" id="view_histest_department_form">
 
      <field name="name">histest.department.form</field>
 
      <field name="model">histest.department</field>
 
      <field name="arch" type="xml">
 
        <form string="Patient" version="7.0">
 
          <group>
 
            <field name="name"/>
 
            <field name="appointment_ids"/>
 
          </group>
 
        </form>
 
      </field>
 
    </record>
 
 
 
    <record model="ir.actions.act_window" id="action_histest_department">
 
      <field name="name">Department</field>
 
      <field name="res_model">histest.department</field>
 
      <field name="view_type">form</field>
 
      <field name="view_mode">form,tree</field>
 
    </record>
 
 
 
    <menuitem name="แผนก" id="menu_histest_department"
 
              parent="menu_histest_main" sequence="4"
 
              action="histest.action_histest_department"/>
 
</syntaxhighlight>
 
 
 
'''ส่วน department search form:'''
 
 
 
<syntaxhighlight lang="xml">
 
    <record model="ir.ui.view" id="view_histest_departmentsearch_form">
 
      <field name="name">histest.departmentsearch.form</field>
 
      <field name="model">histest.departmentsearch</field>
 
      <field name="arch" type="xml">
 
        <form string="Patient" version="7.0">
 
          <group>
 
            <field name="department_id"/>
 
            <field name="search_date"/>
 
            <field name="appointment_ids"/>
 
          </group>
 
        </form>
 
      </field>
 
    </record>
 
 
 
    <record model="ir.actions.act_window" id="action_histest_departmentsearch">
 
      <field name="name">Department Appointment Search</field>
 
      <field name="res_model">histest.departmentsearch</field>
 
      <field name="view_type">form</field>
 
      <field name="view_mode">form,tree</field>
 
    </record>
 
 
 
    <menuitem name="แผนก search" id="menu_histest_departmentsearch"
 
              parent="menu_histest_main" sequence="5"
 
              action="histest.action_histest_departmentsearch"/>
 
</syntaxhighlight>
 
 
 
'''appointment tree view:'''
 
 
 
<syntaxhighlight lang="xml">
 
    <record model="ir.ui.view" id="view_histest_appointment_tree">
 
      <field name="name">histest.appointment.tree</field>
 
      <field name="model">histest.appointment</field>
 
      <field name="arch" type="xml">
 
        <tree string="Message">
 
          <field name="patient_id"/>
 
          <field name="date"/>
 
        </tree>
 
      </field>
 
    </record>
 
</syntaxhighlight>
 
 
 
== เอกสารครั้งก่อน ๆ ==
 
* [[Openerp/histest1|โค้ดสำหรับการทดสอบครั้งที่ 1 วันที่ 27 มี.ค. 2557]] - เกี่ยวกับ web module และการเรียก message
 
* [[Openerp/histest2|โค้ดสำหรับการทดสอบครั้งที่ 2 วันที่ 3 เม.ย. 2557]] - การทำ responsive css และ asynchronous request
 
* [[Openerp/histest3|โค้ดสำหรับการทดสอบครั้งที่ 3]] - การทำรายงาน
 

รุ่นแก้ไขปัจจุบันเมื่อ 07:02, 15 พฤษภาคม 2557

ปรับแก้โมเดล Patient ให้รองรับการถ่ายภาพผู้ป่วย

ดาวน์โหลดมอดูล Web Camera ไฟล์:Web camera.zip