Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6220 มุมมอง

Friends,

Usually i write record rules from settings>Security in odoo.

Can we write it directly in any files like we write access writes for a group?

Thanks..

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Yes.

To create a rule, you need to set this record at MODULE_NAME/security/security.xml.
        <record id="portal_read_own_res_partner" model="ir.rule">
            <field name="name">res_partner: read access on my partner</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="domain_force">[('user_ids', 'in', user.id)]</field>
            <field name="groups" eval="[(4, ref('group_portal')), (4, ref('group_anonymous'))]"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
            <field name="perm_write" eval="False"/>

            <field name="global" eval="True"/>       <!-- To set a rule as global -->
        </record>

Note:
Mostly record rules are defined inside <data noupdate="1">, so as to not update the rule if modified from Odoo Web-UI.

อวตาร
ละทิ้ง
ผู้เขียน

I did it..but rules didnt generated..which file i upgrade after change(I upgrade my module & base)..and make noupdate="0"

did you add the security.xml in __openerp__.py file? Then restart your server and upgrade your module

ผู้เขียน

Yes..I added the rules in my file_details_security.xml..the restart..then upgrade..bt no changes

ผู้เขียน

Sorry Friend,It was a mistake from my side.I chage a file and upgrade another(Both looks similer)..Thank you(1 vote & 1 tick)..

ผู้เขียน

How can we set it a global(No group)

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ม.ค. 24
3849
0
ม.ค. 24
1922
0
ธ.ค. 20
2440
1
ก.ย. 19
5299
0
มิ.ย. 17
3497