跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

Q

qdfulee

@qdfulee
关于
帖子
12
主题
9
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • MRP II 应该涵盖的16个子功能
    Q qdfulee

    1、销售与运作规划(S&OP);
    2、需求管理;
    3、主生产计划(MPS)及最后总装计划(FAS);
    4、物料需求计划(MRP);
    5、物流清单子系统(BOM);
    6、库存事务处理子系统;
    7、计划接收量子系统;
    8、车间作业排产、派工及控制;
    9、能力需求计划(CRP);
    10、投入/产出工作量控制;
    11、供应商计划及采购作业;
    12、分销资源计划(DRP);
    13、工具计划及管理;
    14、财务计划及管理;
    15、模拟;
    16、业绩评价;


  • 库存明细报表的实现
    Q qdfulee

    后台代码在附件中。说明下,前台显示的二级表头不是我做的,不能上传,见谅。
    目前这个版本的效率不高,希望高手能优化下。

    模块设计思路:

    1、库存明细表是通过 fields_view_get 动态生成的。
    2、不同库位的库存根据系统stock里product.product 中的字段 qty_available,virtual_available 读出。这两个字段的值是依据context里不同库位读出。我是通过这个功能循环产品id和库位id读出的。(这个方法挺笨的)
    3、功能入口通过向导进入。向导生成的菜单如下图:
    [attachimg=2]

    如果安装出错,可能需要把 product.py里 fields_view_get()中下几句代码:
    etree.SubElement(view, 'field', {'name': tools.ustr(location.id)+'-real', 'th_string':location.name, 'colspan':'2'})
    etree.SubElement(view, 'field', {'name': tools.ustr(location.id)+'-virtual','colspan':'1'})
    etree.SubElement(view, 'field', {'name': 'qty_available', 'string': u'实际库存', 'th_string': u'汇总', 'colspan':'2'})
    etree.SubElement(view, 'field', {'name': 'virtual_available', 'string': u'账面库存', 'colspan':'1'})
    中的'th_string' 和'colspan' 标签去掉。


  • OE 之搜索效率问题
    Q qdfulee

    先看一段search的代码

    <br />&lt;record model=&quot;ir.ui.view&quot; id=&quot;dispatch_work_order_filter&quot;&gt;<br />&lt;field name=&quot;name&quot;&gt;dispatch.work_order.filter&lt;/field&gt;<br />&lt;field name=&quot;model&quot;&gt;dispatch.work_order&lt;/field&gt;<br />&lt;field name=&quot;type&quot;&gt;search&lt;/field&gt;<br />&lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&lt;search string=&quot;工单&quot;&gt;<br />&lt;field name=&quot;name&quot;/&gt;<br />&lt;field name=&quot;customer&quot;/&gt;<br />&lt;field name=&quot;mobile&quot;/&gt;<br />&lt;field name=&quot;phone&quot;/&gt;<br />&lt;field name=&quot;address&quot;/&gt;<br />&lt;field name=&quot;service_card&quot;/&gt;<br />&lt;field name=&quot;brand&quot;/&gt;<br />&lt;field name=&quot;series_number&quot;/&gt;<br />&lt;field name=&quot;area&quot;/&gt;<br />&lt;field name=&quot;client_source&quot;/&gt;<br />&lt;field name=&quot;buy_address&quot;/&gt;<br />&lt;field name=&quot;engineer&quot;/&gt;<br />&lt;field name=&quot;department&quot;/&gt;<br />&lt;field name=&quot;note&quot;/&gt;<br />&lt;field name=&quot;check_result&quot;/&gt;<br />&lt;field name=&quot;measure&quot;/&gt;<br />&lt;field name=&quot;description_of_fault&quot;/&gt;<br />&lt;field name=&quot;bill_date&quot; string=&quot;开单日期等于&quot; filter_domain=&quot;[(&#039;bill_date&#039;,&#039;=&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;bill_date&quot; string=&quot;开单日期大于&quot; filter_domain=&quot;[(&#039;bill_date&#039;,&#039;&gt;&#039;,self)]&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;field name=&quot;bill_date&quot; string=&quot;开单日期小于&quot; filter_domain=&quot;[(&#039;bill_date&#039;,&#039;&lt;&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;appointment_date&quot; string=&quot;预约日期等于&quot; filter_domain=&quot;[(&#039;appointment_date&#039;,&#039;=&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;appointment_date&quot; string=&quot;预约日期大于&quot; filter_domain=&quot;[(&#039;appointment_date&#039;,&#039;&gt;&#039;,self)]&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;field name=&quot;appointment_date&quot; string=&quot;预约日期小于&quot; filter_domain=&quot;[(&#039;appointment_date&#039;,&#039;&lt;&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;visit_time&quot; string=&quot;回访日期等于&quot; filter_domain=&quot;[(&#039;appointment_date&#039;,&#039;=&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;visit_time&quot; string=&quot;回访日期大于&quot; filter_domain=&quot;[(&#039;appointment_date&#039;,&#039;&gt;&#039;,self)]&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;field name=&quot;visit_time&quot; string=&quot;回访日期小于&quot; filter_domain=&quot;[(&#039;appointment_date&#039;,&#039;&lt;&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;done_date&quot; string=&quot;完工日期等于&quot; filter_domain=&quot;[(&#039;done_date&#039;,&#039;=&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;done_date&quot; string=&quot;完工日期大于&quot; filter_domain=&quot;[(&#039;done_date&#039;,&#039;&gt;&#039;,self)]&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;field name=&quot;done_date&quot; string=&quot;完工日期小于&quot; filter_domain=&quot;[(&#039;done_date&#039;,&#039;&lt;&#039;,self)]&quot;/&gt;<br />&lt;field name=&quot;bill_month&quot;/&gt;<br />&lt;field name=&quot;create_uid&quot;/&gt;<br />&lt;field name=&quot;done_month&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;draft&#039;)]&quot; string=&quot;待派工&quot; name=&quot;done0&quot;/&gt;<br />&lt;filter icon=&quot;ter-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;dealing&#039;)]&quot; string=&quot;待报工&quot; name=&quot;dealing0&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;done&#039;)]&quot; string=&quot;待交单&quot; name=&quot;reply0&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;reply&#039;)]&quot; string=&quot;待回访&quot; name=&quot;visit0&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state_use_card&#039;,&#039;=&#039;,&#039;0&#039;)]&quot; string=&quot;不扣卡&quot; name=&quot;state_use_card0&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state_use_card&#039;,&#039;=&#039;,&#039;1&#039;)]&quot; string=&quot;需扣卡&quot; name=&quot;state_use_card1&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;draft&#039;)]&quot; string=&quot;草稿&quot; name=&quot;draft&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;dealing&#039;)]&quot; string=&quot;已派工&quot; name=&quot;dealing&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;done&#039;)]&quot; string=&quot;已完工&quot; name=&quot;done&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;reply&#039;)]&quot; string=&quot;已交单&quot; name=&quot;reply&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;state&#039;,&#039;=&#039;,&#039;visit&#039;)]&quot; string=&quot;已回访&quot; name=&quot;visit&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;evaluate&#039;,&#039;=&#039;,&#039;very_satisfied&#039;)]&quot; string=&quot;非常满意&quot; name=&quot;very_satisfied&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;evaluate&#039;,&#039;=&#039;,&#039;satisfied&#039;)]&quot; string=&quot;满意&quot; name=&quot;satisfied&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;evaluate&#039;,&#039;=&#039;,&#039;discontent&#039;)]&quot; string=&quot;不满&quot; name=&quot;discontent&quot;/&gt;<br />&lt;filter icon=&quot;terp-check&quot; domain=&quot;[(&#039;evaluate&#039;,&#039;=&#039;,&#039;visit&#039;)]&quot; string=&quot;非常不满&quot; name=&quot;very_discontent&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;group expand=&quot;0&quot; string=&quot;分组&quot;&gt;<br />&lt;filter string=&quot;按月&quot; icon=&quot;terp-personal&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;bill_month&#039;}&quot;/&gt;<br />&lt;filter string=&quot;客户&quot; icon=&quot;terp-personal&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;customer&#039;}&quot;/&gt;<br />&lt;filter string=&quot;服务卡&quot; icon=&quot;terp-personal&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;service_card&#039;}&quot;/&gt;<br />&lt;filter string=&quot;品牌型号&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;brand&#039;}&quot;/&gt;<br />&lt;filter string=&quot;工程师&quot; icon=&quot;terp-personal&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;engineer&#039;}&quot;/&gt;<br />&lt;filter string=&quot;部门&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;department&#039;}&quot;/&gt;<br />&lt;filter string=&quot;区域&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;area&#039;}&quot;/&gt;<br />&lt;filter string=&quot;客户来源&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;client_source&#039;}&quot;/&gt;<br />&lt;filter string=&quot;购机地点&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;buy_address&#039;}&quot;/&gt;<br />&lt;filter string=&quot;维修类型&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;warranty_type&#039;}&quot;/&gt;<br />&lt;filter string=&quot;维修方式&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;repair_method&#039;}&quot;/&gt;<br />&lt;filter string=&quot;客户评价&quot; icon=&quot;terp-personal+&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;evaluate&#039;}&quot;/&gt;<br />&lt;filter string=&quot;状态&quot; icon=&quot;terp-stock_effects-object-colorize&quot; domain=&quot;&#91;]&quot; context=&quot;{&#039;group_by&#039;:&#039;state&#039;}&quot;/&gt;<br />&lt;/group&gt;<br />&lt;/search&gt;<br />&lt;/field&gt;<br />&lt;/record&gt;<br />
    



    要说明什么问题呢?
    当用户数据量比较多的时候,这样的搜索视图效率就会越来越低。
    原因是OE是根据输入不断的向服务器请求数据。如果用户输入速度慢,同时匹配的数据项由比较多,那么原先出于人体工学考虑的搜索就会出现卡顿现象。

    有两个方法可以解决,一是search不要太复杂,二是用wizard做精准的搜索条件然后一次提交。


  • 库存明细报表的实现
    Q qdfulee

    OE当前的功能里,查询库存要么是所有产品所有库位一张表,要么是一个产品在不同库位的数量分布,无法在一张表上实现多个产品多个库位的明细。
    于是就有了如下的代码:

    # -*- coding: utf-8 -*-<br />from openerp.osv import osv,fields<br />from lxml import etree<br />from openerp import tools<br /><br /><br />class product_product(osv.osv):<br />&nbsp; &nbsp; _inherit = &quot;product.product&quot;<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; res = super(product_product, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)<br />&nbsp; &nbsp; &nbsp; &nbsp; if context.get(&#039;inventory_list&#039;) == True and view_type == &#039;tree&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loc_obj = self.pool.get(&#039;stock.location&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; locations = loc_obj.browse(cr, uid, loc_obj.search(cr, uid, [(&#039;child_ids&#039;, &#039;=&#039;, False), (&#039;usage&#039;, &#039;=&#039;, &#039;internal&#039;)]))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view = etree.fromstring(res&#91;&#039;arch&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields_list = res&#91;&#039;fields&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for location in locations:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields_list[tools.ustr(location.id)+&#039;-real&#039;] = {&#039;type&#039;: &#039;float&#039;, &#039;string&#039;: location.name+&#039;-实际库存&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields_list[tools.ustr(location.id)+&#039;-virtual&#039;] = {&#039;type&#039;: &#039;float&#039;, &#039;string&#039;: location.name+&#039;-账面库存&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(view, &#039;field&#039;, {&#039;name&#039;: tools.ustr(location.id)+&#039;-real&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etree.SubElement(view, &#039;field&#039;, {&#039;name&#039;: tools.ustr(location.id)+&#039;-virtual&#039;})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res&#91;&#039;arch&#039;] = etree.tostring(view)<br />&nbsp; &nbsp; &nbsp; &nbsp; return res<br /><br />&nbsp; &nbsp; def read(self, cr, uid, ids, fields=None, context=None, load=&#039;_classic_read&#039;):<br />&nbsp; &nbsp; &nbsp; &nbsp; result = super(product_product, self).read(cr, uid, ids, fields=fields, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; if context.get(&#039;inventory_list&#039;) == True:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; locations = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for field in fields:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = field.split(&#039;-&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(s) == 2:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if s[1] == &#039;real&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; locations.append(int(s[0]))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for id in ids:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for location in locations:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context&#91;&#039;location&#039;] = location<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val = super(product_product, self).read(cr, uid, id, &#91;&#039;qty_available&#039;, &#039;virtual_available&#039;], context, )<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i][tools.ustr(location)+&#039;-real&#039;] = val&#91;&#039;qty_available&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i][tools.ustr(location)+&#039;-virtual&#039;] = val&#91;&#039;virtual_available&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i += 1<br />&nbsp; &nbsp; &nbsp; &nbsp; return result
    



    实现的效果附件



  • OPENERP CRM应该拓展的报表
    Q qdfulee

    正式阐释CRM拓展前,首先说下客户对信息化系统的潜在需求.所谓潜在需求是指客户大多数时候不会直接提出来,但需要实施公司满足的需求.
    信息系统必须体现管理思想,满足企业三个层面的潜在需求.
    第一个层面 战略层(企业决策层):
    战略项目和企业关键业绩点的多维统计功能.该项功能最好能够达到抽丝剥茧后体现出相关业绩点的关联关系.
    第二个层面 战术层(企业各业务单元负责人):
    1、需要在流程中体现相关业务单元的制约、协作关系,且流程要简洁高效。
    2、业务单元数据分析,需要实时跟踪其关键业绩指标的变化,以满足其及时调整战术的需要。
    第三个层面 战斗层(系统的数据采集点):
    这个层面的工作相对单一、工作量大,所以数据采集要尽量简单、明了、易懂。

    下面切入正题
    OPENERP的CRM在战术层上的功能略显单薄,管理思想没有体现出来。个人认为需要关注如下几个点内容:
    1、营销渠道的绩效。
    2、不同客户类别的绩效。
    3、新增客户的绩效。
    4、老客户的绩效。
    如上几点可以通过几类报表实现
    1、营销渠道下新增客户的分布、成交分布、客户类别分布。
    2、新增客户 、客户成交总额、首次和二次成交 随时间的动态分布报表。
    3、商机各阶段平均时间报表。

    如上报表应该可以和产品及其分类关联


  • OPENERP 构建动态视图
    Q qdfulee

    在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]


  • 解决Document上传中文docx\pptx\xlsx\doc无法获得正确内容索引的问题
    Q qdfulee

    [quote author=佛山-姜 link=topic=11888.msg21802#msg21802 date=1377701845]
    是指中文文件名称吗???
    [/quote]
    是中文文本的doc,docx等文件,在文档模块中内容索引为乱码。


  • 解决Document上传中文docx\pptx\xlsx\doc无法获得正确内容索引的问题
    Q qdfulee

    [quote author=mrshelly link=topic=11888.msg21811#msg21811 date=1377747427]
    了解.... 能给贴子加点 Tag 吗. 这样会更便于检索..
    [/quote]

    加了,不长写帖子,见谅。


  • 解决Document上传中文docx\pptx\xlsx\doc无法获得正确内容索引的问题
    Q qdfulee

    主题如题,不多描述。解决方法:

    1、openerp\addons\document\std_index.py中修改类似“res = toString().encode('ascii','replace')”的代码为“res = toString().encode('utf-8','replace')”
    这个修改解决pptx\docx\xlsx
    2、linux下安装antiword,这个解决doc的问题。   


  • OE开发中错误信息的调用
    Q qdfulee

    直接代码

    &nbsp; &nbsp; def dispatch_work_order_reduce_card_times(self,cr,uid,ids,context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; service_card_id=self.read(cr,uid,ids,[&quot;service_card&quot;],context)[0][&quot;service_card&quot;][0]<br />&nbsp; &nbsp; &nbsp; &nbsp; if service_card_id:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj=self.pool.get(&quot;dispatch.service_card&quot;).read(cr,uid,service_card_id,[&quot;due_date&quot;,&quot;remaining_times&quot;],context)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if obj[&quot;remaining_times&quot;]&lt;1:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise osv.except_osv(_(&#039;Error!&#039;), _(&#039;服务卡剩余次数为:0.&#039;))
    

  • Fields.function中的fnct为什么要返回字典类型
    Q qdfulee

    初学者的浅薄的领悟,高手飘过吧。
    写一个小练习的时候出现的问题,幸亏总监指点。
    fnct之所以返回字典类型,可能考虑form和tree处理不同数量记录的通用性。 这样设计是不是同样因为oe数据处理的基本单位是整张表呢?


  • Openerp 中的 domain
    Q qdfulee

    oe中的domain多用于自定义搜索条件。

    domain中的单个条件是一个三个元素组成的元组。第一个是对象的一个column,也就是字段名;第二个是比较运算符=, !=, &gt;, &gt;=, &lt;, &lt;=, like, ilike, in, not in, child_of, parent_left, parent_right;第三个就是用来比较的值了。多个条件用“|”(or),“&”(and),“!”(no)逻辑运算符链接。逻辑运算符作为前缀放置于条件前面。“|”与“&”必须两个条件链接,“!”对一个条件取反。默认逻辑运算符为“&”。

    举个例子:

    ['|','|',('group_ids','in',[g.id for g in user.groups_id]), ('user_id', '=', user.id), '&', ('user_id', '=', False), ('group_ids','=',False),  '|','|', ('company_id','=',False), ('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]


    这个例子的意思是:

    ['|',

    '|',('group_ids','in',[g.id for g in user.groups_id]), ('user_id',  '=', user.id),

    '&', ('user_id', '=', False),  ('group_ids','=',False),

    '|',

    '|', ('company_id','=',False),  ('company_id','child_of',[user.company_id.id]),

    ('company_id.child_ids','child_of',[user.company_id.id])]

    写个容易看的方式:


    (('group_ids','in',[g.id for g in user.groups_id]) or ('user_id',  '=', user.id)) or (('user_id', '=', False) and ('group_ids','=',False)) or (('company_id','=',False) or ('company_id','child_of',[user.company_id.id])) or ('company_id.child_ids','child_of',[user.company_id.id])

  • 登录

  • 没有帐号? 注册

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组