Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

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

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

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

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

    创建人为当前用户则显示,其余人则隐藏按钮

    Odoo 开发与实施交流
    9
    17
    6765
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 萧
      萧云飞 last edited by

      新人向各位朋友问好了。最近在做一个模块的二次开发时遇见了一种需求:
          在form视图中有个按钮B,还有一个many2one字段A(关联的res.users),当当前用户的id等于这个的id时,这个按钮B显示,否则隐藏。
      我试着设置了下attrs="{'invisibal':[('A.id','!=',uid)]}" 但是会报错,报错信息显示uid没有定义,现在不知道怎么弄了,大家能帮我解答下么?

      1 Reply Last reply Reply Quote 0
      • 静静
        静静 last edited by

        用户组判断。

        1 Reply Last reply Reply Quote 0
        • 萧
          萧云飞 last edited by

          [quote author=开阖-静静 link=topic=17417.msg31498#msg31498 date=1448264724]
          用户组判断。
          [/quote]

          你的意思是给button设置groups属性吗?但是能看见这个按钮和不能看见这个按钮的用户都是属于同一个组的。

          1 Reply Last reply Reply Quote 0
          • 静静
            静静 last edited by

            那就自定义一个用户组,让谁看谁在里边。

            1 Reply Last reply Reply Quote 0
            • wjfonhand
              wjfonhand last edited by

              可以试一下在form对应的act_window里用context传uid,然后在invisible属性里用context.get()

              GoodERP -- Odoo China fork

              1 Reply Last reply Reply Quote 0
              • 萧
                萧云飞 last edited by

                感谢各位,已找到个笨方法,我在实体里面多定义了boolean个字段A,然后用compute的方式判断当前用户是不是创建人,并且不保存在数据库中,然后设置A的值,然后再在button中判断A字段的值,用以控制button的显示或则隐藏。

                1 Reply Last reply Reply Quote 0
                • 萧
                  萧云飞 last edited by

                  [quote author=Jeff link=topic=17417.msg31504#msg31504 date=1448336441]
                  可以试一下在form对应的act_window里用context传uid,然后在invisible属性里用context.get()
                  [/quote]

                  感谢,我抽空的时候再试试,然后贴出答案

                  1 Reply Last reply Reply Quote 0
                  • O
                    oldbro last edited by

                    也许可以在acces rulers.xml里添加domain_force

                    1 Reply Last reply Reply Quote 0
                    • N
                      newnewman80 last edited by

                      在考量odoo中,想问问二次开发的工作量一般会有多大的呢?

                      1 Reply Last reply Reply Quote 0
                      • A
                        a136794drt last edited by

                        在action定义里面写context,传入uid,如何在ui视图获取当前用户?

                        1 Reply Last reply Reply Quote 0
                        • 周
                          周士超 last edited by

                          [quote author=Jeff link=topic=17417.msg31504#msg31504 date=1448336441]
                          可以试一下在form对应的act_window里用context传uid,然后在invisible属性里用context.get()
                          [/quote]
                          感觉这个是正解

                          1 Reply Last reply Reply Quote 0
                          • wjfonhand
                            wjfonhand last edited by

                            试了一下,没发现什么好办法。可能只有在按钮点击之后判断报错了。不太友好。

                            GoodERP -- Odoo China fork

                            1 Reply Last reply Reply Quote 0
                            • KevinKong
                              KevinKong last edited by

                              系统不认识uid,你就让它认识uid嘛~~~

                              重写orm.py中的transfer_node_to_modifiers方法

                              <br />def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False):<br />	if node.get(&#039;attrs&#039;):<br />		if &#039;uid&#039; in&nbsp; node.get(&#039;attrs&#039;):<br />			uid = 1#获取当前登录用户的id,怎么获取?留个坑,拒绝伸手党~<br />		modifiers.update(eval(node.get(&#039;attrs&#039;)))<br />
                              



                              bingo~ 以后就可以愉快地在attrs里和uid进行玩耍啦! 😮 😮 😮 😮

                              1 Reply Last reply Reply Quote 0
                              • I
                                iooop last edited by

                                另外一个方案是覆盖一下field_view_get()方法,修改返回给浏览器的XML。

                                1 Reply Last reply Reply Quote 0
                                • KevinKong
                                  KevinKong last edited by

                                  [quote author=iooop link=topic=17417.msg31545#msg31545 date=1448954462]
                                  另外一个方案是覆盖一下field_view_get()方法,修改返回给浏览器的XML。
                                  [/quote]

                                  field_view_get 可以解决当前页面的问题,但不具有普适性。

                                  1 Reply Last reply Reply Quote 0
                                  • 萧
                                    萧云飞 last edited by

                                    [quote author=KevinKong link=topic=17417.msg31544#msg31544 date=1448953273]
                                    系统不认识uid,你就让它认识uid嘛~~~

                                    重写orm.py中的transfer_node_to_modifiers方法

                                    <br />def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False):<br />	if node.get(&#039;attrs&#039;):<br />		if &#039;uid&#039; in&nbsp; node.get(&#039;attrs&#039;):<br />			uid = 1#获取当前登录用户的id,怎么获取?留个坑,拒绝伸手党~<br />		modifiers.update(eval(node.get(&#039;attrs&#039;)))<br />
                                    



                                    bingo~ 以后就可以愉快地在attrs里和uid进行玩耍啦! 😮 😮 😮 😮
                                    [/quote]

                                    谢谢你的提示哦,已经能获取了

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post