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

P

panyi5202

@panyi5202
关于
帖子
8
主题
3
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • 部分记录查看、部分记录编辑的权限配置方法
    P panyi5202

    由于公司业务的需要,公司的行政经理需要看到所有的员工,但是又只能让他们修改自己公司的员工(公司是集团架构),之前自己摸索一直没成功,今天在jeff的指导下,终于配置成功,配置方法很简单(之前主要是没有掌握一个诀窍):
    1、在 人力资源 / 经理 组中增加一条规则,限定记录的访问范围([('company_id','=',user.company_id.id)]);
    2、在访问权限(对象级别权限)那里要把“读权限”上面的勾去掉,新建、修改、删除的权限都勾上;

    其实事后想想,确实是应该这样,读权限应该要用 雇员组 中的权限,如果这里勾选了读权限,会覆盖掉之前的,导致只能看到自己公司的员工。

    美中不足:这样配置后,对于只能查看的记录,在form视图中还是会显示编辑按钮,只是点击后会提示没有权限。
    要是按钮都不出来就美啦!!!

    :P[size=14pt][b]补充[/b][/size]
    之前配置规则时都只是配置了记录级的权限,在页面配置的时候发现是可以同时配置对象级别的权限的,在addons宝库里搜索了一把,呦,还真有,有好东西当然要和大家一起分享。现将例子奉上:

    &lt;record id=&quot;goal_officer_visibility&quot; model=&quot;ir.rule&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;HR Officer can see any goal&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model_id&quot; ref=&quot;gamification.model_gamification_goal&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;groups&quot; eval=&quot;[(4, ref(&#039;base.group_hr_user&#039;))]&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;perm_read&quot; eval=&quot;True&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;perm_write&quot; eval=&quot;True&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;perm_create&quot; eval=&quot;False&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;perm_unlink&quot; eval=&quot;False&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;domain_force&quot;&gt;[(1, &#039;=&#039;, 1)]&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;
    

  • Excel导出
    P panyi5202

    今天从高人那里学来一招不用写controller的excel导出方式,赶快记录下来,不废话,直接上代码:

    #下载清单<br />&nbsp; &nbsp; def down_lines(self, cr, uid,ids, context=None): <br />&nbsp; &nbsp; &nbsp; &nbsp; addonpath = &quot;/home/davidli/workspace/fiat/&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; title = [u&#039;编号&#039;,u&#039;零部件号&#039;,u&#039;零部件名称&#039;,u&#039;数量&#039;,u&#039;单位&#039;,u&#039;标准成本&#039;,u&#039;总额&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; lines_obj = self.pool.get(&quot;gfiat.com_parts_recipients_lines&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; lines_ids=lines_obj.search(cr, uid, [(&#039;com_parts_recipients_apply_id&#039;, &#039;=&#039;, ids[0])])<br />&nbsp; &nbsp; &nbsp; &nbsp; lines_result=lines_obj.read(cr, uid, lines_ids,&#91;&#039;number&#039;,&#039;parts_no&#039;,&#039;parts_name&#039;,&#039;parts_quantity&#039;,&#039;unit&#039;,&#039;standard_cost&#039;,&#039;total_price&#039;], context)<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; writedata = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; for row in lines_result:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata = &#91;&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[0] = row&#91;&#039;number&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[1] = row&#91;&#039;parts_no&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[2] = row&#91;&#039;parts_name&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[3] = row&#91;&#039;parts_quantity&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[4] = row&#91;&#039;unit&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[5] = row&#91;&#039;standard_cost&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowdata[6] = row&#91;&#039;total_price&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writedata.append(rowdata)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; filepath = &quot;/fiat_com_department/static/&quot;+datetime.datetime.now().strftime(&quot;%Y%m%d%H%M%S%f&quot;)+&quot;.xls&quot;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; down_xls_report.write_report1_xls(cr, uid, title, writedata, 0, len(title), addonpath+filepath)<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; #创建一个sheet<br />&nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; return {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;name&#039;:&quot;download&quot;,<br />#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#039;url&#039;:&quot;http://www.baidu.com&quot;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;url&#039;:&quot;http://localhost:8069&quot;+filepath,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: &#039;ir.actions.act_url&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;target&#039;: &#039;self&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
    

    ``` #报表文件写出到excel文件
        def write_report1_xls(self, cr, uid,title,data,startrow,collen,filepath):
            #collen = 11
            wbk = xlwt.Workbook()
            sheet = wbk.add_sheet('sheet 1',cell_overwrite_ok=True)
            x=0
            while x<collen:
                sheet.write(startrow,x,title[x])
                x+=1
               
            row_index = startrow+1
            for row in data:
                col_index = 0
                while col_index<collen:
                    sheet.write(row_index,col_index,row[col_index])
                    col_index += 1
                   
                row_index += 1
               
            #wbk.save('/home/stevezhou/zambon201403/testwrite.xls')
            wbk.save(filepath)
            print "write file %s finished!" % filepath ```

    说明:上面的路径信息都是可以写到系统参数配置的。

  • 字段名不要用汉字或者大写字母
    P panyi5202

    证据确凿,先顶为上


  • [分享]OpenERP Web Client 事件处理源码初探
    P panyi5202

    这里面有几个问题:
    [list type=decimal]
    [li]同一个事件,能不能绑定多一个响应方法?后面的绑定会不会覆盖前面的绑定?[/li]
    [li]如果可以同时绑定多个响应的话,这几个响应是并行还是串行?[/li]
    [/list]

    下次我也要找个机会试一下。


  • Js初探
    P panyi5202

    多谢阿狸的提醒,把python中的定义的方法补充了一下


  • Js初探
    P panyi5202

    openerp.syt_insurance,其中的syt_insurance必须是模块名,否则,这里定义的js对象是不会初始化的。我就是在这个地方浪费了好多事件啊。。。再次感谢Tommy


  • Js初探
    P panyi5202

    最近准备通过js来对oe的页面做一些默认没有的效果,先研究下页面的按钮要怎么样才能调用到js方法;
    研究的思路如下:
    1、先要让js文件加载到页面;
    2、初始化js的对象;
    3、按钮的方法要能调用到js的对象的方法;这里有两种路径,一种是页面的按钮经过后台的python方法调用js方法,一种是在页面的按钮上定义onclick事件,直接调用;

    碰到的问题如下:
    1、通过在__openerp__.py文件中定义js,是可以加载js文件的,但是发现js文件加载到页面后,并没有初始化;

    解决办法:
    1、经过@深圳-Tommy的提醒,在js中定义的对象,必须和模块名相同;
    2、如果要页面的按钮上添加onclick事件,需要在按钮外面包<html>标签。

    老规矩,附上代码:
    openerp.py中的js文件引入:

    {...<br />&nbsp; &nbsp; &quot;installable&quot; : True,&nbsp; # 可否安装&nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &#039;auto_install&#039;: False,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &quot;category&quot;:u&#039;保险&#039;,&nbsp; # 模块类型<br />&nbsp; &nbsp; &#039;js&#039;: &#91;&#039;static/src/js/syt_insurance222.js&#039;,],<br />}
    


    js类定义如下:

    openerp.syt_insurance = function(instance) {<br />	instance.web.client_actions.add(&#039;bt_start&#039;, &#039;instance.syt_insurance.btn_start&#039;);<br />	instance.syt_insurance.btn_start = function() {<br />		var self = this;<br />		alert(&#039;test&#039;);<br />		return false;<br />	};<br />};<br />function aaa(){<br />	alert(123);<br />}<br />
    


    页面调用,通过python方法:

    &lt;button name=&quot;call_js&quot;&nbsp; groups=&quot;base.group_erp_manager&quot;&nbsp; string=&quot;调用js方法&quot; type=&quot;object&quot;/&gt;
    


    页面调用,直接通过onclick:

    &lt;html&gt;<br />	&lt;input type=&quot;button&quot; value=&quot;获得设备代码&quot; onclick=&quot;aaa(this)&quot; class=&quot;oe_button oe_form_button_save&quot;/&gt;<br /> &lt;/html&gt;
    


    python类中定义的方法:

    def call_js(self, cr, uid, ids,context=None): <br />&nbsp; &nbsp; &nbsp; &nbsp; context={}<br />&nbsp; &nbsp; &nbsp; &nbsp; context[&quot;key&quot;]=&quot;value&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; print &quot;call——js...&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; ret = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: &#039;ir.actions.client&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;tag&#039;: &#039;bt_start&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;context&#039;: context,<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; return ret
    

  • Act_window 里的 res_id 参数
    P panyi5202

    大爱啊,下次我再试一个用eval的,看能不能支持表达式,期望达到的效果:默认显示今天的创建的记录;当然即使这样也没完,还有可以继续深挖的,比如按日期排序,默认显示最近的那条记录。

  • 登录

  • 没有帐号? 注册

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