跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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 中文社区

阿

阿狸

@阿狸
关于
帖子
27
主题
13
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • Form表单button弹出自定义对话框(button增加type)
    阿 阿狸

    留几个字吧,在view.js里有一个函数是用来判断button的type的,如图3,我在view里增加一个type类别,然后form表单的button填写上类别之后,点击事件就可以调用该type对应的js函数了,剩下的就是海阔天空任鸟飞了


  • Form里自定义显示many2many与one2many的字段
    阿 阿狸

    many2many字段在from里一般会显示出many端的表的tree视图,如果要更改显示的字段需要修改该表的tree视图,比较麻烦,经总监提示,通过
    <field name="many2many 字段">
        <tree ....
        </tree>
    </field>
    便可选择性的显示many端的表的字段
    上代码:

    &lt;field name=&quot;lc_fixed_assets_line&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tree string=&quot;固定资产明细&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;article_id&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;asset_id&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;asset_user&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;user_department&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;state&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button name=&quot;get_assets&quot; icon=&quot;STOCK_REDO&quot; string=&quot;领用&quot; type=&quot;object&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tree&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;
    


    改之前与改之后的效果图如下:


  • 放假无聊用OPENERP做了个股票数据分析平台
    阿 阿狸

    期待楼主的开源 🙂


  • 开阖软件已收购OpenERP中文包并开源
    阿 阿狸

    其实这篇文章对国内的现状充满了无奈感,我只能说大家加油!


  • 【分享】oe字段过滤器
    阿 阿狸

    首先谢谢总监指导 😄


    比如account_id是个many2many字段,所对应的表有两条记录,分别为“张三”,“李四”
    如果在xml这么写的话:
    <field name="account_id" domain="('name', '=', '张三')]" />
    则many2many备选框里只会出现张三,不会出现李四。


  • 【分享】定义oe自带的搜索及默认搜索(即过滤器)
    阿 阿狸

    谢谢上海-开阖正翔的解答,有学问又有耐心
    下面是代码:

    &lt;!--定义视图动作--&gt;<br />&lt;record model=&quot;ir.actions.act_window&quot; id=&quot;action_my_debug_models&quot;&gt;<br />&lt;field name=&quot;name&quot;&gt;调试&lt;/field&gt;<br />&lt;field name=&quot;res_model&quot;&gt;my_debug.models&lt;/field&gt;<br />&lt;field name=&quot;view_type&quot;&gt;form&lt;/field&gt;<br />&lt;field name=&quot;view_mode&quot;&gt;form,tree&lt;/field&gt;<br />&lt;field name=&quot;view_id&quot; ref=&quot;my_debug_models_tree_view&quot;/&gt;<br />&lt;field name=&quot;context&quot;&gt;{&quot;search_default_outpeople&quot;:1}&lt;/field&gt;<br />&lt;field name=&quot;search_view_id&quot; ref=&quot;view_my_debug_models_filter&quot;/&gt;<br />&lt;/record&gt;<br />&lt;!--定义搜索视图--&gt;<br />&lt;record id=&quot;view_my_debug_models_filter&quot; model=&quot;ir.ui.view&quot;&gt;<br />&lt;field name=&quot;name&quot;&gt;my_debug.models.select&lt;/field&gt;<br />&lt;field name=&quot;model&quot;&gt;my_debug.models&lt;/field&gt;<br />&lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&lt;search string=&quot;Search Partner&quot;&gt;<br />&lt;field name=&quot;meeting_temporary_data&quot;/&gt;<br />&lt;filter string=&quot;离职人员&quot; name=&quot;outpeople&quot; domain=&quot;[(&#039;active&#039;,&#039;=&#039;,0)]&quot;/&gt;<br />&lt;separator/&gt;<br />&lt;filter string=&quot;显示所有&quot; name=&quot;display_all&quot; domain=&quot;&#91;&#039;|&#039;,(&#039;active&#039;,&#039;=&#039;,1),(&#039;active&#039;,&#039;=&#039;,0)]&quot;/&gt;<br />&lt;/search&gt;<br />&lt;/field&gt;<br />&lt;/record&gt;
    


    代码不过多解释,都能看明白,需要注意的是定义默认搜索这两句代码比较关键:
    <field name="context">{"search_default_outpeople":1}</field>
    <field name="search_view_id" ref="view_my_debug_models_filter"/>
    效果图如下:


  • 总监分享: 在v8 v9 多维报表导出excel 时, 日期 时间格式 造成 Excel 不能正常处理
    阿 阿狸

    这是总监发的,我只是转到bbs上


  • 总监分享: 在v8 v9 多维报表导出excel 时, 日期 时间格式 造成 Excel 不能正常处理
    阿 阿狸

    【大校】重庆-mrshelly
    分享一个:
    在v8 v9 多维报表导出excel 时, 日期 时间格式 造成 Excel 不能正常处理需要修改 openper\models.py



    日期 时间格式



    注:以上出自总监言论


  • 【分享-oe嵌入qweb】用js读取数据库数据,用类似html语言重写web报表
    阿 阿狸

    [quote author=神仙采葡萄 link=topic=16554.msg28959#msg28959 date=1410492180]
    具体怎么把读取数据后的表格导出成一个excel文件呢?谢谢!
    [/quote]
    开发导出模块,大概就是用python读取数据库然后导出成excel。
    一般用xlrd等


  • 【分享】在OE里用函数发邮件
    阿 阿狸

    [quote author=Jeff link=topic=16642.msg29106#msg29106 date=1412669752]

    发邮件不是这样子的么?
    您这个是发消息
    [/quote]
    总觉得我这么写有问题,果然有问题。。。

    谢谢Jeff指正


  • OE权限设置文档
    阿 阿狸

    感谢分享


  • 【分享】在OE里用函数发邮件
    阿 阿狸
    def send_the_mail(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; active_model_pool = self.pool.get(&#039;mail.thread&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; post_values = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;subject&#039;: u&#039;该开会了&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;body&#039;: u&#039;开会时间到了&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;parent_id&#039;: &#91;],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;partner_ids&#039;: [9],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;attachment_ids&#039;: &#91;],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;attachments&#039;: &#91;],<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; res_id=[0]<br />&nbsp; &nbsp; &nbsp; &nbsp; subtype = &#039;mail.mt_comment&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; msg_id = active_model_pool.message_post(cr, uid, res_id, type=&#039;comment&#039;, subtype=subtype, context=context, **post_values)
    


    其中, 'subject','body',分别为标题跟内容,partner_ids为res.user里的partner_id,发送给partner_id对应的联系人,前提是该user填写了邮箱地址,大前提是在OE里配置好了邮件发送服务器

    关于发送邮件若有更好的方法还请罗列一下


  • 手把手教你在7.0下开发wizard【多亏了总监指导,大家一起感谢他】
    阿 阿狸

    [quote author=mrshelly link=topic=16611.msg28995#msg28995 date=1411031355]
    整些没用的. 把最重要的教程搞丢了.
    [/quote]


    嘿嘿。。


  • 手把手教你在7.0下开发wizard【多亏了总监指导,大家一起感谢他】
    阿 阿狸

    首先,先安装前两个模块,即oecn_training与oecn_training_classroom
    oecn_training_classroom_wizard是基于oecn_training_classroom改写的,当然你也可以直接装oecn_training与oecn_training_classroom_wizard.zip!
    效果图见附件。
    wizard主要是定义一个osv_memory类,视图上加一个target,其他跟正常的view没啥区别。

    现在说下怎么基于oecn_training_classroom定义wizard
    首先,在oecn_training_classroom下写一个class,我是在classroom.py里写的。当然不一定写在同一个文件里。代码如下:

    # -*- coding: utf-8 -*-<br />from openerp.osv import fields, osv<br /> <br />class oecn_training_classroom(osv.osv):<br />&nbsp; &nbsp; _name = &#039;oecn.training.classroom&#039;<br />&nbsp; &nbsp; _description = u&#039;OECN 教室&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;number&#039;:fields.char(u&#039;编号&#039;, size=64, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;capacity&#039;:fields.integer(u&#039;容纳人数&#039;, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;location&#039;:fields.char(u&#039;地点&#039;, size=125, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;room_ids&#039;:fields.many2many(&#039;oecn.training.classroom.wizard&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;classroom_many2many&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;class_room_id&#039;,&#039;room_id&#039;,&nbsp; string=&#039;room&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />class oecn_training_classroom_wizard(osv.osv_memory):<br />&nbsp; &nbsp; _name = &#039;oecn.training.classroom.wizard&#039;<br />&nbsp; &nbsp; _description = u&#039;OECN 教室2&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;p_number&#039;:fields.integer(u&#039;容纳人数&#039;, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;class_room_ids&#039;:fields.many2many(&#039;oecn.training.classroom&#039;, &#039;classroom_many2many&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;room_id&#039;, &#039;class_room_id&#039;, string=&#039;room&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; def act_done(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp;  raise osv.except_osv(_(&#039;Error!&#039;), _(&#039;Set OK!&#039;))<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />oecn_training_classroom()<br />oecn_training_classroom_wizard()<br />
    


    其中最关键的继承osv.osv_memory类

    xml里添加如下代码:

    &lt;!--定义表单视图--&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record model=&quot;ir.ui.view&quot; id=&quot;oecn_training_classroom_wizard_form_view&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;课程表单&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;type&quot;&gt;form&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model&quot;&gt;oecn.training.classroom.wizard&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form string=&quot;课程表单&quot; version=&quot;7.0&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button name=&quot;act_done&quot; string=&quot;Set It!&quot; type=&quot;object&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;p_number&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;class_room_ids&quot; widget=&quot;many2many_tags&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;!--定义列表视图--&gt;<br />&lt;!--定义视图动作--&gt;<br />&nbsp; &nbsp; &lt;record model=&quot;ir.actions.act_window&quot;&nbsp; id=&quot;action_oecn_training_classroom_wizard&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;课程&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;res_model&quot;&gt;oecn.training.classroom.wizard&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;view_type&quot;&gt;form&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;view_mode&quot;&gt;form,tree&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;view_id&quot; ref=&quot;oecn_training_classroom_wizard_form_view&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;target&quot;&gt;new&lt;/field&gt;<br />&nbsp; &nbsp; &lt;/record&gt;<br />&lt;!--定义菜单--&gt;<br />&nbsp; &nbsp; &lt;menuitem id=&quot;oecn_menu&quot; name=&quot;OECN&quot;/&gt;<br />&nbsp; &nbsp; &lt;menuitem id=&quot;oecn_training_menu&quot; name=&quot;OECN Training&quot; parent=&quot;oecn_menu&quot;/&gt;<br />&nbsp; &nbsp; &lt;menuitem id=&quot;oecn_training_classroom_wizard_menu2&quot; name=&quot;OECN Training Lesson2&quot; parent=&quot;oecn_training_menu&quot; action=&quot;action_oecn_training_classroom_wizard&quot;/&gt; 
    



    注意几点,wizard不需要tree视图,另外,需要在视图动作下加上<field name="target">new</field>。
    这样wizard就出现了,然后可以根据业务逻辑添加自己想要的功能。。

    貌似没有其他的了。。wizard只会挡门外汉,进来了发现没那么难。。


  • 手把手教你在7.0下开发wizard【多亏了总监指导,大家一起感谢他】
    阿 阿狸

    首先,总监集耐心,爱心,雄心与一心;学富,财富,情妇与一身。
    气度非凡,气宇轩昂,气壮河山;英俊潇洒,英姿飒爽,英姿焕发。
    总监1岁会打字,3岁会编程,4岁满地跑,6岁单手抱电脑;
    10岁进微软,15开公司,18收谷歌,20成首富。
    看淡世间情与乱,屈身公司当总监。
    热心教导新来人,不求谢来不求钱。


    咳咳,说好的教程呢?写二楼好了,一楼赞总监


  • 【分享】禁用日历视图下的事件可以随意拖动功能,该功能容易引起误操作
    阿 阿狸

    老规矩,先说下情景:
        最近在做会议模块功能扩展时,发现了一个“bug”,会议时间过长时点击日历视图下的事件会随机延后一段时间,照成事件飘逸,经总监指点找到了该模块的源码,即web_calendar模块,在模块里一通乱翻,才发现那是人家的功能:即日历视图下的模块支持拖动功能。。。(吐,看来得换鼠标了)
        不过该拖动功能容易照成误操作,嘛,找到了“说辞”就该“加其罪”了,果断禁用掉!(叫你浪费我半天时间!)
    在addons\web_calendar\static\lib\dhtmlxScheduler\sources下有个dhtmlxScheduler.js文件
    在其2362行处,
    switch (classname) {
    case "dhx_cal_event_line":

    下面边加一个break;即可
    该方法简单粗暴,一劳永逸

    switch (classname) {
    case "dhx_cal_event_line":
                        break;


  • 【分享-oe嵌入qweb】用js读取数据库数据,用类似html语言重写web报表
    阿 阿狸

    [quote author=行云流水 link=topic=16554.msg28741#msg28741 date=1408090429]
    结合 上面几篇文章  掉坑了,然后 找老刘 要了 样例  bzr branch lp:~niv-openerp/+junk/oepetstore -r 1

    然后从坑里 爬了出来

    安装 这个  教程 [检测到链接无效,已移除] br />
    看 楼主的 顺序 ,没理解前都会copy  看看 能不能运行。。  js  ,xml 写了,然后掉坑里了

    1、出菜单 ,贴代码

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;openerp&gt;<br />&nbsp; &nbsp; &lt;data&gt;<br />&nbsp; &nbsp; &nbsp; &lt;!-- Top menu item --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;menuitem name=&quot;Test&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id=&quot;menu_test_root&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sequence=&quot;30&quot;/&gt;<br />&nbsp; &nbsp;  &lt;record model=&quot;ir.actions.client&quot; id=&quot;action_client_example&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;Example Client Action&lt;/field&gt;<br />&nbsp;  &lt;!-- 此处 name&nbsp; 修改了 浏览器 title&nbsp; &nbsp; --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;tag&quot;&gt;petstore.homepage&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;  &lt;!-- 此处 tag 内容 要对应&nbsp; js&nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp;  instance.web.client_actions.add(&#039;petstore.homepage&#039;, &#039;instance.oepetstore.HomePage&#039;);<br /><br />这个 阿狸木有 解释,或者不解释 。<br /><br />济南-stone&nbsp; 提示 过 , “找action.tag是否写对”&nbsp; 结果不得要领<br />看了样例才知道<br />&nbsp; &nbsp; &nbsp; &nbsp;  --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br /> &lt;!-- 此处 tag 内容 要对应&nbsp; js&nbsp; &nbsp;  这个 阿狸木有 解释,或者不解释 。<br />&nbsp; --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;menuitem id=&quot;test_qweb_menu&quot; name=&quot;test qweb&quot; sequence=&quot;20&quot; parent=&quot;menu_test_root&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;menuitem action=&quot;action_client_example&quot; id=&quot;menu_client_example&quot; parent=&quot;test_qweb_menu&quot; name=&quot;test report qweb&quot;/&gt;<br />&nbsp; &nbsp; &lt;/data&gt;<br />&lt;/openerp&gt;
    





    这样 界面可以出  hello  world

    [/quote]

    我上面说了, 注意qweb的name字段等与js中的关联,就不一一说了,仔细看就看出来了。

    。。。

    PS: 你这坑掉的可真深啊 ;D


  • 【分享-oe嵌入qweb】用js读取数据库数据,用类似html语言重写web报表
    阿 阿狸

    本来是开发个报表模块,具体功能为:OE读取excel表格-web显示-导出成excel。
    做完了拿给老板看时,老板对web显示这一块大不满意(用的OE自带的form页面),觉得人性化方便做的不到位,让我重新设计web页面,于是开始了为期一个月的前端研究。

    起先是打算自己脱离OE搞个前端来显示这个报表,用的是Django做了一个页面,做的差不多时拿给老板看,老板说从OE再弹出个窗口体验性差,叫我整合进OE里,当时我就(此处省略若干字。。)

    不得已就去翻官网文档,看到这篇文档:https://doc.odoo.com/trunk/training/web_framework/
    后大有启发,决定用qweb来写这个报表。其中多亏了群里的高手指点,才得以实现呀

    看了这么久是不是着急看代码 8),嘿嘿。。

    首先从梦姑处偷了点经验,看了他的帖子:http://shine-it.net/index.php/topic,16514.0.html

    他的贴子里的我就不重复了

    先是js读取数据库:

    start: function() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new instance.web.Model(&quot;lcqc.date.table.smt.data&quot;).query().filter([[&quot;smt_qctable_id&quot;, &quot;=&quot;, 139]])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .all().then(function(result) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log(&quot;##################the message_of_the_day result is&quot;, result);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.append($(QWeb.render(&quot;MessageofTheDay&quot;, {item: result})));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; },
    


    值得注意的是得到的是一个object
    然后把参数item: result传递给qweb。
    qweb代码:

    &lt;t t-name=&quot;MessageofTheDay&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=&quot;oe_petstore_motd&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;table&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;t t-foreach=&quot;item&quot; t-as=&quot;qname&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;t t-esc=&quot;qname.date_smtqc_statistical_table&quot;/&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;t t-esc=&quot;qname.inspector_smtqc_st&quot;/&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ..................<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;/tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/t&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/table&gt;<br />&nbsp; &nbsp; &lt;/t&gt;
    


    注意qweb的name字段等与js中的关联,就不一一说了,仔细看就看出来了。

    然后就是整合进OE:
    首先是__openerp__.py中的定义:
        'data': ['qc_table_qweb.xml'],
        "js": ["static/src/js/.js"],
        "css": ["static/src/css/
    .css"],
        "qweb": ["static/src/xml/*.xml"], 
    其中qc_table_qweb.xml放在模块的根目录里,其代码:

    &lt;openerp&gt;<br />&nbsp; &nbsp; &lt;data&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record model=&quot;ir.actions.client&quot; id=&quot;action_client_example&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;Example Client Action&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;tag&quot;&gt;example.action&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />		&lt;menuitem id=&quot;qc_table_qweb_menu&quot; name=&quot;QC报表qweb&quot; sequence=&quot;20&quot; parent=&quot;qc_table_menu&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;menuitem action=&quot;action_client_example&quot; id=&quot;menu_client_example&quot; parent=&quot;qc_table_qweb_menu&quot; name=&quot;qc_smt日报表qweb&quot;/&gt;<br />&nbsp; &nbsp; &lt;/data&gt;<br />&lt;/openerp&gt;
    



    同样注意下name字段与js的关联,才能保证正确显示。

    css:

    .oe_petstore_motd td,th{<br />&nbsp; &nbsp; border:1px solid blue;<br />}<br />.oe_petstore_motd td{<br />&nbsp; &nbsp; color:#F80E0E;<br />}
    


    其实我还是建议看上面的英文文档,跟着教程一步一步走,才能把握到精髓呀!

    下面上一张效果图:


  • Fields.function store=True 执行次数的问题(已解决)
    阿 阿狸

    【大校】上海-开阖Jeff(85822082) 2014-08-06 21:41:00查看前后消息
    @上海-Joshua 大神曾经说过,store=true 相当于 store = {self._name:(lambda self, cr, uid, ids, c={}: ids, None, 10)


  • Js初探
    阿 阿狸

    感谢梦姑的分享,让好多新人少走了弯路,赞一个!希望后续再多多分享宝贵的经验,嘿嘿

  • 登录

  • 没有帐号? 注册

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