Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

OPENERP 构建动态视图



  • 在openerp展示界面通常是通过定义class的view(xml文件)来实现的。
    有时这种方法不能支持用户自定义字段的需求,于是就可以通过重写fields_view_get()、 read()来实现。
    实例代码

    <br /><br /># -*- coding: utf-8 -*-<br />from openerp.osv import osv,fields<br />from lxml import etree<br />from openerp import tools<br />from openerp.tools import to_xml<br /><br /><br /><br /><br />class AnalysisQuestionnaireType(osv.osv):<br />&nbsp; &nbsp; _name = &#039;analysis.questionnaire.type&#039;<br />&nbsp; &nbsp; _description = &#039;问卷类型&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;name&#039;: fields.char(&#039;名称&#039;, size=125, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;analysis_set&#039;: fields.many2many(&#039;analysis.title.set&#039;, id1=&#039;analysis_questionnaire_type_id&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  id2=&#039;analysis_title_set_id&#039;, string=&#039;主题&#039;),<br />&nbsp; &nbsp; }<br /><br /><br /><br /><br />class AnalysisTitleSet(osv.osv):<br />&nbsp; &nbsp; _name = &quot;analysis.title.set&quot;<br />&nbsp; &nbsp; _description = &quot;主题&quot;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot;: fields.char(string=&quot;名称&quot;, size=125, required=True,),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;analysis_questionnaire_type&#039;: fields.many2many(&#039;analysis.questionnaire.type&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id1=&#039;analysis_title_set_id&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id2=&#039;analysis_questionnaire_type_id&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string=&#039;问卷类型&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;analysis_title&quot;: fields.one2many(&#039;analysis.title&#039;, &#039;set&#039;, &#039;题目&#039;),<br />&nbsp; &nbsp; }<br /><br /><br /><br /><br />class AnalysisTitle(osv.osv):<br />&nbsp; &nbsp; _name = &quot;analysis.title&quot;<br />&nbsp; &nbsp; _description = &quot;题目&quot;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot;: fields.char(string=&quot;名称&quot;, size=125, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;note&quot;: fields.text(&quot;描述&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;set&quot;: fields.many2one(&quot;analysis.title.set&quot;, string=&quot;主题&quot;, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: fields.selection([(&#039;multiple_choice_only_one_ans&#039;, &#039;单项选择&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;multiple_choice_multiple_ans&#039;, &#039;多项选择&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;matrix_of_choices_only_one_ans&#039;, &#039;单选组合&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;single_textbox&#039;, &#039;单行文本框&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;multiple_textbox&#039;, &#039;多个单行文本框&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;comment&#039;, &#039;多行文本框&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;date&#039;, &#039;日期框&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;date_and_time&#039;, &#039;日期时间框&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;descriptive_text&#039;, &#039;描述性文本&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;attachment&#039;, &#039;附件&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;image&#039;, &#039;图片&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ], &#039;题目类型&#039;,&nbsp; required=1,),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;is_require_answer&#039;: fields.boolean(&#039;必填项&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;option_id&#039;: fields.one2many(&#039;analysis.title.option&#039;, &#039;title_id&#039;, &#039;备选答案&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;column_heading_ids&#039;: fields.one2many(&#039;analysis.title.column.heading&#039;, &#039;title_id&#039;, &#039;标题&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;descriptive_text&#039;: fields.text(&#039;描述文本&#039;),<br />&nbsp; &nbsp; }<br /><br /><br /><br /><br />class AnalysisTitleOption(osv.osv):<br />&nbsp; &nbsp; _name = &#039;analysis.title.option&#039;<br />&nbsp; &nbsp; _description = &#039;答案选项&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;title_id&#039;: fields.many2one(&#039;analysis.title&#039;, &#039;题目&#039;, ondelete=&#039;cascade&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;option&#039;: fields.char(&#039;答案选项&#039;, size=128, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: fields.selection([(&#039;char&#039;, &#039;字符型&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;date&#039;, &#039;日期&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;datetime&#039;, &#039;日期时间型&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;integer&#039;, &#039;整数型&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;float&#039;, &#039;小数型&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;selection&#039;, &#039;选择型&#039;)],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;答案类型&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  required=True),<br /><br /><br />&nbsp; &nbsp; }<br /><br /><br /><br /><br />class AnalysisTitleColumnHeading(osv.osv):<br />&nbsp; &nbsp; _name = &#039;analysis.title.column.heading&#039;<br />&nbsp; &nbsp; _description = &#039;选项标题&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;name&#039;: fields.char(&#039;选项标题&#039;, size=128, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;title_id&#039;: fields.many2one(&#039;analysis.title&#039;, &#039;题目&#039;, ondelete=&#039;cascade&#039;),<br />&nbsp; &nbsp; }<br /><br /><br /><br /><br />class AnalysisAnswer(osv.osv):<br />&nbsp; &nbsp; _name = &#039;analysis.answer&#039;<br />&nbsp; &nbsp; _description = &#039;答案&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;analysis_questionnaire&#039;: fields.many2one(&#039;analysis.questionnaire&#039;, &#039;问卷&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;value&#039;: fields.text(&#039;值&#039;)<br />&nbsp; &nbsp; }<br /><br /><br /><br /><br />class AnalysisQuestionnaire(osv.osv):<br />&nbsp; &nbsp; _name = &#039;analysis.questionnaire&#039;<br />&nbsp; &nbsp; _description = &#039;分析问卷&#039;<br /><br /><br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot;: fields.char(string=&#039;名称&#039;, size=125, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: fields.many2one(&#039;analysis.questionnaire.type&#039;, string=&#039;类型&#039;, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;title&#039;: fields.one2many(&#039;analysis.answer&#039;, &quot;analysis_questionnaire&quot;, &quot;答案&quot;),<br />&nbsp; &nbsp; }<br /><br /><br />&nbsp; &nbsp; def default_get(self, cr, uid, fields_list, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; default = super(AnalysisQuestionnaire, self).default_get(cr, uid, fields_list, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; con = context.get(&#039;type&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; default&#91;&#039;type&#039;] = con<br />&nbsp; &nbsp; &nbsp; &nbsp; return default<br /><br /><br />&nbsp; &nbsp; def view_init(self, cr, uid, fields_list, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; pass<br /><br /><br />&nbsp; &nbsp; def fields_view_get(self, cr, uid, view_id=None, view_type=&#039;form&#039;, context=None, toolbar=False, submenu=False,):<br />&nbsp; &nbsp; &nbsp; &nbsp; if context is None:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; result = super(AnalysisQuestionnaire, self).fields_view_get(cr, uid, view_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view_type=view_type, context=context,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; toolbar=toolbar, submenu=submenu)<br />&nbsp; &nbsp; &nbsp; &nbsp; if view_type == &#039;form&#039; and context.has_key(&#039;type&#039;):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view = etree.fromstring(result&#91;&#039;arch&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields = result&#91;&#039;fields&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print etree.tostring(view)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notebook = etree.SubElement(view, &#039;notebook&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sets = self.pool.get(&#039;analysis.questionnaire.type&#039;).browse(cr, uid, context&#91;&#039;type&#039;]).analysis_set<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q_no = 0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for set in sets:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; page = etree.SubElement(notebook, &#039;page&#039;, string=set.name)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for title in set.analysis_title:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q_no += 1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(page, &#039;newline&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if title.is_require_answer:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(page, &#039;separator&#039;, {&#039;string&#039;: &#039;*&#039;+tools.ustr(q_no)+&#039;.&#039;+tools.ustr(title.name)})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(page, &#039;separator&#039;, {&#039;string&#039;: tools.ustr(q_no)+&#039;.&#039;+tools.ustr(title.name)})<br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if title.type == &#039;multiple_choice_only_one_ans&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for option in title.option_id:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection.append((tools.ustr(option.id), option.option))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;_selection&#039;] = {&#039;type&#039;: &#039;selection&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;selection&#039;: selection,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;name&#039;: title.name}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;_selection&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;multiple_choice_multiple_ans&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;, {&#039;col&#039;: &#039;4&#039;, &#039;colspan&#039;: &#039;4&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for option in title.option_id:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;option&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(option.id)})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;option&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(option.id)] = {&#039;type&#039;: &#039;boolean&#039;, &#039;string&#039;: option.option}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;matrix_of_choices_only_one_ans&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;, {&#039;col&#039;: &#039;2&#039;, &#039;colspan&#039;: &#039;2&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for option in title.option_id:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection.append((tools.ustr(option.id), option.option))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for col in title.column_heading_ids:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;newline&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(col.id),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  })<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(col.id)] = {&#039;type&#039;: &#039;selection&#039;, &#039;selection&#039;: selection}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;single_textbox&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;,)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id) + &quot;_single&quot;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;nolabel&#039;: &quot;1&quot;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;colspan&#039;: &quot;4&quot;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id) + &quot;_single&quot;] = {&#039;type&#039;: &#039;char&#039;, &#039;size&#039;: 255}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;multiple_textbox&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;, {&#039;col&#039;: &#039;4&#039;, &#039;colspan&#039;: &#039;4&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for col in title.column_heading_ids:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;+tools.ustr(col.id)] = {&#039;type&#039;: &#039;char&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;size&#039;: 255}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;width&#039;: &#039;300&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;colspan&#039;: &#039;1&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(col.id)})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;comment&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id) + &quot;_comment&quot;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;nolabel&#039;: &quot;1&quot;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;colspan&#039;: &quot;4&quot;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id) + &quot;_comment&quot;] = {&#039;type&#039;: &#039;text&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;date&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;, {&#039;col&#039;: &#039;4&#039;, &#039;colspan&#039;: &#039;4&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for col in title.column_heading_ids:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;+tools.ustr(col.id)] = {&#039;type&#039;: &#039;date&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(col.id)})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;date_and_time&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;, {&#039;col&#039;: &#039;4&#039;, &#039;colspan&#039;: &#039;4&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for col in title.column_heading_ids:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + &#039;col&#039;+&#039;_&#039;+tools.ustr(col.id)] = {&#039;type&#039;: &#039;datetime&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;-&#039;+&#039;col&#039;+&#039;_&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + tools.ustr(col.id)})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;attachment&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;,)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;_attachment&#039;] = {&#039;type&#039;: &#039;binary&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;_attachment&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;descriptive_text&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if title.descriptive_text:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for que_test in title.descriptive_text.split(&#039;\n&#039;):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;label&#039;, {&#039;string&#039;: to_xml(tools.ustr(que_test)),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;align&#039;: &quot;0.0&quot;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif title.type == &#039;image&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent = etree.SubElement(page, &#039;group&#039;,)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields&#91;&#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;_image&#039;] = {&#039;type&#039;: &#039;binary&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(parent, &#039;field&#039;, {&#039;name&#039;: &#039;title&#039;+&#039;_&#039;+tools.ustr(title.id)+&#039;_image&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;widget&#039;: &#039;image&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result&#91;&#039;arch&#039;] = etree.tostring(view)<br />&nbsp; &nbsp; &nbsp; &nbsp; return result<br /><br /><br />&nbsp; &nbsp; def create(self, cr, uid, vals, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; answer_obj = self.pool.get(&quot;analysis.answer&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; questionnaire_vals = {&#039;name&#039;: vals.get(&#039;name&#039;), &#039;type&#039;: vals.get(&#039;type&#039;)}<br />&nbsp; &nbsp; &nbsp; &nbsp; vals.pop(&#039;name&#039;, &quot;not name&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; vals.pop(&#039;type&#039;, &#039;not type&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; answer_vals = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; questionnaire_id = super(AnalysisQuestionnaire, self).create(cr, uid, questionnaire_vals, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; answer_vals&#91;&#039;analysis_questionnaire&#039;] = questionnaire_id<br />&nbsp; &nbsp; &nbsp; &nbsp; answer_vals&#91;&#039;value&#039;] = vals<br />&nbsp; &nbsp; &nbsp; &nbsp; answer_obj.create(cr, uid, answer_vals, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; return questionnaire_id<br /><br /><br />&nbsp; &nbsp; def read(self, cr, user, ids, fields=None, context=None, load=&#039;_classic_read&#039;):<br />&nbsp; &nbsp; &nbsp; &nbsp; result = super(AnalysisQuestionnaire, self).read(cr, user, ids, fields=fields, context=context, load=load)<br />&nbsp; &nbsp; &nbsp; &nbsp; answer_obj = self.pool.get(&#039;analysis.answer&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; i = 0<br />&nbsp; &nbsp; &nbsp; &nbsp; while i &lt; len(result):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; answer_list = answer_obj.search(cr, user, [(&#039;analysis_questionnaire&#039;, &#039;=&#039;, result&#91;&#039;id&#039;])])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if answer_list:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val = eval(answer_obj.read(cr, user, answer_list, &#91;&#039;value&#039;], context=context)[0]&#91;&#039;value&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.update(val)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i += 1<br />&nbsp; &nbsp; &nbsp; &nbsp; return result<br />
    

    [i]
    [color=rgb(69, 69, 69)][font=tahoma][size=14px]上述代码用户可以自己定义问卷题目及题目类型。通过fields_view_get()画出view,然后把动态构建的字段及其值通过重写create()把数据存储到另外一个表里。这里用的是一个text字段把create返回的值直接存储起来的。当需要查看保存过的数据时,通过重写read()整理成需要的数据格式返回。[/size][/font][/color][/i]



  • good  idea 又学了一招



  • 学习了!



  • qdfulee你好!感谢分享的代码,如若方便,可否将整体的代码贴出来,或打包发给我【lykiao@sina.com】,菜鸟一枚,想在调试的过程中加以学习理解。多谢了~