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

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

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

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

OE 之搜索效率问题



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

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

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



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

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

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



  • 有道理


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待