** 在字段 'Object' 中找不到外部 id 'model_oemedical_lab_group' 的匹配记录**
- 我是openerp的初学者。我试图在一些简单的模块中进行自己的自定义。一旦我下载了名为的模式
- 医疗
- 我无法安装 oemedical_lab。当我尝试安装它时,该模块显示一些错误。请帮帮我。我被这个卡住了。
- 感谢您
omedical_lab.py
enter code here
import time
from openerp.osv import fields, orm
class oemedical_patient (orm.Model):
_name = "oemedical.patient"
_inherit = "oemedical.patient"
_columns = {
'lab_test_ids': fields.one2many(
'oemedical.patient.lab.test', 'patient_id', 'Lab Tests Required'),
}
class test_type (orm.Model):
_name = "oemedical.test_type"
_description = "Type of Lab test"
_columns = {
'name': fields.char(
'Test', size=128,
help="Test type, eg X-Ray, hemogram,biopsy..."),
'code': fields.char(
'Code', size=128,
help="Short name - code for the test"),
'info': fields.text(
'Description'),
'product_id': fields.many2one(
'product.product', 'Service', required=True),
'critearea': fields.one2many(
'oemedical_test.critearea', 'test_type_id', 'Test Cases'),
}
_sql_constraints = [
('code_uniq', 'unique (name)', 'The Lab Test code must be unique')]
class lab (orm.Model):
_name = "oemedical.lab"
_description = "Lab Test"
_columns = {
'name': fields.char(
'ID', size=128, help="Lab result ID"),
'test': fields.many2one(
'oemedical.test_type', 'Test type', help="Lab test type"),
'patient': fields.many2one(
'oemedical.patient',
'Patient',
help="Patient ID"),
'pathologist': fields.many2one(
'oemedical.physician',
'Pathologist',
help="Pathologist"),
'requestor': fields.many2one(
'oemedical.physician',
'Physician',
help="Doctor who requested the test"),
'results': fields.text(
'Results'),
'diagnosis': fields.text(
'Diagnosis'),
'critearea': fields.one2many(
'oemedical_test.critearea', 'oemedical_lab_id', 'Test Cases'),
'date_requested': fields.datetime(
'Date requested'),
'date_analysis': fields.datetime(
'Date of the Analysis'),
}
_defaults = {
'date_requested': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'date_analysis': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'name': lambda self, cr, uid, context: self.pool['ir.sequence'].get(
cr, uid, 'oemedical.lab'),
}
_sql_constraints = [
('id_uniq', 'unique (name)', 'The test ID code must be unique')]
class oemedical_lab_test_units(orm.Model):
_name = "oemedical.lab.test.units"
_columns = {
'name': fields.char('Unit', size=25),
'code': fields.char('Code', size=25),
}
_sql_constraints = [
('name_uniq', 'unique(name)', 'The Unit name must be unique')]
class oemedical_test_critearea(orm.Model):
_name = "oemedical_test.critearea"
_description = "Lab Test Critearea"
_columns = {
'name': fields.char('Test', size=64),
'result': fields.text('Result'),
'normal_range': fields.text('Normal Range'),
'units': fields.many2one('oemedical.lab.test.units', 'Units'),
'test_type_id': fields.many2one('oemedical.test_type', 'Test type'),
'oemedical_lab_id': fields.many2one('oemedical.lab', 'Test Cases'),
'sequence': fields.integer('Sequence'),
}
_defaults = {
'sequence': lambda *a: 1,
}
_order = "sequence"
class oemedical_patient_lab_test(orm.Model):
_name = 'oemedical.patient.lab.test'
def _get_default_dr(self, cr, uid, context=None):
partner_id = self.pool.get('res.partner').search(
cr, uid, [('user_id', '=', uid)], context=context)
if partner_id:
dr_id = self.pool.get('oemedical.physician').search(
cr, uid, [('name', '=', partner_id[0])], context=context)
if dr_id:
return dr_id[0]
# else:
# raise osv.except_osv(_('Error !'),
# _('There is no physician defined ' \
# 'for current user.'))
else:
return False
_columns = {
'name': fields.many2one(
'oemedical.test_type', 'Test Type'),
'date': fields.datetime(
'Date'),
'state': fields.selection(
[('draft', 'Draft'),
('tested', 'Tested'),
('cancel', 'Cancel')],
'State', readonly=True),
'patient_id': fields.many2one(
'oemedical.patient', 'Patient'),
'doctor_id': fields.many2one(
'oemedical.physician',
'Doctor',
help="Doctor who Request the lab test."),
# 'invoice_status' : fields.selection(
# [('invoiced','Invoiced'),
# ('tobe','To be Invoiced'),
# ('no','No Invoice')],'Invoice Status'),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'state': lambda *a: 'draft',
'doctor_id': _get_default_dr,
# 'invoice_status': lambda *a: 'tobe',
}
omedical_view.xml
<?xml version="1.0" ?>
<openerp>
<data>
<!-- Lab test units -->
<record model="ir.ui.view" id="oemedical_lab_unit_form">
<field name="name">Test Units</field>
<field name="model">oemedical.lab.test.units</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Test Unit">
<field name="name" required="1"/>
<field name="code"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="oemedical_lab_unit_tree">
<field name="name">Test Units</field>
<field name="model">oemedical.lab.test.units</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Test Unit">
<field name="name"/>
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="oemedical_action_lab_unit">
<field name="name">Lab Testing Units</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">oemedical.lab.test.units</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
实验室测试请求 oemedical.patient.lab.test 表格 实验室测试请求 oemedical.patient.lab.test 树
<record model="ir.actions.act_window" id="oemedical_action_lab_test_request">
<field name="name">Lab Requests</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">oemedical.patient.lab.test</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="oemedical_action_lab_test_request" id="oemedical_labtest_request" parent="oemedical_laboratory_menu"/>
<record model="ir.actions.act_window" id="oemedical_action_draft_lab_test_request">
<field name="name">Draft Requests</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">oemedical.patient.lab.test</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft')]</field>
</record>
<menuitem action="oemedical_action_draft_lab_test_request" id="oemedical_draft_labtest_request" parent="oemedical_labtest_request"/>
<record model="ir.actions.act_window" id="oemedical_action_today_draft_lab_test_request">
<field name="name">Today's Draft Requests</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">oemedical.patient.lab.test</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft'),('date','>=',time.strftime('%Y-%m-%d 00:00:01')),('date','<=',time.strftime('%Y-%m-%d 23:59:59'))]</field>
</record>
<menuitem action="oemedical_action_today_draft_lab_test_request" id="oemedical_today_draft_labtest_request" parent="oemedical_labtest_request"/>
<record id="view_oemedical_lab_test_filter" model="ir.ui.view">
<field name="name">Lab Tests Requests</field>
<field name="model">oemedical.patient.lab.test</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Lab Tests Requests">
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="date" select="1"/>
<field name="patient_id" select="1"/>
<field name="doctor_id" select="1"/>
<field name="state" select="1"/>
<newline/>
</search>
</field>
</record>
<record model="ir.ui.view" id="oemedical_patient_view_lab_test">
<field name="name">Patient Lab Test</field>
<field name="model">oemedical.patient</field>
<field name="type">form</field>
<field name="inherit_id" ref="oemedical.view_oemedical_patient_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Lab Tests">
<field name="lab_test_ids" colspan="4" nolabel="1">
<tree string="Lab Tests">
<field name="name" required="1"/>
<field name="doctor_id"/>
<field name="date"/>
<field name="state"/>
</tree>
<form string="Lab Tests">
<field name="name"/>
<field name="doctor_id"/>
<field name="date"/>
<field name="state"/>
</form>
</field>
</page>
</notebook>
</field>
</record>
<record model="ir.ui.view" id="oemedical_test_view">
<field name="name">Lab test</field>
<field name="model">oemedical.test_type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Lab Test">
<notebook>
<page string="Main Info">
<field name="name" required="1"></field>
<field name="code"></field>
<field name="critearea" colspan="4" nolabel="1">
<tree string="Test Cases">
<field name="sequence"/>
<field name="name"/>
<field name="normal_range"/>
<field name="units"/>
</tree>
<form string="Test Cases">
<field name="name"/>
<field name="units"/>
<field name="sequence"/>
<newline/>
<field name="normal_range"/>
</form>
</field>
<field name="product_id"/>
</page>
<page string="Extra Info">
<field name="info"></field>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="oemedical_test_tree">
<field name="name">Lab test types list</field>
<field name="model">oemedical.test_type</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string='Lab test type'>
<field name="name"></field>
<field name="code"></field>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="oemedical_action_form_test">
<field name="name">New Type of Lab test</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">oemedical.test_type</field>
<field name="view_type">form</field>
<field name="view_id" ref="oemedical_test_view"/>
</record>
<record id="view_oemedical_lab_test_type_search" model="ir.ui.view">
<field name="name">oemedical.test_type.select</field>
<field name="model">oemedical.test_type</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Lab Test Types">
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="code" select="1"/>
<newline/>
</search>
</field>
</record>
<menuitem action="oemedical_action_form_test" id="oemedical_conf_test" parent="oemedical_conf_laboratory" />
<record model="ir.ui.view" id="oemedical_lab_view">
<field name="name">Lab Test</field>
<field name="model">oemedical.lab</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Laboratory Test">
<notebook>
<page string="Main Info">
<field name="name" required="1"></field>
<field name="test" required="1"></field>
<field name="date_analysis"></field>
<newline/>
<field name="patient" required="1"></field>
<field name="pathologist"></field>
<newline/>
<field name="date_requested"></field>
<field name="requestor" required="1"></field>
<field name="critearea" colspan="4" nolabel="1">
<tree editable="top" string="Test Cases">
<field name="sequence"/>
<field name="name"/>
<field name="result"/>
<field name="normal_range"/>
<field name="units"/>
</tree>
<form string="Test Cases">
<field name="name"/>
<field name="result"/>
<field name="units"/>
<field name="normal_range"/>
</form>
</field>
</page>
<page string="Extra Info">
<field name="results"></field>
<newline/>
<field name="diagnosis"></field>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="oemedical_lab_tree">
<field name="name">Lab test type</field>
<field name="model">oemedical.lab</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string='Lab test type'>
<field name="name"></field>
<field name="test"></field>
<field name="patient"></field>
<field name="date_analysis"></field>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="oemedical_action_tree_lab">
<field name="name">Lab Tests Results</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">oemedical.lab</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="oemedical_lab_tree"/>
</record>
<menuitem action="oemedical_action_tree_lab" id="oemedical_action_lab_tree" parent="oemedical_laboratory_menu" sequence="2"/>
<act_window domain="[('patient', '=', active_id)]" id="act_patient_lab_history" name="Lab Reports" res_model="oemedical.lab" src_model="oemedical.patient"/>
<record id="view_oemedical_lab_test_results_filter" model="ir.ui.view">
<field name="name">Lab Tests Results</field>
<field name="model">oemedical.lab</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Lab Tests Results">
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="test" select="1"/>
<field name="patient" select="1"/>
<field name="date_analysis" select="1"/>
<newline/>
</search>
</field>
</record>
</data>