<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                在odoo中新建兩個用戶user1,user2 ![](http://upload-images.jianshu.io/upload_images/3551405-2e9c89e6b9ef2e85.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 新建用戶 建完了用戶,記得編輯用戶,設置密碼。 然后以user1用戶登錄系統,在導航菜單中我們看不到`請假`菜單,因為我們沒有給user1這個用戶請假模塊的權限。編輯`security/ir.model.access.csv` ~~~ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_qingjia_qingjiadan,qingjia.qingjiadan,model_qingjia_qingjiadan,base.group_user,1,1,1,1 ~~~ id 權限id,默認規則是`access_模塊名_類名`,還沒發現有什么用 name 權限名,默認規則是`模塊名.類名`,還沒發現有什么用 model_id:id 這個是固定寫法,規則是`model_模塊名_類名`,其它地方引用權限會用這個id group_id:id 組id,這里的`base.group_user`是系統內置組,即`員工.員工`組,創建帳戶時,默認屬于這個組。所以給這個組賦權限,相當于給新帳戶的默認權限。 perm_read,perm_write,perm_create,perm_unlink 對應讀、寫、增加、刪除權限,1是有權限,0是無權限,具體根據需要來設置權限 編輯`__manifest__.py` ~~~ # -*- coding: utf-8 -*- { 'name': "qingjia", 'summary': """ 請假模塊""", 'description': """ 請假模塊 """, 'author': "leo", 'website': "http://www.yourcompany.com", # Categories can be used to filter modules in modules listing # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml # for the full list 'category': 'Uncategorized', 'version': '0.1', # any module necessary for this one to work correctly 'depends': ['base'], # always loaded 'data': [ 'security/ir.model.access.csv', 'views/views.xml', 'views/templates.xml', ], # only loaded in demonstration mode 'demo': [ 'demo/demo.xml', ], 'application': True, } ~~~ 在`'data':[]`中添加權限文件?`'security/ir.model.access.csv'`, 新增一行`'application': True,`這樣在應用中默認能搜索到請假單模塊,因為應用列表默認使用`應用`過濾器的。 以管理員身份登錄系統,在應用>應用查找qingjia模塊。然后升級。 ![](http://upload-images.jianshu.io/upload_images/3551405-0fa397b435335423.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 新增請假單 使用user1用戶登錄系統,現在可以看到`請假`菜單了。新建一個請假單。看起來功能正常。然后我們用user2登錄系統。也可以看到這個請假單。如果我們希望用戶只能看到自己的請假單,如何做呢,修改代碼`views/views.xml` ~~~ <openerp> <data> <!-- tree視圖 --> <record id="view_tree_qingjia_qingjiadan" model="ir.ui.view"> <field name="name">請假單列表</field> <field name="model">qingjia.qingjiadan</field> <field name="arch" type="xml"> <tree> <field name="name"/> <field name="days"/> <field name="startdate"/> </tree> </field> </record> <!-- form視圖 --> <record id="view_form_qingjia_qingjiadan" model="ir.ui.view"> <field name="name">請假單</field> <field name="model">qingjia.qingjiadan</field> <field name="arch" type="xml"> <form> <sheet> <group name="group_top" string="請假單"> <field name="name"/> <field name="days"/> <field name="startdate"/> <field name="reason"/> </group> </sheet> </form> </field> </record> <!-- 視圖動作 --> <act_window id="action_qingjia_qingjiadan" name="請假單" res_model="qingjia.qingjiadan" view_mode="tree,form" /> <!-- 頂級菜單 --> <menuitem name="請假" id="menu_qingjia"/> <!-- 二級菜單 --> <menuitem name="請假單" id="menu_qingjia_qingjiadan" parent="menu_qingjia" action="action_qingjia_qingjiadan"/> <!--record 規則 --> <record id="rule_user_qingjia_qingjiadan" model="ir.rule"> <field name="name">自己編輯自己的請假單</field> <field name="model_id" ref="model_qingjia_qingjiadan" /> <field name="domain_force">[('create_uid','=',user.id)]</field> <field name="groups" eval="[(4,ref('base.group_user'))]"/> </record> </data> </openerp> ~~~ 增加了一個record 規則,幾個關鍵屬性 model_id 模塊id,對應`ir.model.access.csv`文件中定義的`model_id` domain_forc domain表達式,`'create_uid'`是`qiangjia_qingjiadan`表的字段,在insert數據時,odoo自動寫入添加用戶的id。`user.id`是當前用戶id。這個domain表達式的含義就是請假單數據的添加用戶id等于當前用戶id. groups 組id,`base.group_user`前面說過,是系統內置的員工組的外部id 再次升級請假模塊,現在user1、user2都只能看到自己的請假單,管理員可以看到全部的請假單。odoo管理員默認擁有全部權限。 #### 總結下odoo權限分級: * 第一級是access rule,即表級權限,控制用戶組對表的訪問權限,一般是用`security/ir.model.access.csv`文件來管理 * 第二級是record rule,即行級權限,控制用戶組對表中數據行的訪問權限,可以寫在`views/views.xml`文件中 * 其實還有第三級權限,是字段級權限,之后再學習。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看